# rishabh-raj-pathak/console-ticket-booking-system architecture

> Architecture diagram of the GitHub repository rishabh-raj-pathak/console-ticket-booking-system, 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/rishabh-raj-pathak/console-ticket-booking-system
- Repository: https://github.com/rishabh-raj-pathak/console-ticket-booking-system

## Overview

##### Main Components
- Application Entry Point and Initialization
- Main.java serves as the application entry point.
- AppContext.java and Initializer.java likely manage configuration and initialization of services.
- Domain Models
- All classes within the models package (e.g., Booking, Cinema, Movie, Customer, Show, etc.) represent the core domain entities.
- Models/enums holds domain-specific enumerations (AccountStatus, BookingStatus, etc.).
- Repositories (Data Access Layer)
- The repositories package contains interfaces such as BookingRepository, CinemaRepository, etc.
- The implementations under repositories/impl (e.g., InMemoryBookingRepository) provide concrete data handling (here, an in-memory approach).
- Services (Business Logic Layer)
- Service interfaces (BookingService, CinemaService, etc.) outline business logic operations.
- Their implementations (BookingServiceImpl, CinemaServiceImpl, etc.) contain the core logic that manipulates the models and interacts with the repositories.
- User Interface and Utilities
- The ConsoleUI class in the utils package stands for the console-based presentation layer.
- MenuHandler and SampleDataCreator in the main package assist with user interaction and data seeding.

##### Mapping Relationships and Interactions
- Application Flow:
- The Main.java starts the application, which calls Initializer and AppContext to set up the environment.
- The ConsoleUI (and possibly MenuHandler) manages user inputs, sending commands to the appropriate service.
- Business Logic Invocation:
- Services (like BookingService, CinemaService, etc.) process user requests and enforce the business rules (e.g., booking tickets, managing seat selection, payment processing).
- Data Persistence Interaction:
- Services call upon the corresponding repository implementations to retrieve/modify domain model data.
- Domain Model Usage:
- Domain models are used across all layers to represent the core entities and to transfer data among components.

##### Architectural Patterns and Design Principles
- Layered Architecture:
- The system is clearly divided into layers: presentation (console UI), business logic (services), data (repositories) and domain (models).
- Dependency Injection / Inversion of Control (potentially using AppContext/Initializer)
- These classes may be responsible for wiring together services and repositories.
- Separation of Concerns:
- Each package (models, repositories, services, utils) has a dedicated responsibility.
- In-Memory Repositories:
- For the data layer, the implementation uses in-memory storage by default, which is a common pattern in learning projects or initial prototypes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    subgraph "Application Layer"
        A1["Main.java"]:::application
        A2["AppContext.java"]:::application
        A3["Initializer.java"]:::application
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        P1["ConsoleUI"]:::presentation
        P2["MenuHandler"]:::presentation
        P3["SampleDataCreator"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BL1["BookingService"]:::business
        BL2["BookingServiceImpl"]:::business
        BL3["CinemaService"]:::business
        BL4["CinemaServiceImpl"]:::business
        BL5["MovieService"]:::business
        BL6["MovieServiceImpl"]:::business
        BL7["ShowService"]:::business
        BL8["ShowServiceImpl"]:::business
        BL9["UserService"]:::business
        BL10["UserServiceImpl"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DA1["BookingRepository"]:::data
        DA2["InMemoryBookingRepository"]:::data
        DA3["CinemaRepository"]:::data
        DA4["InMemoryCinemaRepository"]:::data
        DA5["MovieRepository"]:::data
        DA6["InMemoryMovieRepository"]:::data
        DA7["ShowRepository"]:::data
        DA8["InMemoryShowRepository"]:::data
        DA9["UserRepository"]:::data
        DA10["InMemoryUserRepository"]:::data
    end

    %% Domain Models
    subgraph "Domain Models"
        D1["Domain Entities"]:::domain
        D2["Domain Enumerations"]:::domain
    end

    %% Connections within Application Layer
    A1 -->|"initializes"| A2
    A1 -->|"launches"| A3
    A3 -->|"setup UI"| P1
    A3 -->|"wires services"| BL2
    A3 --> BL4
    A3 --> BL6
    A3 --> BL8
    A3 --> BL10

    %% Presentation to Business Logic Interaction
    P1 -->|"handles input"| P2
    P2 -->|"bookTicket"| BL2
    P2 -->|"manageCinema"| BL4
    P2 -->|"selectMovie"| BL6
    P2 -->|"chooseShow"| BL8
    P2 -->|"userAction"| BL10

    %% Business Logic to Data Access Interaction
    BL2 -->|"CRUD_booking"| DA2
    BL4 -->|"CRUD_cinema"| DA4
    BL6 -->|"CRUD_movie"| DA6
    BL8 -->|"CRUD_show"| DA8
    BL10 -->|"CRUD_user"| DA10

    %% Business Logic using Domain Models
    BL2 -.->|"uses"| D1
    BL4 -.->|"uses"| D1
    BL6 -.->|"uses"| D1
    BL8 -.->|"uses"| D1
    BL10 -.->|"uses"| D1

    %% Data Access storing Domain Models
    DA2 -.->|"stores"| D1
    DA4 -.->|"stores"| D1
    DA6 -.->|"stores"| D1
    DA8 -.->|"stores"| D1
    DA10 -.->|"stores"| D1

    %% Click Events for Application Layer
    click A1 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/Main.java"
    click A2 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/AppContext.java"
    click A3 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/Initializer.java"

    %% Click Events for Presentation Layer
    click P1 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/utils/ConsoleUI.java"
    click P2 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/MenuHandler.java"
    click P3 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/blob/master/src/main/java/com/ticketbooking/SampleDataCreator.java"

    %% Click Events for Business Logic Layer
    click BL1 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services"
    click BL2 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services/impl"
    click BL3 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services"
    click BL4 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services/impl"
    click BL5 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services"
    click BL6 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services/impl"
    click BL7 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services"
    click BL8 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services/impl"
    click BL9 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services"
    click BL10 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/services/impl"

    %% Click Events for Data Access Layer
    click DA1 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories"
    click DA2 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories/impl"
    click DA3 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories"
    click DA4 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories/impl"
    click DA5 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories"
    click DA6 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories/impl"
    click DA7 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories"
    click DA8 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories/impl"
    click DA9 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories"
    click DA10 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/repositories/impl"

    %% Click Events for Domain Models
    click D1 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/models"
    click D2 "https://github.com/rishabh-raj-pathak/console-ticket-booking-system/tree/master/src/main/java/com/ticketbooking/models/enums"

    %% Styles
    classDef application fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef presentation fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef business fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef data fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef domain fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
