# askwhynot1309/formula-one-insight-dashboard architecture

> Architecture diagram of the GitHub repository askwhynot1309/formula-one-insight-dashboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/askwhynot1309/formula-one-insight-dashboard
- Repository: https://github.com/askwhynot1309/formula-one-insight-dashboard

## Overview

##### Project type and purpose
- This is a full-stack web application (“FormulaOneInsight”) that provides RESTful endpoints for Formula 1 data (circuits, drivers, teams, races, results) and a React-based SPA frontend.
- Backend stack: ASP.NET Core (.NET 8), Entity Framework Core with SQL Server, layered architecture (DAO, Repository, Services).
- Frontend stack: React, TypeScript, Vite.

##### File structure to extract main components
- Frontend:
- “Formula One FE/” → React SPA (components, pages, API client, context, hooks).
- Backend API:
- “F1API/” → ASP.NET Core Web API project (Controllers, Program.cs, appsettings, Dockerfile).
- Data Access:
- “DAO/” → EF Core DbContext, Migrations.
- Shared Types:
- “Models/” → domain entities & DTOs.
- Business Logic:
- “Services/” → service layer interfaces + implementations.
- Data Abstraction:
- “Repository/” → repository interfaces + implementations + CSV helper.
- Solution files (.sln) & docker-compose.yml for orchestration.

##### README for additional insights
- Backend runs on HTTPS port 5001, FE runs on port 5173.
- Database migrations via EF in DAO.
- Patterns used: Repository, Service layers, DTO mapping.
- Development prerequisites and run steps.

##### Main components & interactions (to represent
a. Frontend SPA (“React / Vite”)
- Calls REST APIs on F1API.
- AuthContext for JWT login flows.
b. API Layer (“ASP.NET Core Controllers”)
- Exposes endpoints under /api/[resource].
- Delegates to Services.
c. Service Layer (“Services/…Service.cs”)
- Business logic, data validation, transaction management.
- Interfaces in Services/Interface and implementations.
d. Repository Layer (“Repository/…Repository.cs”)
- CRUD operations, CSV import helper.
- Interfaces and concrete classes.
e. Data Access Layer (“DAO/F1DbContext”)
- Entity Framework Core DbContext, migrations.
- Communicates with SQL Server database.
f. Shared Models (“Models/”)
- Domain entities and DTOs used across layers.
g. Database (“SQL Server”)
- Stores persistable data (Circuits, Drivers, Teams, Races, Results, Users).
h. Docker Compose (optional)
- Orchestrates containers: F1API, perhaps SQL Server, FE.

