# andargachewtadesse/cinema-ebooking-system architecture

> Architecture diagram of the GitHub repository andargachewtadesse/cinema-ebooking-system, 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/andargachewtadesse/cinema-ebooking-system
- Repository: https://github.com/andargachewtadesse/cinema-ebooking-system

## Overview

##### Main Components
- Frontend Application:
- Located in the root project under directories such as “src/app” and “src/components”. This folder contains pages for both user interactions (movie browsing, booking, profile management, login/signup) and an admin panel (admin movies, users, promotions).
- It also includes API route handlers under “src/app/api” that likely communicate with or proxy to the backend.

- Backend Server:
- Found in the “cinema-backend” directory, which is a standard Spring Boot project. It includes Java packages for controllers, DAOs, and configurations.
- Key Java classes (e.g., MovieController, UserController, PromotionController) indicate that the backend applies an MVC-like pattern.
- The backend accesses the MySQL database and handles business logic (with classes such as DatabaseConnection, EmailService, and data initializers).

- Database:
- A MySQL database, setup instructions in the README specify tables for movies, users, cards, show_times, etc.
- SQL scripts and table creation commands are provided in “cinema-backend/SQL Tables.txt” and the README.

##### Relationships and Interactions
- User interactions start at the Frontend:
- Users interact with the Next.js client (on port 3000) which provides interfaces for browsing movies, managing bookings, and admin tasks.
- The frontend pages (including admin and public pages) either invoke frontend internal API routes (in src/app/api) or directly make HTTP requests to the backend REST API.

- Frontend to Backend Communications:
- The frontend communicates to the Spring Boot backend running on port 8080.

- Backend to Database Communication:
- The backend uses DAOs and a DatabaseConnection class to interact with MySQL. Represent the database as a separate component receiving queries from the backend.

##### Important Architectural Patterns and Design Principles
- MVC/Layered Architecture:
- In the backend, controllers receive requests and use DAOs to update or query the database.
- In the frontend, Next.js pages and components separate presentation, state management, and API calls.
- Separation of Concerns:
- Distinct project directories clearly separate UI (frontend), server-side logic (backend), and data persistence (MySQL).
- Micro Frontend Pattern (if applicable):
- The admin panel has dedicated page routes under “src/app/admin”, which is logically separated from the public-facing parts of the application.

##### Relevant Technologies
- Frontend: Next.js, TypeScript, Tailwind CSS.
- Backend: Spring Boot, Java, and MySQL Connector (provided in the “cinema-backend/lib” directory).
- Database: MySQL.
- Build tools: Maven for the backend and npm for the frontend.

##### Details
- For frontend:
- That it includes both public user pages and an admin panel to manage promotions, movies, and users.

- For backend:
- Some of the key controllers and DAOs (e.g., MovieController, UserController, CardDAO).
- That configuration files (“application.properties”, “pom.xml”, etc.) play a crucial role in setting up the environment.

- For Database:
- Sample table names from the provided SQL scripts (such as movies, show_times, user, card) to clearly connect the data layer to the backend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("User Browser"):::external

    subgraph "Next.js Frontend (Port 3000)"
        F1("User & Admin Interfaces"):::frontend
        F2("UI Components"):::frontend
        F3("API Routes"):::frontend
    end

    A -->|"interacts"| F1
    F1 -->|"uses"| F2
    F2 -->|"triggers"| F3

    subgraph "Spring Boot Backend (Port 8080)"
        BE0("Backend Root"):::backend
        BE1("Controllers (MovieController,UserController,PromotionController) & DAOs"):::backend
        BE2("Database Connection & Business Logic"):::backend
        subgraph "Configuration"
            BE3("application.properties"):::backend
            BE4("pom.xml"):::backend
        end
    end

    F3 -->|"HTTPCalls"| BE0
    BE0 -->|"initializes"| BE1
    BE0 -->|"loads"| BE2
    BE1 -->|"reliesOn"| BE2

    subgraph "MySQL Database"
        DB("Movies, Users, Cards, Show_Times Tables"):::database
    end

    BE2 -->|"queries/updates"| DB

    %% Click Events for Frontend Components
    click F1 "https://github.com/andargachewtadesse/cinema-ebooking-system/tree/main/src/app"
    click F2 "https://github.com/andargachewtadesse/cinema-ebooking-system/tree/main/src/components"
    click F3 "https://github.com/andargachewtadesse/cinema-ebooking-system/tree/main/src/app/api"

    %% Click Events for Backend Components
    click BE0 "https://github.com/andargachewtadesse/cinema-ebooking-system/tree/main/cinema-backend"
    click BE1 "https://github.com/andargachewtadesse/cinema-ebooking-system/tree/main/cinema-backend/src/main/java/cinema"
    click BE3 "https://github.com/andargachewtadesse/cinema-ebooking-system/blob/main/cinema-backend/src/main/resources/application.properties"
    click BE4 "https://github.com/andargachewtadesse/cinema-ebooking-system/blob/main/cinema-backend/pom.xml"

    %% Click Event for Database SQL Script
    click DB "https://github.com/andargachewtadesse/cinema-ebooking-system/blob/main/cinema-backend/SQL Tables.txt"

    %% Styles
    classDef frontend fill:#d4f4dd,stroke:#28a745,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#ffc107,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
