# dinhduongdev/flight-booking-management architecture

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

- Interactive diagram: https://gitdiagram.com/dinhduongdev/flight-booking-management
- Repository: https://github.com/dinhduongdev/flight-booking-management

## Overview

##### Project Overview
- This is a full-stack web application focused on flight management and booking. The backend (built using Flask with blueprints for modularity) handles user authentication (including Google OAuth), flight information management, booking/reservation processing, administrative tasks, and integration with third-party services like VNPay for payments and Cloudinary for avatar management.
- The project emphasizes distinct roles for admins, flight managers, sales staff, and customers, as well as system processes for notifications and emails.

##### Main Components
- Client/Frontend: Though the project uses server-rendered templates rather than a separate frontend directory, it makes heavy use of HTML, CSS (including bootstrap, custom CSS files), and JavaScript (custom scripts for booking, home, search, etc.). Represent this as the “User Interface” or “Web Browser Client” that interacts with the server.
- Backend Application Server: This is the Flask application located under the “backend/app” folder. Divide this further according to the major blueprints:
- Admin: For administrative tasks (flight management, dashboard, regulation changes).
- Auth: For login, signup, reset password, and Google OAuth integration.
- Bookings: For flight reservations, seat management, and VNPay payment integration.
- Flights: For flight schedule management and search functionality.
- Main: For the general user views like home and about pages.
- Errors: For error handling.
- Database Layer: The README describes an initialization process with a MySQL database. Represent this as a “Database” component interacting with the backend.
- External Services:
- Payment Gateway (VNPay): Used to handle flight reservation payments.
- Authentication/Third-party (Google OAuth): Used for user signups and logins.
- Cloudinary: For managing user avatars.
- Email Service: For token-based password resets and notifications.
- Containerization/Deployment: With Docker (Dockerfile in the backend and docker-compose file), include a “Container/Infrastructure” component, indicating that the app can be deployed in a containerized environment.

##### Relationships and Data Flow
- Interactions from the backend to external services:
- Outbound calls for Google OAuth authentication.
- Integration with VNPay for payment processing.
- Communication with Cloudinary when randomizing user avatars.
- Outbound email notifications.
- That containerization (Docker) encapsulates the backend and perhaps even the database, indicating deployment aspects.

##### Architectural Patterns & Design Principles
- Modular Architecture: Represent the multiple blueprints within Flask (admin, auth, bookings, flights, main, errors). This indicates separation of concerns.
- MVC-like Separation: Though not strictly MVC, the separation of templates (views), static files, and business logic (Flask blueprints/routes) should be represented.
- Integration Patterns: Highlight external integrations via clearly labeled connections.

- Clear labels for each component:
- Web Client (Browser)
- Flask Application (with modular blueprints: Admin, Auth, Bookings, Flights, Main, Errors)
- MySQL Database
- External Services (VNPay, Google OAuth, Cloudinary, Email Service)
- Docker Container/Infrastructure (if depicting deployment)
- User requests from browser to backend and responses back.
- Data interactions between the backend and the database.
- Backend outbound REST/API calls to payment gateways and third-party authentication.
- Rectangles for application components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        WC["Web Client"]:::web
        T["Templates"]:::web
        SA["Static Assets"]:::web
    end

    %% Application Layer
    subgraph "Application Layer"
        FA["Flask Application"]:::app
        AB["Admin Blueprint"]:::app
        AU["Auth Blueprint"]:::app
        BK["Bookings Blueprint"]:::app
        FL["Flights Blueprint"]:::app
        MN["Main Blueprint"]:::app
        ER["Errors Handler"]:::app
    end

    %% Data Layer
    subgraph "Data Layer"
        DB["MySQL Database"]:::db
    end

    %% External Services
    subgraph "External Services"
        GP["Google OAuth"]:::ext
        VN["VNPay Payment Gateway"]:::ext
        EM["Email Service"]:::ext
        CL["Cloudinary"]:::ext
    end

    %% Deployment
    subgraph "Deployment"
        DC["Docker Container"]:::cont
    end

    %% Connections
    WC -->|"HTTP_Request"| FA
    FA -->|"dispatches_to"| AB
    FA -->|"dispatches_to"| AU
    FA -->|"dispatches_to"| BK
    FA -->|"dispatches_to"| FL
    FA -->|"dispatches_to"| MN
    FA -->|"handles_errors"| ER
    FA -->|"data_RW"| DB

    AU -->|"OAuth_call"| GP
    BK -->|"process_payment"| VN
    AU -->|"send_email"| EM
    BK -->|"notify_payment"| EM
    FA -->|"avatar_mgr"| CL

    DC --> FA
    DC --> DB

    %% Styling
    classDef web fill:#F5F5DC,stroke:#333,stroke-width:2px;
    classDef app fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef db fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef ext fill:#C1FFC1,stroke:#333,stroke-width:2px;
    classDef cont fill:#FFD700,stroke:#333,stroke-width:2px;

    %% Click Events for Presentation Layer
    click T "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/templates"
    click SA "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/static"

    %% Click Events for Backend Application Server
    click FA "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/__init__.py"
    click FA "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/run.py"

    %% Click Events for Admin Blueprint
    click AB "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/admin"
    click AB "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/admin/routes.py"
    click AB "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/admin/views.py"
    click AB "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/admin/forms.py"

    %% Click Events for Auth Blueprint
    click AU "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/auth"
    click AU "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/auth/routes.py"
    click AU "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/auth/utils.py"
    click AU "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/auth/models.py"

    %% Click Events for Bookings Blueprint
    click BK "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/bookings"
    click BK "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/bookings/routes.py"
    click BK "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/bookings/vnpay.py"

    %% Click Events for Flights Blueprint
    click FL "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/flights"
    click FL "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/flights/routes.py"

    %% Click Events for Main Blueprint
    click MN "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/main"
    click MN "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/main/routes.py"

    %% Click Events for Errors Handler
    click ER "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/app/blueprints/errors"
    click ER "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/blueprints/errors/handlers.py"

    %% Click Events for Database configuration
    click DB "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/config.py"
    
    %% Click Events for Email Service templates (Auth related)
    click EM "https://github.com/dinhduongdev/flight-booking-management/blob/master/backend/app/templates/auth/reset_email.html"
    
    %% Click Events for Containerization/Deployment
    click DC "https://github.com/dinhduongdev/flight-booking-management/tree/master/backend/Dockerfile"
    click DC "https://github.com/dinhduongdev/flight-booking-management/blob/master/docker-compose.yml"
```
