REST Countries API - Where in the world?

This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

šŸŒ Live Demo: https://country-api-eight-wheat.vercel.app

šŸ“‹ Table of contents

Overview

The challenge

Your challenge is to integrate with the REST Countries API to pull country data and display it like in the designs.

Users should be able to:

  • See all countries from the API on the homepage
  • Search for a country using an input field
  • Filter countries by region
  • Click on a country to see more detailed information on a separate page
  • Click through to the border countries on the detail page
  • Toggle the color scheme between light and dark mode

Screenshot

Desktop Preview Mobile Preview

(Note: Add your actual screenshots if available)

My process

Built with

  • Astro 6 - Framework for content-driven websites with Islands Architecture.
  • Vue 3 (Composition API) - For interactive components.
  • Tailwind CSS v4 - Modern CSS utility framework.
  • Zod - Robust schema validation.
  • Flexbox & CSS Grid - Layout systems.
  • Mobile-first workflow - Responsive design strategy.
  • SSR (Server-Side Rendering) - For instant load times and optimal SEO.

Architecture (Clean Architecture)

The project follows a simplified Clean Architecture pattern to ensure maintainability, testability, and scalability:

src/
ā”œā”€ā”€ core/             # Core Domain (SSOT)
│   ā”œā”€ā”€ domain/       # Types, Schemas (Zod) and Centralized Errors
│   ā”œā”€ā”€ interfaces/   # Ports (Repository definitions)
│   └── use-cases/    # Unified Business Logic (e.g. GetCountries)
ā”œā”€ā”€ infrastructure/   # Data Adapters
│   ā”œā”€ā”€ cache/        # In-memory optimization
│   ā”œā”€ā”€ http/         # Core fetch with Retry & Timeout logic
│   └── repositories/ # Concrete API implementations
ā”œā”€ā”€ presentation/    # Presentation Layer
│   ā”œā”€ā”€ components/   # Vue components
│   └── composables/  # Generic reactive hooks (useAsync)
ā”œā”€ā”€ actions/          # Astro Actions (Bridges)
ā”œā”€ā”€ pages/            # Astro Routes (SSR Entry points)
└── layouts/          # Base layouts

Key Optimizations:

  • Centralization: Types and validation schemas consolidated in src/core/domain.
  • SSR Integration: Initial data fetching happens on the server, eliminating layout shifts and improving UX.
  • Intelligent Caching: Infrastructure-level caching to reduce API calls and improve performance.
  • Full Accessibility: ARIA attributes and keyboard navigation fully implemented.

šŸ“¦ Scripts

pnpm dev          # Run development server
pnpm build        # Build for production (Vercel/Node)
pnpm test         # Run unit tests (Vitest)
pnpm e2e          # Run E2E tests (Playwright)

Author

Acknowledgments

It was fun to build it! šŸš€ If you like the code, feel free to follow me. šŸ‘‹


Top categories

Loading Svelte Themes