# midudev/kings-league-project architecture

> Architecture diagram of the GitHub repository midudev/kings-league-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/midudev/kings-league-project
- Repository: https://github.com/midudev/kings-league-project

## Overview

##### Main Components
- External Data Source: The Kings League Infojobs website from which data is scraped.
- Web Scraping Module: Represent the “scraping” directory as the component that includes individual modules for scraping teams, coaches, MVPs, schedule, etc. Indicate that this process uses Cheerio for HTML parsing and may also optimize images.
- Database (JSON Files): The “db” directory that houses JSON files (such as teams, coaches, schedule, leaderboard, etc.) acting as persistent storage for scraped data.
- API Layer: The “api” directory that houses the main API entry point (index.js), along with its test files; this component is built on Node.js and Hono, and it’s configured for deployment via Cloudflare Workers (as indicated by the “wrangler.toml” file).
- Web Frontend: The “src” directory (with layouts and pages) which contains the Astro-based website. This component utilizes Tailwind CSS (configured via tailwind.config.cjs) for styling and serves the user interface.
- Assets and Public Files: The “assets” and “public” folders provide static assets such as images, logos, and other media used on the website.
- CI/CD and Testing Components: Represent GitHub workflows (under “.github/workflows”) for automated deployments, scraping jobs, and readme updates, as well as testing configurations (global-setup, Vitest config, etc.).

##### Relationships and Interactions
- Deployment and Automation: Optionally, include a side branch for CI/CD pipelines (GitHub Actions) that trigger deployments for the API (via Cloudflare Workers) and updates that might regenerate or populate data for the frontend.
- Testing: Show a testing component (Vitest, global-setup tests) that validates the API and scraping functions by interacting with both the API and Database modules.

##### Important Architectural Patterns/Design Principles
- Separation of Concerns: Clearly separate the scraping, data storage, API services, and frontend presentation layers.
- API-First Design: The API is the core service that aggregates data (from the lightweight JSON “database”) and serves it to both the frontend and any consumers.
- Microservice-like Decoupling: Although all components reside within a single repository, the scraping, API, and frontend components are modular and can be thought of as separate services.

- Clear labels for each component.
- Annotations for each technology or framework involved, which helps in understanding the component responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    EX["Kings League Infojobs Website"]
    Scraper["Web Scraper – Cheerio Modules"]
    DB["Database – JSON Files"]
    API["API – Node.js & Hono on Cloudflare Workers"]
    FE["Astro Web Frontend"]
    Assets["Assets"]
    Public["Public Files"]

    subgraph "CI/CD & Testing"
        GA["GitHub Actions"]
        Testing["Vitest Testing"]
    end

    EX -->|"scrapes_data"| Scraper
    Scraper -->|"stores_JSON"| DB
    DB -->|"serves_JSON"| API
    API -->|"fetches_data"| FE
    FE -->|"uses_assets"| Assets
    FE -->|"uses_public"| Public
    GA -->|"deploys_API"| API
    GA -->|"deploys_FE"| FE
    Testing -->|"tests_API_scraper"| API
    Testing -->|"tests_scraping"| Scraper

    style EX fill:#FFE0B2,stroke:#E65100,stroke-width:2px
    style Scraper fill:#FFCC80,stroke:#FF6F00,stroke-width:2px
    style DB fill:#A5D6A7,stroke:#2E7D32,stroke-width:2px
    style API fill:#90CAF9,stroke:#1565C0,stroke-width:2px
    style FE fill:#CE93D8,stroke:#6A1B9A,stroke-width:2px
    style Assets fill:#FFF59D,stroke:#FBC02D,stroke-width:2px
    style Public fill:#FFF59D,stroke:#FBC02D,stroke-width:2px
    style GA fill:#B0BEC5,stroke:#455A64,stroke-width:2px
    style Testing fill:#B0BEC5,stroke:#455A64,stroke-width:2px

    click Scraper "https://github.com/midudev/kings-league-project/tree/main/scraping/"
    click DB "https://github.com/midudev/kings-league-project/tree/main/db/"
    click API "https://github.com/midudev/kings-league-project/tree/main/api/"
    click FE "https://github.com/midudev/kings-league-project/tree/main/src/"
    click Assets "https://github.com/midudev/kings-league-project/tree/main/assets/"
    click Public "https://github.com/midudev/kings-league-project/tree/main/public/"
    click GA "https://github.com/midudev/kings-league-project/tree/main/.github/workflows/"
    click Testing "https://github.com/midudev/kings-league-project/blob/main/vitest.config.ts"
```