##### Architectural patterns & design principles
- Layered (Onion) Architecture: API → Services → Repositories → DAO → DB.
- Separation of Concerns: Controllers only route, Services only business logic, Repositories only data I/O.
- Shared DTOs to decouple domain models from API surface.
- EF Core Migrations for schema versioning.
- React Context (AuthContext) for global state.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "Frontend Layer"
        UI["Formula One FE (React 18, TS, Vite)"]:::frontend
    end

    %% Backend Docker Compose Boundary
    subgraph "Docker Compose" 
        direction TB

        %% API Controllers
        subgraph "API Layer"
            direction TB
            AuthCtrl["AuthController"]:::api
            CircuitCtrl["CircuitController"]:::api
            DriverCtrl["DriverController"]:::api
            RaceCtrl["RaceController"]:::api
            RaceResultCtrl["RaceResultController"]:::api
            TeamCtrl["TeamController"]:::api
        end

        %% Services
        subgraph "Service Layer"
            direction TB
            AuthSvc["AuthService"]:::service
            IAuthSvc["IAuthService"]:::service
            CircuitSvc["CircuitService"]:::service
            ICircuitSvc["ICircuitService"]:::service
            DriverSvc["DriverService"]:::service
            IDriverSvc["IDriverService"]:::service
            RaceSvc["RaceService"]:::service
            IRaceSvc["IRaceService"]:::service
            RaceResultSvc["RaceResultService"]:::service
            IRaceResultSvc["IRaceResultService"]:::service
            TeamSvc["TeamService"]:::service
            ITeamSvc["ITeamService"]:::service
        end

        %% Repository & DAO
        subgraph "Repository & Data Access"
            direction TB
            AuthRepo["AuthenticationRepository"]:::repo
            CircuitRepo["CircuitRepository"]:::repo
            DriverRepo["DriverRepository"]:::repo
            RaceRepo["RaceRepository"]:::repo
            RaceResultRepo["RaceResultRepository"]:::repo
            TeamRepo["TeamRepository"]:::repo
            CsvHelper["CsvHelper"]:::repo
            F1DbContext["F1DbContext"]:::dao
            Migrations["Migrations"]:::dao
        end

        %% Shared Models
        Models["Models (Entities & DTOs)"]:::models

        %% Database
        DB["SQL Server"]:::db
    end

    %% Flow
    UI -->|HTTPS REST API calls| AuthCtrl
    UI -->|HTTPS REST API calls| CircuitCtrl
    UI -->|HTTPS REST API calls| DriverCtrl
    UI -->|HTTPS REST API calls| RaceCtrl
    UI -->|HTTPS REST API calls| RaceResultCtrl
    UI -->|HTTPS REST API calls| TeamCtrl

    AuthCtrl -->|"uses"| AuthSvc
    CircuitCtrl -->|"uses"| CircuitSvc
    DriverCtrl -->|"uses"| DriverSvc
    RaceCtrl -->|"uses"| RaceSvc
    RaceResultCtrl -->|"uses"| RaceResultSvc
    TeamCtrl -->|"uses"| TeamSvc

    AuthSvc -->|"implements IAuthService"| IAuthSvc
    CircuitSvc -->|"implements ICircuitService"| ICircuitSvc
    DriverSvc -->|"implements IDriverService"| IDriverSvc
    RaceSvc -->|"implements IRaceService"| IRaceSvc
    RaceResultSvc -->|"implements IRaceResultService"| IRaceResultSvc
    TeamSvc -->|"implements ITeamService"| ITeamSvc

    AuthSvc -->|"CRUD operations"| AuthRepo
    CircuitSvc -->|"CRUD operations"| CircuitRepo
    DriverSvc -->|"CRUD operations"| DriverRepo
    RaceSvc -->|"CRUD operations"| RaceRepo
    RaceResultSvc -->|"CRUD operations"| RaceResultRepo
    TeamSvc -->|"CRUD operations"| TeamRepo

    AuthRepo -->|"uses CSV helper"| CsvHelper
    CircuitRepo -->|"EF Core calls"| F1DbContext
    DriverRepo -->|"EF Core calls"| F1DbContext
    RaceRepo -->|"EF Core calls"| F1DbContext
    RaceResultRepo -->|"EF Core calls"| F1DbContext
    TeamRepo -->|"EF Core calls"| F1DbContext

    F1DbContext -->|"applies migrations"| Migrations
    F1DbContext -->|"connects"| DB

    %% Shared Models usage
    Models --> AuthCtrl
    Models --> CircuitCtrl
    Models --> DriverCtrl
    Models --> RaceCtrl
    Models --> RaceResultCtrl
    Models --> TeamCtrl
    Models --> AuthSvc
    Models --> CircuitSvc
    Models --> DriverSvc
    Models --> RaceSvc
    Models --> RaceResultSvc
    Models --> TeamSvc
    Models --> AuthRepo
    Models --> CircuitRepo
    Models --> DriverRepo
    Models --> RaceRepo
    Models --> RaceResultRepo
    Models --> TeamRepo

    %% Click Events
    click UI "https://github.com/askwhynot1309/formula-one-insight-dashboard/tree/main/Formula One FE/"
    click AuthCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/AuthController.cs"
    click CircuitCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/CircuitController.cs"
    click DriverCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/DriverController.cs"
    click RaceCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/RaceController.cs"
    click RaceResultCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/RaceResultController.cs"
    click TeamCtrl "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/F1API/Controllers/TeamController.cs"

    click AuthSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/AuthService.cs"
    click IAuthSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/IAuthService.cs"
    click CircuitSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/CircuitService.cs"
    click ICircuitSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/ICircuitService.cs"
    click DriverSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/DriverService.cs"
    click IDriverSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/IDriverService.cs"
    click RaceSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/RaceService.cs"
    click IRaceSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/IRaceService.cs"
    click RaceResultSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/RaceResultService.cs"
    click IRaceResultSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/IRaceResultService.cs"
    click TeamSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/TeamService.cs"
    click ITeamSvc "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Services/Interface/ITeamService.cs"

    click AuthRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/AuthenticationRepository.cs"
    click CircuitRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/CircuitRepository.cs"
    click DriverRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/DriverRepository.cs"
    click RaceRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/RaceRepository.cs"
    click RaceResultRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/RaceResultRepository.cs"
    click TeamRepo "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/TeamRepository.cs"
    click CsvHelper "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/Repository/Helper/CsvHelper.cs"

    click F1DbContext "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/DAO/F1DbContext.cs"
    click Migrations "https://github.com/askwhynot1309/formula-one-insight-dashboard/tree/main/DAO/Migrations/"

    click Models "https://github.com/askwhynot1309/formula-one-insight-dashboard/tree/main/Models/"

    click DB "https://github.com/askwhynot1309/formula-one-insight-dashboard/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef api fill:#D4F8D4,stroke:#28A745,color:#28A745;
    classDef service fill:#FFF4C1,stroke:#FFD324,color:#D69E00;
    classDef repo fill:#FFE8D6,stroke:#FF7F11,color:#FF7F11;
    classDef dao fill:#FFEFD5,stroke:#D2691E,color:#D2691E;
    classDef models fill:#F0E6FF,stroke:#6F42C1,color:#6F42C1;
    classDef db fill:#EDEDED,stroke:#6A737D,color:#6A737D;
```
