# nguyendatgh/ticketmaster-moviemanagerment architecture

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

- Interactive diagram: https://gitdiagram.com/nguyendatgh/ticketmaster-moviemanagerment
- Repository: https://github.com/nguyendatgh/ticketmaster-moviemanagerment

## Overview

Based on your provided file tree and README, this project is a Java-based web application (likely using the Model-View-Controller pattern) that centers around cinema/movie management and booking. The project combines a traditional front-end based on JSPs (with separate folders for admin and public user views) and a back-end built on Servlets, DAOs, and model classes, all tied together with database persistence using JPA (and a Microsoft SQL Server connection as indicated in context.xml).

##### Main Components to Highlight
- Frontend / Presentation Layer:
- The web pages (JSPs) located under src/main/webapp (subdirectories such as admin, auth, view, include, asset).
- They serve as the user interface for both public users and administrative users.
- Controller Layer:
- The Servlets under src/main/java/Controller, such as HomeServlet, LoginServlet, BookingServlet, MovieManagementServlet, etc.
- They receive and process requests from the JSP pages, deciding the control flow.
- Business & Domain Model Layer:
- The modal package (with classes like Movie, Booking, User, Seat, etc.) represents the core business entities.
- Data Access Layer:
- The DAO package contains classes (e.g., CinemaDAO, MovieDAO, TransactionDao, etc.) which encapsulate database interactions.
- ConnectionPool, DBUtils, and other helper utilities reside here to manage connectivity.
- Configuration and Utility Components:
- The utils package (with ConfigLoader).
- Resource configuration files under src/main/resources and the persistence.xml for JPA settings.
- The README’s guidelines about config.properties and context.xml show how external configuration and environment-specific settings are applied.
- Database:
- Represented by prj.sql (hinting at initial database schema) and the configuration in context.xml that connects to a SQL Server.
- External Services:
- Integration with SendGrid (as noted in the README) for sending emails, which should be noted as an external API dependency.

##### Relationships and Data Flow
- A typical flow: a client (browser) interacts with a JSP page → the request is forwarded to a corresponding Servlet in the Controller layer → the servlet manipulates domain objects (from the modal package) and calls the DAO layer for data operations → DAOs interact with the database → results are passed back up the layers and rendered by JSP pages.

##### Architectural Patterns and Design Principles
- MVC Pattern: The project clearly separates concerns via Controllers (servlets), Views (JSP pages), and Models (domain objects).
- Layered Architecture: Emphasize different layers (presentation, business, persistence) and their interactions.
- Configuration Dependency Injection: Via the beans.xml, context.xml and persistence.xml, hinting at usage of dependency management and potentially some container-based injection.
- Use of DAO Pattern: To abstract and encapsulate all access to the data source.

##### Technologies and Frameworks
- Java Servlets and JSP for the web layer.
- Maven for build and dependency management (pom.xml).
- JPA (configured in persistence.xml) and JDBC (via context.xml) for database access.
- Microsoft SQL Server as the underlying database.
- SendGrid API integration (as indicated in the README for email-related functionality).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Client/Browser"]:::client

    subgraph "Frontend / Presentation Layer"
        JSP["User Interface (JSP Views)"]:::frontend
    end

    subgraph "Controller Layer"
        Controller["Controller (Servlets)"]:::controller
    end

    subgraph "Business & Domain Model Layer"
        Model["Business Model (Domain Objects)"]:::model
    end

    subgraph "Data Access Layer"
        DAO["Data Access (DAO Classes)"]:::dao
    end

    subgraph "Configuration & Utility Components"
        ConfigLoader["ConfigLoader"]:::config
        Persistence["persistence.xml"]:::config
        Context["context.xml"]:::config
        Beans["beans.xml"]:::config
    end

    subgraph "Database"
        DB[(Database SQL Server)]:::db
    end

    subgraph "External Services"
        SendGrid["SendGrid API"]:::external
    end

    Browser -->|"HTTP_Request"| JSP
    JSP -->|"Forwards_Request"| Controller
    Controller -->|"Processes_Data"| Model
    Controller -->|"Calls_DAO"| DAO
    DAO -->|"Persists_Data"| DB
    Controller -->|"Sends_Email"| SendGrid
    Controller -->|"Loads_Configs"| ConfigLoader
    ConfigLoader -->|"Loads"| Persistence
    ConfigLoader -->|"Loads"| Context
    ConfigLoader -->|"Loads"| Beans

    click JSP "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/tree/master/src/main/webapp"
    click Controller "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/tree/master/src/main/java/Controller"
    click Model "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/tree/master/src/main/java/modal"
    click DAO "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/tree/master/src/main/java/DAO"
    click ConfigLoader "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/blob/master/src/main/java/utils/ConfigLoader.java"
    click Persistence "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/blob/master/src/main/resources/META-INF/persistence.xml"
    click Context "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/blob/master/src/main/webapp/META-INF/context.xml"
    click Beans "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/blob/master/src/main/webapp/WEB-INF/beans.xml"
    click DB "https://github.com/nguyendatgh/ticketmaster-moviemanagerment/blob/master/prj.sql"

    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef controller fill:#f99,stroke:#333,stroke-width:2px;
    classDef model fill:#9f9,stroke:#333,stroke-width:2px;
    classDef dao fill:#ff9,stroke:#333,stroke-width:2px;
    classDef config fill:#ccc,stroke:#333,stroke-width:2px;
    classDef db fill:#fa5,stroke:#333,stroke-width:2px;
    classDef external fill:#aff,stroke:#333,stroke-width:2px;
```
