# openutm/flight-passport architecture

> Architecture diagram of the GitHub repository openutm/flight-passport, 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/openutm/flight-passport
- Repository: https://github.com/openutm/flight-passport

## Overview

##### Main Components
- Django Core – Centered around the flight_passport directory. This contains the Django settings, URL configuration, WSGI/ASGI interfaces, and overall project configuration.
- Authentication & OAuth Apps – Multiple Django apps play a role:
- allauth: Provides templates and views for user authentication and account management.
- authprofiles: Handles adapter logic, migrations, and views related to OAuth profiles, playing a critical role in managing client credentials.
- oauth2_provider_jwt: Implements JWT-specific endpoints, utilities, and authentication flows.
- rolepermissions: Manages roles and permissions for fine-grained access control.
- vault: Contains additional admin commands, JWT utilities, and views that may handle secure storage or additional credential management.
- External Dependencies – Note the use of external libraries such as Authlib and Django OAuth Toolkit that are central to the OAuth and JWT capabilities.

##### Relationships and Interactions
- Flow from the client interfaces (admin interface, API clients like Postman/Insomnia) to the Django REST endpoints that handle authentication, token issuance, and OIDC flows.
- That the views/templates provided by allauth and vault serve user-facing components (like login pages, error pages, and account management) while the authprofiles and oauth2_provider_jwt apps handle back-end token logic.
- External libraries (Authlib, Django OAuth Toolkit) as shared services used by the OAuth apps to enforce protocol standards, token signing, and validation.

##### Architectural Patterns and Design Principles
- Separation of concerns typical in a full-stack Django application. Each Django app is responsible for a specific part of the authentication process.
- Use of MVC-like patterns where models (in apps like authprofiles and vault) interact with views (allauth templates, oauth2_provider_jwt views) and controllers (Django’s URL routing and middleware).
- Details about migrations, management commands (in rolepermissions and vault), and static/template resources, showing how they enable extendibility and maintenance.

##### Detail and Granularity
- Don’t shy away from splitting the architecture into as many components as possible. For example, separate out the JWT processing logic, the OAuth validation, admin operations, and role/permission management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client (Browser & API Clients)"]:::client
    B["Django Project (flight_passport)"]:::django
    subgraph "Django Project Modules"
        C["User Management (allauth)"]:::frontend
        D["OAuth Profiles (authprofiles)"]:::backend
        E["JWT Service (oauth2_provider_jwt)"]:::backend
        F["Roles & Permissions (rolepermissions)"]:::backend
        G["Admin Utilities (vault)"]:::frontend
    end
    H["Authlib"]:::external
    I["Django OAuth Toolkit"]:::external
    J["Database (Django ORM)"]:::database
    K["Container Deployment (Docker Compose & Dockerfile)"]:::infrastructure

    A -->|"requests"| B
    B -->|"handles"| C
    B -->|"handles"| D
    B -->|"handles"| E
    B -->|"handles"| F
    B -->|"handles"| G

    C -->|"templates"| G
    D -->|"profiles"| E
    E -->|"tokenIssuance"| F

    E -->|"uses"| H
    E -->|"uses"| I
    D -->|"uses"| I

    B -->|"ORMoperations"| J

    K -->|"runs"| B

    click B "https://github.com/openutm/flight-passport/tree/master/flight_passport/"
    click C "https://github.com/openutm/flight-passport/tree/master/allauth/"
    click D "https://github.com/openutm/flight-passport/tree/master/authprofiles/"
    click E "https://github.com/openutm/flight-passport/tree/master/oauth2_provider_jwt/"
    click F "https://github.com/openutm/flight-passport/tree/master/rolepermissions/"
    click G "https://github.com/openutm/flight-passport/tree/master/vault/"

    classDef client fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef django fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef frontend fill:#FADBD8,stroke:#922B21,stroke-width:2px;
    classDef backend fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#D6EAF8,stroke:#2E86C1,stroke-width:2px;
    classDef database fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef infrastructure fill:#F5EEF8,stroke:#9B59B6,stroke-width:2px;
```
