# max2288/fly_school_game architecture

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

- Interactive diagram: https://gitdiagram.com/max2288/fly_school_game
- Repository: https://github.com/max2288/fly_school_game

## Overview

##### Main Components
- Game Client: Represented by game.py. This is the frontend part of the game where users register, authenticate, and play by controlling a small bird. It sends telemetry data (via keypresses) in real time to the server.
- API Server (Backend): Represented by main.py, which launches the FastAPI server. Complementary modules like config.py, database.py, and logger.py support configuration management, database interactions, and logging.
- Database: A PostgreSQL server running in a Docker container. The database schema is prepared via init_db.ddl, and the .env file connection parameters allow the FastAPI server to communicate with it.

##### Relationships and Interactions
- The Game Client transmits user inputs and telemetry data to the API server.
- The API server uses configuration settings (from config.py, .env variables) and logging (via logger.py) to operate properly.
- The CI/CD workflows trigger code quality checks and tests that ensure robust development practices.

##### Architectural Patterns and Technologies
- Separation of Concerns: The architecture distinctly separates the game client from backend services. The FastAPI server focuses solely on HTTP request handling while game.py is used for real-time interactions.
- Micro-architecture: Although not explicitly microservice-based (everything is in a single repository), there is a clear modular structure – game logic, API service, database connectivity, and logging are separated into different modules.
- Containerization: The use of Docker for running PostgreSQL underscores the importance of containerized services and deployment.
- Real-Time Communication: Emphasize that the API server receives real-time telemetry from the game, which guides the design of data flow and interaction handling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        FC["Game Client (game.py)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        BS["FastAPI Server (main.py)"]:::backend
        C["Configuration (config.py)"]:::backend
        D["Database Connector (database.py)"]:::backend
        L["Logger (logger.py)"]:::backend
        BS -->|"Utilizes"| C
        BS -->|"Utilizes"| D
        BS -->|"Utilizes"| L
    end

    %% Database Layer
    subgraph "Database"
        PG["PostgreSQL Database"]:::database
        NOTE["(Initialized via init_db.ddl in Docker)"]:::database
    end

    %% CI/CD Pipeline
    subgraph "CI/CD"
        CICD["GitHub Workflows (.github/workflows)"]:::cicd
    end

    %% Connections between layers
    FC -->|"Telemetry/DataFlow"| BS
    BS -->|"CRUDOperations"| PG
    CICD -.->|"CIChecks"| BS
    CICD -.->|"CIChecks"| FC

    %% Click Events
    click FC "https://github.com/max2288/fly_school_game/blob/main/game.py"
    click BS "https://github.com/max2288/fly_school_game/blob/main/main.py"
    click C "https://github.com/max2288/fly_school_game/blob/main/config.py"
    click D "https://github.com/max2288/fly_school_game/blob/main/database.py"
    click L "https://github.com/max2288/fly_school_game/blob/main/logger.py"
    click PG "https://github.com/max2288/fly_school_game/blob/main/init_db.ddl"
    click CICD "https://github.com/max2288/fly_school_game/tree/main/.github/workflows"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFD700,stroke:#000,stroke-width:2px;
```
