# mhhhsn/extreme-startup architecture

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

- Interactive diagram: https://gitdiagram.com/mhhhsn/extreme-startup
- Repository: https://github.com/mhhhsn/extreme-startup

## Overview

##### Main Components
- Backend (Flask): Located in the “flaskr” directory, this Python code is responsible for serving API endpoints and handling game logic (files like game.py, quiz_master.py, questions.py, etc.). It also serves the built static frontend files once you move the “dist” folder (renamed as “vite” in flaskr) into its directory.
- Frontend (React/Vite): Found in the “frontend” directory, this includes React components, assets, and Vite configuration. The frontend is usually built (via “npm run build”) into static files that the Flask backend serves in production. In development the React app runs on a separate port (5173) for live updates.
- Database (MongoDB): The README instructs that a MongoDB daemon must be running on port 27017. This external database supports the backend (even though its integration isn’t explicitly detailed in the file tree, the port is exposed via Docker and the manual instructions require it).
- Auxiliary / Deployment Utilities: “auxiliary” contains command wrappers and scripts (like dockerRun and flask_run_wrapper) that assist in running or deploying the project. Additionally, files like Dockerfile, .gitlab-ci.yml, and fly.toml indicate continuous integration/deployment configurations.
- Test and Bot Components: There are separate “test” and “tests” folders (including bots definitions in “test/bots”) that suggest integration and unit tests are part of the architecture. These, though not part of the deployed service, are important for understanding code quality and behavior.

##### Relationships and Interactions
- Optionally, include a “Deployment & CI/CD” component that references Docker, GitLab CI, and Fly (fly.toml), showing how the continuous integration/deployment pipeline interacts with both the Backend and Frontend components.

##### Architectural Patterns and Design Principles
- Clear separation of concerns: Frontend handles the UI using React, while backend focuses on API logic and game management.
- API-driven communication is key; the backend is “API only” for the frontend, as explicitly mentioned in the README.
- The project supports a development mode with hot module reloading for the frontend and debug mode for Flask, while production mode consolidates services.
- Micro-level modules in the “flaskr” directory (for instance, separate files for player, game, questions, etc.) show that the backend logic is modularized.
- Use of Docker and CI/CD configurations suggest that containerization and automated deployments are vital parts of the system.

##### Final Steps
- Components have clear labels.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% Main Vertical Flow
    FE["React Application (Vite)"]:::frontend
    SA["Static Assets (vite)"]:::static
    BE["Flask API"]:::backend
    DB["MongoDB (Port 27017)"]:::database
    Aux["Deployment & CI/CD"]:::deployment
    Test["Test Suite"]:::test

    %% Connections between components
    FE -->|"HTTPAPI"| BE
    FE -->|"ProdBuild"| SA
    SA -->|"ServedBy"| BE
    BE -->|"DataOps"| DB
    Aux -->|"Deploys"| FE
    Aux -->|"Deploys"| BE
    Test -->|"Tests"| FE
    Test -->|"Tests"| BE

    %% Click Events (Using component mapping)
    click FE "https://github.com/mhhhsn/extreme-startup/tree/master/frontend"
    click BE "https://github.com/mhhhsn/extreme-startup/tree/master/flaskr"
    click DB "https://github.com/mhhhsn/extreme-startup/blob/master/flaskr/database.py"
    click Aux "https://github.com/mhhhsn/extreme-startup/tree/master/auxiliary"
    click Test "https://github.com/mhhhsn/extreme-startup/tree/master/tests"
    click SA "https://github.com/mhhhsn/extreme-startup/tree/master/flaskr/vite"

    %% Style Definitions
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef database fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef deployment fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef test fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef static fill:#D5DBDB,stroke:#566573,stroke-width:2px;
```
