# aberdeenrss/flightmanagementserver architecture

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

- Interactive diagram: https://gitdiagram.com/aberdeenrss/flightmanagementserver
- Repository: https://github.com/aberdeenrss/flightmanagementserver

## Overview

##### Main Components
- API Gateway / Web Server: This is represented by the “app/main.py” file and is launched via Uvicorn. It is the entry point for incoming requests.
- Controllers: Under the “app/controller” directory, you have various controllers handling HTTP endpoints for authentication, flight data, commands, vessel operations, and a dedicated “socketio” submodule to handle real-time, bi-directional communication.
- Models: The “app/models” directory defines various data models (e.g., flight, vessel, user) which structure the data being processed.
- Helpers and Middleware: “app/helper” offers utility functions and “app/middleware” (including authentication middleware) provide request-level processing such as auth-checks.
- Configuration: “app/config.py” is where various settings reside, impacting how the system behaves (which could optionally be overridden by command-line settings).
- Deployment & CI/CD: Files in “.github/workflows” (e.g., deployment and testing YAML) and the Dockerfile indicate automated deployments and containerization.

##### Relationships and Interactions
- The Uvicorn server acts as the entry point, routing HTTP requests to appropriate controllers.
- Controllers call services to perform business logic, authentication/authorization, and data access.
- Services connect to the database (MongoDB) and perform CRUD operations via the data_access modules.
- Middleware (like the auth middleware) is interposed before controllers to ensure authenticated requests.
- The socketio controllers handle live real-time connections, which likely communicate with similar service layers to dispatch commands in real time.
- The API endpoints and WebSocket endpoints are both provided, showing a separation between synchronous API calls and asynchronous, real-time communications.

##### Architectural Patterns and Design Principles
- MVC-like Decomposition: Although not strictly MVC, there is a clear separation (models, controllers, services) that provides modularity.
- Layered Architecture: The controllers, middleware, and services form layers that isolate concerns (presentation, business logic, and data persistence).
- Containerization and CI/CD: The Dockerfile and GitHub workflows denote a deployment rather than monolithic architecture and continuous integration practices.

##### Relevant Technologies and Frameworks
- Python 3.9+ for the language environment.
- Likely FastAPI or a similar ASGI framework (implied by Uvicorn in the run command).
- MongoDB as the primary data storage (from the “mongodb/mongodb_connection.py”).
- GitHub Actions for continuous integration and deployment.
- Docker for container orchestration.

##### Detail
- Don’t overcomplicate but ensure you capture all essential architectural elements: API endpoints (both HTTP and real-time), security/auth flow, business logic delegation, and database connectivity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client"]:::client

    subgraph "API Layer"
        B["API Gateway (uvicorn/app.main)"]:::apigateway
        C["Auth Middleware (requireAuth)"]:::middleware
        D["HTTP Controllers (auth,flight,command,vessel)"]:::controller
        E["SocketIO Controllers (real-time endpoints)"]:::controller
    end

    subgraph "Service Layer"
        F["Authentication Services"]:::service
        G["Data Access Services"]:::service
        H["Models"]:::model
    end

    I["MongoDB"]:::database
    J["Configuration (app/config.py)"]:::config
    K["Helpers (Utility Functions)"]:::helper

    subgraph "Deployment"
        L["CI/CD Pipeline (GitHub Workflows)"]:::deployment
        M["Dockerfile"]:::deployment
    end

    %% Connections: Request Flow
    A -->|"HTTP_request"| B
    B -->|"reads_config"| J
    B -->|"routes_to"| C
    C -->|"auth_check"| D
    C -->|"socket_connect"| E
    D -->|"calls_auth"| F
    D -->|"calls_data"| G
    D -->|"uses_models"| H
    E -->|"calls_auth"| F
    E -->|"calls_data"| G
    F -.->|"utilizes"| K
    G -.->|"utilizes"| K
    G -->|"persists_to"| I

    %% Deployment links
    L -->|"deploys_to"| B
    M -->|"builds"| B

    %% Styles
    classDef client fill:#F8B195,stroke:#000,stroke-width:2px;
    classDef apigateway fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef middleware fill:#FF6347,stroke:#000,stroke-width:2px;
    classDef controller fill:#87CEEB,stroke:#000,stroke-width:2px;
    classDef service fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef model fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef database fill:#FFE4B5,stroke:#000,stroke-width:2px;
    classDef config fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef helper fill:#B0E0E6,stroke:#000,stroke-width:2px;
    classDef deployment fill:#BC8F8F,stroke:#000,stroke-width:2px;

    %% Click Events
    click B "https://github.com/aberdeenrss/flightmanagementserver/blob/master/app/main.py"
    click D "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/controller/"
    click E "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/controller/socketio/"
    click H "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/models/"
    click F "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/services/auth/"
    click G "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/services/data_access/"
    click K "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/helper/"
    click C "https://github.com/aberdeenrss/flightmanagementserver/tree/master/app/middleware/"
    click J "https://github.com/aberdeenrss/flightmanagementserver/blob/master/app/config.py"
    click L "https://github.com/aberdeenrss/flightmanagementserver/tree/master/.github/workflows/"
    click M "https://github.com/aberdeenrss/flightmanagementserver/tree/master/Dockerfile"
```
