# ashwinjo/cricket-top-trumps architecture

> Architecture diagram of the GitHub repository ashwinjo/cricket-top-trumps, 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/ashwinjo/cricket-top-trumps
- Repository: https://github.com/ashwinjo/cricket-top-trumps

## Overview

##### Project type and purpose
- This is a full-stack web application called “Ek-Tappa-Out,” centered around cricket-themed gameplay and statistics.
- Frontend: React single-page application (SPA) managing UI components, game flow, leaderboard, stats, etc.
- Backend: Python service (likely FastAPI given typical `main.py` structure) exposing a RESTful API, handling CRUD operations, loading data into a SQLite database (`ek_tappa_out.db`).
- Supporting code for automated testing (pytest for backend, Playwright for frontend).

##### File structure
- Top-level:
- `frontend/` — React code, tests, config files (Playwright, package.json).
- `backend/` — Python code, database file, dependencies (`requirements.txt`, `pyproject.toml`), and test suite.
- Other docs: `gameplay-flowchart.md`, `vision.md`, `prd.md`.
- Frontend:
- `/src/components` — UI components (Card, Game, Header, Home, Leaderboard, Stats).
- `/src/context/GameContext.js` — React Context for state management.
- `/src/services/api.js` — HTTP client for API calls.
- Playwright setup in `playwright.config.js` and reports under `playwright-report`.
- Backend:
- `/app/main.py` — application entrypoint, mounts routes.
- `/app/crud.py`, `/app/models.py`, `/app/schemas.py` — standard MVC-like separation using ORM/Pydantic.
- `/app/database.py`, `/app/data_loader.py` — DB connection and seeding logic.
- Tests under `backend/tests` verifying endpoints and integration.
- Config/build:
- `frontend/package.json` and lockfile, `.gitignore`.
- `backend/requirements.txt`, `pyproject.toml`, `.env`, `run.py`, `start.sh`.

##### Key README insights
- Confirms two-part structure, minimal setup instructions stubbed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Browser and Entry Point
    Browser["Web Browser"]:::external
    Entry["public/index.html"]:::frontend
    SPA["React SPA<br/>(frontend/src)"]:::frontend
    Browser -->|"loads"| Entry
    Entry -->|"boots"| SPA

    subgraph "Frontend"
        direction TB
        UIComp["UI Components<br/>(components)"]:::frontend
        Context["GameContext.js"]:::frontend
        Service["api.js"]:::frontend
        UIComp -->|"use context"| Context
        UIComp -->|"calls API"| Service
        Context --> Service
        SPA --> UIComp
    end

    %% HTTP Interaction
    Service -->|"HTTP /api/*"| API["Backend API Router<br/>(main.py)"]:::backend

    subgraph "Backend"
        direction TB
        API
        CRUD["crud.py"]:::backend
        Schemas["schemas.py"]:::backend
        Models["models.py"]:::backend
        DBConn["database.py"]:::backend
        Loader["data_loader.py"]:::backend
        API -->|"calls CRUD"| CRUD
        CRUD -->|"uses schemas"| Schemas
        CRUD -->|"queries ORM"| Models
        Models --> DBConn
        Loader --> DBConn
        Loader --> Models
    end

    DB["SQLite Database<br/>(ek_tappa_out.db)"]:::database
    DBConn --> DB

    %% Deployment Scripts
    RunModule["run.py"]:::script
    Startup["start.sh"]:::script
    RunModule --> API
    Startup --> RunModule

    %% Testing Pipelines
    subgraph "Testing"
        direction TB
        PWConfig["playwright.config.js"]:::test
        PWTests["Playwright Tests<br/>(frontend/tests)"]:::test
        PWReport["Playwright Reports<br/>(playwright-report)"]:::test
        PyTests["pytest Suite<br/>(backend/tests)"]:::test
        PWConfig --> PWTests
        PWTests --> PWReport
        Browser --> PWTests
        PyTests --> API
    end

    %% Click Events
    click SPA "https://github.com/ashwinjo/cricket-top-trumps/tree/main/frontend/src"
    click Entry "https://github.com/ashwinjo/cricket-top-trumps/blob/main/frontend/public/index.html"
    click UIComp "https://github.com/ashwinjo/cricket-top-trumps/tree/main/frontend/src/components"
    click Context "https://github.com/ashwinjo/cricket-top-trumps/blob/main/frontend/src/context/GameContext.js"
    click Service "https://github.com/ashwinjo/cricket-top-trumps/blob/main/frontend/src/services/api.js"
    click PWTests "https://github.com/ashwinjo/cricket-top-trumps/tree/main/frontend/tests"
    click PWConfig "https://github.com/ashwinjo/cricket-top-trumps/blob/main/frontend/playwright.config.js"
    click PWReport "https://github.com/ashwinjo/cricket-top-trumps/tree/main/frontend/playwright-report"
    click API "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/main.py"
    click CRUD "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/crud.py"
    click Models "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/models.py"
    click Schemas "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/schemas.py"
    click DBConn "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/database.py"
    click Loader "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/app/data_loader.py"
    click DB "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/ek_tappa_out.db"
    click PyTests "https://github.com/ashwinjo/cricket-top-trumps/tree/main/backend/tests"
    click RunModule "https://github.com/ashwinjo/cricket-top-trumps/blob/main/backend/run.py"
    click Startup "https://github.com/ashwinjo/cricket-top-trumps/blob/main/start.sh"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef backend fill:#D5F5E3,stroke:#145A32,color:#1B2631
    classDef database fill:#FAD7A0,stroke:#B9770E,color:#1B2631
    classDef test fill:#E5E8E8,stroke:#616A6B,color:#1B2631
    classDef script fill:#FCF3CF,stroke:#B7950B,color:#1B2631
    classDef external fill:#F5EEF8,stroke:#7D3C98,color:#1B2631
```
