# domhnallmorr/pitwall architecture

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

- Interactive diagram: https://gitdiagram.com/domhnallmorr/pitwall
- Repository: https://github.com/domhnallmorr/pitwall

## Overview

##### Project type and purpose
- Pitwall is a desktop F1 manager simulation game written in Python.
- It follows an MVC-style architecture and uses Flet for its UI.
- Key responsibilities include: simulating seasons, races, driver/staff markets, car development, facilities, emails, and persistence via load/save.

##### File structure
- Top-level:
- src/ — contains all application code
- src/pw_view/ — presentation layer (Flet views & assets)
- src/pw_controller/ — application layer (controllers & page logic)
- src/pw_model/ + src/race_weekend_model — domain layer (game models, simulation engines)
- src/1998_Roster/ + load_save subfolder — data layer (initial data & persistence)
- README.md, pyproject.toml — configuration & metadata
- tests/ — automated unit and integration tests
- Patterns:
- MVC/MVVM: Views ←→ Controllers ←→ Models
- Layered separation: presentation, application, domain, data
- Persistence:
- roster.db, season.txt, and save_game.db for initial data & save games
- load_save modules under pw_model handle serialization

##### README for insights
- Confirms Flet-based UI, Python/Poetry toolchain, GPLv3 license.
- Features highlight core modules: simulation, email, car dev, load/save.

a. Main components
1. Presentation Layer (pw_view + Flet)
2. Application Layer (pw_controller)
3. Domain Layer
- Core Models (pw_model)
- Race Simulation Engine (race_weekend_model)
4. Data Layer
- Data sources (src/1998_Roster roster.db & track files)
- Persistence (load_save modules → save_game.db)
5. Assets (images, logos under pw_view/assets)
b. Relationships & interactions
- User interacts via Presentation Layer → events routed to Controllers
- Controllers invoke Domain Layer APIs to update game state
- Domain Layer reads/writes via Data Layer (load/save, roster)
- Controllers push updates back to Presentation for rendering
c. Architectural patterns
- MVC: clear separation of concerns
- Layered architecture: UI, application logic, domain logic, data access
- Modularization by feature: car_development, driver_negotiation, finance, etc.
d. Key technologies
- Python 3.x, Poetry for dependency management
- Flet for cross-platform UI
- SQLite (via roster.db, save_game.db) or file-based persistence
- pytest for testing

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Libraries
    subgraph "External Technologies"
        direction TB
        Flet["Flet UI Library"]:::external
        Python["Python 3.x / Poetry"]:::external
    end

    %% Main Entry
    Main["Main Entry (src/main.py)"]:::entry
    click Main "https://github.com/domhnallmorr/pitwall/blob/main/src/main.py"

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Views["Flet Views (src/pw_view)"]:::presentation
        click Views "https://github.com/domhnallmorr/pitwall/tree/main/src/pw_view"
        Assets["Assets (src/pw_view/assets)"]:::presentation
        click Assets "https://github.com/domhnallmorr/pitwall/tree/main/src/pw_view/assets"
    end

    %% Application Layer (Controllers)
    subgraph "Application Layer (Controllers)"
        direction TB
        CarDevCtrl["CarDevelopmentController"]:::controller
        click CarDevCtrl "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_controller/car_development/car_development_controller.py"
        RaceCtrl["RaceWeekendController"]:::controller
        click RaceCtrl "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_controller/race_controller.py"
        EmailCtrl["EmailPageController"]:::controller
        click EmailCtrl "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_controller/email_page/email_controller.py"
        DriverNegCtrl["DriverNegotiationController"]:::controller
        click DriverNegCtrl "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_controller/driver_negotiation/driver_negotiation_controller.py"
    end

    %% Domain Layer (Models & Simulation)
    subgraph "Domain Layer"
        direction TB
        CoreModels["Core Models (src/pw_model)"]:::domain
        click CoreModels "https://github.com/domhnallmorr/pitwall/tree/main/src/pw_model"
        RaceEngine["RaceWeekendModel"]:::domain
        click RaceEngine "https://github.com/domhnallmorr/pitwall/blob/main/src/race_weekend_model/race_weekend_model.py"
        CarDevModel["CarDevelopmentModel"]:::domain
        click CarDevModel "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/car_development/car_development_model.py"
        FacilitiesModel["TeamFacilitiesModel"]:::domain
        click FacilitiesModel "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/team/facilities_model.py"
        EmailModel["EmailGenerationModel"]:::domain
        click EmailModel "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/email/email_generation.py"
        FinanceModel["FinanceModel"]:::domain
        click FinanceModel "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/finance/finance_model.py"
        DriverModel["DriverModel"]:::domain
        click DriverModel "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/driver/driver_model.py"
    end

    %% Data Layer (Persistence & Initial Data)
    subgraph "Data Layer"
        direction TB
        InitialData["Initial Data (src/1998_Roster)"]:::data
        click InitialData "https://github.com/domhnallmorr/pitwall/tree/main/src/1998_Roster"
        PersistenceDir["Load/Save Modules (src/pw_model/load_save)"]:::data
        click PersistenceDir "https://github.com/domhnallmorr/pitwall/tree/main/src/pw_model/load_save"
        CalendarLS["CalendarLoadSave"]:::data
        click CalendarLS "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/load_save/calendar_load_save.py"
        CoreLS["LoadSaveCore"]:::data
        click CoreLS "https://github.com/domhnallmorr/pitwall/blob/main/src/pw_model/load_save/load_save.py"
        RosterDB["roster.db"]:::storage
        SaveDB["save_game.db"]:::storage
    end

    %% Relationships
    Flet --> Views
    Python --> Main
    Main --> Views
    Main --> CarDevCtrl
    Main --> RaceCtrl
    Views --> CarDevCtrl --> CarDevModel
    Views --> RaceCtrl --> RaceEngine
    Views --> EmailCtrl --> EmailModel
    Views --> DriverNegCtrl --> DriverModel
    CarDevCtrl --> FacilitiesModel
    CarDevCtrl --> FinanceModel
    RaceCtrl --> CoreModels
    CoreModels --> PersistenceDir --> RosterDB
    CoreModels --> PersistenceDir --> SaveDB
    RaceEngine --> InitialData
    RaceEngine --> PersistenceDir
    EmailModel --> PersistenceDir
    DriverModel --> PersistenceDir

    %% Updates back to UI
    CarDevCtrl --> Views
    RaceCtrl --> Views
    EmailCtrl --> Views
    DriverNegCtrl --> Views

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#004085,color:#004085
    classDef controller fill:#d4edda,stroke:#155724,color:#155724
    classDef domain fill:#fff3cd,stroke:#856404,color:#856404
    classDef data fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef storage fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef external fill:#f0f0f0,stroke:#333,stroke-dasharray: 5 5
    classDef entry fill:#d1ecf1,stroke:#0c5460,color:#0c5460
```
