# amauury/pokedex-bts architecture

> Architecture diagram of the GitHub repository amauury/pokedex-bts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amauury/pokedex-bts
- Repository: https://github.com/amauury/pokedex-bts

## Overview

##### Project type and purpose
- This is a full-stack web application (“Pokedex”) with a React front end and a Flask-based REST API back end, backed by an on-disk SQLite database.
- Purpose: allow users to browse, filter, search, sort, and view details (stats, evolutions, shiny mode, multilingual) of Pokémon.

##### File structure
- Top-level:
- api/ → Flask entrypoint (api.py) + SQLite DB (pokedex.db)
- pokedex/ → React app (package.json, config/, public/, scripts/, src/)
- React side uses webpack, Babel, TypeScript, Jest for testing
- Scripts in pokedex/scripts orchestrate build, start, test
- Flask side uses flask-cors to enable cross-origin calls from React
- SQLite DB file is colocated under api/ for simplicity

##### README insights
- Explains prerequisites (Node.js, Python, pip/npm/yarn), installation, startup commands, API port 5001, frontend port 3000
- Describes functional features, multilingual support, DB config

##### Main components & their relationships
a. Frontend (React SPA)
- Runs on Node.js DevServer (webpack dev server) at localhost:3000
- Fetches data via HTTP GET/POST calls to the Flask API
- Contains UI components for listing/filtering/sorting/searching Pokémon, detail pages, language switch
b. Backend API (Flask)
- Exposes REST endpoints (e.g., /pokemons, /pokemon/:id, /filter, /search) on http://localhost:5001
- Uses flask-cors for cross-domain requests
- Reads from SQLite database pokedex.db
- Performs queries, serializes results to JSON
c. Database (SQLite)
- Single file db storing Pokémon data, stats, evolution chains, types, languages
d. Optional external services
- None in this simple setup, but external CDN or translation API could be added later

##### Architectural patterns & design principles
- Frontend: Single-Page Application (SPA) pattern, component-based architecture
- Backend: RESTful API, MVC-style separation between request handlers and data persistence
- Clear separation of concerns: UI vs. business logic vs. data storage
- Dev vs. Prod configurations managed via webpack, env.js and getHttpsConfig.js

##### Technologies & frameworks
- Frontend: React, TypeScript, webpack, Babel, Jest, CSS modules
- Backend: Python 3.7+, Flask, flask-cors, SQLite
- Build tools: npm/yarn, pip

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Browser["User Browser\n(Chrome/Firefox)"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        ReactDev["React DevServer\nNode.js @3000"]:::frontend
        subgraph "React Application" 
            direction TB
            FE_App["Frontend Application\n(React SPA)"]:::frontend
            click FE_App "https://github.com/amauury/pokedex-bts/tree/main/pokedex/"
            Entry["React Entry Point\nindex.tsx"]:::frontend
            click Entry "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/index.tsx"
            AppComp["Root App Component\nApp.tsx"]:::frontend
            click AppComp "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/App.tsx"
            subgraph "UI Components"
                direction TB
                Evo["Evolution View"]:::frontend
                click Evo "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/composants/evolution.tsx"
                Indiv["Individual Pokémon Detail"]:::frontend
                click Indiv "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/composants/individualPokemon.tsx"
                Stat["Stat Display Case"]:::frontend
                click Stat "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/composants/statCase.tsx"
            end
            Lang["Language Resources"]:::frontend
            click Lang "https://github.com/amauury/pokedex-bts/blob/main/pokedex/src/langResources.ts"
            subgraph "Configuration"
                direction TB
                Env["Environment Variables\nenv.js"]:::config
                click Env "https://github.com/amauury/pokedex-bts/blob/main/pokedex/config/env.js"
                HTTPS["HTTPS Setup\ngetHttpsConfig.js"]:::config
                click HTTPS "https://github.com/amauury/pokedex-bts/blob/main/pokedex/config/getHttpsConfig.js"
                Webpack["Webpack Config\nwebpack.config.js"]:::config
                click Webpack "https://github.com/amauury/pokedex-bts/blob/main/pokedex/config/webpack.config.js"
                JestCfg["Jest Config"]:::config
                click JestCfg "https://github.com/amauury/pokedex-bts/tree/main/pokedex/config/jest/"
                DevServerCfg["DevServer Config\nwebpackDevServer.config.js"]:::config
                click DevServerCfg "https://github.com/amauury/pokedex-bts/blob/main/pokedex/config/webpackDevServer.config.js"
            end
            subgraph "Scripts"
                direction TB
                Build["Build Script\nbuild.js"]:::script
                click Build "https://github.com/amauury/pokedex-bts/blob/main/pokedex/scripts/build.js"
                Start["Start Dev Server\nstart.js"]:::script
                click Start "https://github.com/amauury/pokedex-bts/blob/main/pokedex/scripts/start.js"
                Test["Test Script\ntest.js"]:::script
                click Test "https://github.com/amauury/pokedex-bts/blob/main/pokedex/scripts/test.js"
            end
            Public["Public Assets\nindex.html,..."]:::frontend
            click Public "https://github.com/amauury/pokedex-bts/blob/main/pokedex/public/index.html"
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        FlaskAPI["Flask API Server\napi.py @5001"]:::backend
        click FlaskAPI "https://github.com/amauury/pokedex-bts/blob/main/api/api.py"
    end

    %% Database Layer
    subgraph "Database Layer"
        direction TB
        SQLiteDB["SQLite Database\npokedex.db"]:::db
        click SQLiteDB "https://github.com/amauury/pokedex-bts/blob/main/api/pokedex.db"
    end

    %% Interactions
    Browser -->|"HTTP request"| ReactDev
    ReactDev -->|"Serves React SPA"| FE_App
    FE_App -->|"JSON REST calls\nGET/POST"| FlaskAPI
    FlaskAPI -->|"SQL queries"| SQLiteDB
    FE_App -.->|"CORS exchange"| FlaskAPI

    %% Styles
    classDef frontend fill:#fdebd0,stroke:#e67e22,stroke-width:1px
    classDef backend fill:#d6eaf8,stroke:#3498db,stroke-width:1px
    classDef db fill:#d4efdf,stroke:#27ae60,stroke-width:1px
    classDef external fill:#f5cba7,stroke:#d35400,stroke-width:1px
    classDef config fill:#e8daef,stroke:#8e44ad,stroke-width:1px
    classDef script fill:#f9e79f,stroke:#b7950b,stroke-width:1px
```
