How afiiif/pokemon-world works
Main components
• Client/Frontend: This includes all user-facing components built with React, found under src/components and the various feature directories under src/features (e.g., compare-pokemons, guess-pokemon, pokemon-detail, pokemon-list, statistics).
• Next.js Pages & Routing: The pages directory (under src/pages) handles the composition of these React components into individual pages (e.g., index.tsx, pokemon/[...slug].tsx). This layer also includes API routes found in src/pages/api that act as server endpoints.
• API Layer / Data Fetching: Within src/api, you have a dedicated place for queries (using GraphQL) that interact with the external PokeAPI, along with configuration for react-query (src/config/react-query.ts) and related hooks.
• Build and Configuration: Elements such as the Next.js configuration (next.config.js, next-pwa.cache.js, next-sitemap.config.js), Tailwind CSS (tailwind.config.js and PostCSS configurations), and TypeScript settings (tsconfig.json) set the foundation for the build and runtime environment.
• Development, Testing, and Quality Controls: Note the existence of development tooling (such as ESLint, Prettier, Husky with commit hooks, GitHub Actions workflows, and end-to-end e2e tests in the e2e folder and playwright.config.ts).
Relationships and data flow
• The Client/Frontend sends requests (fetched via src/api/fetcher.ts) to the API endpoints (pages/api) when data needs to be fetched or manipulated.
• The API endpoints communicate with the external PokeAPI GraphQL service, using GraphQL queries defined in src/api/queries, to retrieve Pokémon data.
• The returned data flows back to frontend components that render pages based on the Next.js routing.
Important architectural patterns and design principles
• Separation of Concerns: Clear separation between client-side UI (React components and pages) and backend data fetching via API endpoints.
• Modular Feature-Based Structure: The src/features directory is broken down by domain (like compare-pokemons, guess-pokemon, etc.), which assists in maintainability and scalability.
• API Abstraction: Data queries are abstracted into their own modules (under src/api/queries), facilitating easier changes to external data sources.
• Integration of CI/CD and Code Quality: The presence of Husky, Lint-Staged, GitHub Actions, and other tooling suggests a workflow that emphasizes quality assurance throughout the development lifecycle.