# splendor73/splendor_cinema_booking architecture

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

- Interactive diagram: https://gitdiagram.com/splendor73/splendor_cinema_booking
- Repository: https://github.com/splendor73/splendor_cinema_booking

## Overview

##### Project Type and Purpose
- This is a full-stack web application for movie ticket booking.
- The purpose is to provide a seamless booking experience that includes modern movie listings, real-time seat selection, secure payment integration, and automatic email notifications.
- The backend is built with Flask and PostgreSQL, while the frontend is implemented using HTML, CSS (with Bootstrap 5), and custom JavaScript for interactivity.

##### File Structure
- Top-level components include:
- app.py: The main Flask application file where routing, business logic, database connections, and mail configurations reside.
- requirements.txt: Lists all required Python dependencies for the project.
- static/ and templates/: These directories hold the frontend assets. “static/css/style.css” contains the styling, and the “templates” directory includes HTML files representing different pages (index, movies, seats, details, confirmation).
- There are no clearly separated backend or API folders, so the application is structured in a simple monolithic style with routing and logic embedded in app.py.

##### Architectural Insights from the README
- The README clearly outlines the tech stack for both backend and frontend, including Flask for web operations, PostgreSQL for persistent storage, and Flask-Mail for notifications.
- Detailed descriptions of the UI screens serve as hints on how the front-end components interact (e.g., welcome page, movie selection, seat layout, booking processing).
- Integration points such as email notifications (via Gmail SMTP) and (implicitly) payment integration are in scope.

– Identify Main Components:
- Client/User Interface:
- Web browser showing the application’s pages (index.html, movies.html, seats.html, details.html, confirmation.html).
- Web Server Layer:
- The Flask application (app.py) which handles incoming HTTP requests, applies business logic, interacts with the database, and sends out emails.
- It also serves static assets (CSS, JavaScript) and templates.
- Database:
- PostgreSQL database storing Movies, Seats, Bookings, and Booked Seats data.
- External Services:
- Email Service: Gmail SMTP through Flask-Mail to send booking confirmations.
- Payment Integration: Though not expanded on in the file structure, secure payment integration is part of the features, and its interaction should be represented.

– Relationships and Interactions:
- User Request Flow: A user interacts with the web UI (front-end) that sends HTTP requests to the Flask server.
- Flask Server Processes: The server routes requests, queries the PostgreSQL database for movie data or seat availability, and renders the appropriate HTML template.
- Database Communication: The Flask backend uses SQL queries to create, retrieve, update, or delete information in the movies, seats, bookings, and booked_seats tables.
- Email & Payment: Upon successful booking, the Flask app uses Flask-Mail to trigger an email confirmation (and processes payment via an external payment gateway).

– Architectural Patterns/Design Principles:
- Model-View-Controller (MVC)-like separation – though not formally split out into different directories, templates (views), application logic (controllers/routes in app.py), and the database (models) form the layers.
- Separation of concerns: Clearly distinct roles between user interface, business logic, and data persistence.
- Use of environment variables for configuration and separation between development settings and sensitive information.

##### What
- Main component with labels such as “Client/Web Browser”, “Flask Application (app.py)”, “PostgreSQL Database”, “Email Service (Gmail SMTP)”, and “Payment Gateway”.
- How requests originate from the client and flow to the server.
- How the server communicates with the database.
- How notifications are sent out from the server to the email service.
- (Optionally) How the payment process is invoked and its dependencies.
- Rectangles for major components.

##### Final Recommendations
– Keep it detailed enough to serve as a comprehensive overview of the architecture:
- Client → Frontend UI → Flask Server → Database.
- Additional interactions: Flask Server → Email Service and Payment Gateway.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Client Layer"
        A1["Client/Web Browser"]:::frontend
        A2["Templates (HTML)"]:::frontend
        A3["Static Assets (CSS/JS)"]:::frontend
    end

    subgraph "Backend Layer"
        B1["Flask Application (app.py)"]:::backend
    end

    subgraph "External and Database"
        C1["PostgreSQL Database"]:::database
        C2["Email Service (Gmail SMTP)"]:::external
        C3["Payment Gateway"]:::external
    end

    A1 -->|"HTTP_Request"| B1
    B1 -->|"SQL_Query"| C1
    B1 -->|"Send_Email"| C2
    B1 -->|"Process_Payment"| C3
    B1 -->|"Render_HTML"| A2
    B1 -->|"Serve_Assets"| A3

    click A2 "https://github.com/splendor73/splendor_cinema_booking/tree/main//templates"
    click A3 "https://github.com/splendor73/splendor_cinema_booking/blob/main//static/css/style.css"
    click B1 "https://github.com/splendor73/splendor_cinema_booking/blob/main//app.py"

    classDef frontend fill:#a0d8f1,stroke:#333,stroke-width:2px;
    classDef backend fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef database fill:#f5b7b1,stroke:#333,stroke-width:2px;
    classDef external fill:#d2b4de,stroke:#333,stroke-width:2px;
```
