# mroy8202/cine-ticket architecture

> Architecture diagram of the GitHub repository mroy8202/cine-ticket, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mroy8202/cine-ticket
- Repository: https://github.com/mroy8202/cine-ticket

## Overview

#### Purpose and Runtime
CineTicket is a Java 21/Spring Boot REST backend for multi-role movie discovery, theatre/show administration, and seat reservations. The application starts at `src/main/java/com/mritunjay/cineticket/CineTicketApplication.java`; Docker deployment is defined in `Dockerfile`. It uses Maven, Spring Data JPA/Hibernate, and PostgreSQL; the documented production target is Railway with managed PostgreSQL.

#### HTTP/API Boundary
REST controllers expose authentication plus movie, theatre, show, reservation, and user operations. Controllers accept/return DTOs rather than persistence entities, with shared response wrappers and centralized HTTP error translation.
- `src/main/java/com/mritunjay/cineticket/controller/auth/AuthenticationController.java`
- `src/main/java/com/mritunjay/cineticket/controller/ReservationController.java`
- `src/main/java/com/mritunjay/cineticket/controller/controllerAdvice/GlobalExceptionHandler.java`

Primary request flow is: HTTP request → JWT/security filters → controller authorization → service logic → JPA repositories/PostgreSQL → DTO response or mapped error.

#### Identity, Authorization, and Bootstrap
Authentication issues JWTs; the JWT filter authenticates requests and rejects blacklisted logout tokens. Spring Security governs stateless access, while resource-level role checks support Super Admin, Theatre Admin, and User responsibilities. Passwords use a configured encoder. A startup seeder creates the initial Super Admin.
- `src/main/java/com/mritunjay/cineticket/config/SecurityConfig.java`
- `src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java`
- `src/main/java/com/mritunjay/cineticket/service/auth/AuthenticationService.java`
- `src/main/java/com/mritunjay/cineticket/service/auth/TokenBlacklist.java`
- `src/main/java/com/mritunjay/cineticket/seeder/SuperAdminSeeder.java`

The blacklist is in-process, so logout invalidation is not inherently shared across replicas.

#### Domain and Persistence Model
The JPA model separates durable venue layout from per-performance inventory: `Theatre` contains `Screen`, and `Screen` contains physical `Seat`; `Show` has per-show `ShowSeat` availability. `Reservation` joins a user, show, and selected show seats. `TheatreVsAdmin` represents theatre administration assignments.
- `src/main/java/com/mritunjay/cineticket/model/Theatre.java`
- `src/main/java/com/mritunjay/cineticket/model/Seat.java`
- `src/main/java/com/mritunjay/cineticket/model/ShowSeat.java`
- `src/main/java/com/mritunjay/cineticket/model/Reservation.java`

Repositories form the persistence boundary over PostgreSQL.
- `src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java`
- `src/main/java/com/mritunjay/cineticket/repository/ReservationRepository.java`

#### Catalogue and Venue Administration
Movie, theatre, screen/seat, and show services own lifecycle operations and queries. Show creation is the transition from a scheduled movie/screen pairing to reservable per-show seats; detailed show reads expose availability. DTO/mapper layers isolate API shapes from entities.
- `src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java`
- `src/main/java/com/mritunjay/cineticket/service/impl/ShowServiceImpl.java`
- `src/main/java/com/mritunjay/cineticket/service/impl/ShowSeatServiceImpl.java`
- `src/main/java/com/mritunjay/cineticket/mapper/show/ShowMapper.java`

#### Reservation Consistency Path
Reservation creation coordinates seat selection, availability validation, `ShowSeat` state updates, and reservation persistence. `SeatLock` holds JVM-local per-seat `ReentrantLock`s; callers sort seat IDs and use non-blocking lock acquisition to avoid deadlocks and reject competing bookings. Cancellation follows reservation-status/ownership rules.
- `src/main/java/com/mritunjay/cineticket/service/impl/ReservationServiceImpl.java`
- `src/main/java/com/mritunjay/cineticket/lock/SeatLock.java`
- `src/main/java/com/mritunjay/cineticket/exception/SeatAlreadyLockedException.java`

This locking design protects a single application instance; horizontally scaled deployments need database pessimistic locking or a shared distributed lock service.

#### Operational Boundaries
Database and JWT configuration are externally supplied through application properties/environment variables. The repository includes local/example and production property templates, while the container is the deployable unit.
- `src/main/resources/application-example.properties`
- `src/main/resources/application-prod.properties`
- `Dockerfile`

Main entry points: [`src/main/java/com/mritunjay/cineticket/controller/ReservationController.java`](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/controller/ReservationController.java) (REST controllers), [`src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java`](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java) (JPA repositories), [`src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java`](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java) (JWT filter), [`src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java`](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java) (Catalogue & venue services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_client(("API clients<br/>HTTP callers"))
  node_controllers["REST controllers<br/>Spring MVC"]
  node_errors["Global error handler<br/>controller advice"]
end

subgraph group_security["Identity &amp; Access"]
  node_security_config["Security configuration<br/>Spring Security"]
  node_jwt_filter["JWT filter<br/>security filter<br/>[JWTFilter.java]"]
  node_auth_service["Authentication service<br/>auth service"]
  node_token_blacklist[("Token blacklist<br/>in-process state")]
  node_super_admin_seeder["Super Admin seeder<br/>startup seeder"]
end

subgraph group_domain["Domain Services"]
  node_catalogue_services["Catalogue &amp; venue services<br/>service layer"]
  node_show_service["Show service<br/>service layer"]
  node_show_seat_service["Show-seat service<br/>service layer"]
  node_reservation_service["Reservation service<br/>service layer"]
  node_seat_lock["Seat lock<br/>JVM lock manager<br/>[SeatLock.java]"]
  node_dto_mapper["Show mapper<br/>DTO mapper<br/>[ShowMapper.java]"]
end

subgraph group_persistence["Persistence"]
  node_domain_model["Cinema domain model<br/>JPA entities<br/>[ShowSeat.java]"]
  node_repositories["JPA repositories<br/>persistence boundary"]
  node_postgres[("PostgreSQL<br/>managed database")]
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_application{{"Spring Boot application<br/>Java 21 runtime"}}
  node_container["Docker image<br/>deployable unit"]
end

node_client -->|"HTTP request"| node_jwt_filter
node_security_config -->|"configures"| node_jwt_filter
node_jwt_filter -->|"checks logout token"| node_token_blacklist
node_jwt_filter -->|"authenticated request"| node_controllers
node_controllers -->|"authentication"| node_auth_service
node_controllers -->|"catalogue/admin operations"| node_catalogue_services
node_controllers -->|"availability reads"| node_show_seat_service
node_controllers -->|"booking and cancellation"| node_reservation_service
node_controllers -->|"exceptions"| node_errors
node_auth_service -->|"logout invalidation"| node_token_blacklist
node_catalogue_services -->|"schedule show"| node_show_service
node_show_service -->|"creates ShowSeat inventory"| node_domain_model
node_show_seat_service -->|"queries availability"| node_repositories
node_reservation_service -->|"acquires selected seats"| node_seat_lock
node_reservation_service -->|"updates seats and reservation"| node_repositories
node_catalogue_services -->|"persists lifecycle changes"| node_repositories
node_repositories -->|"maps entities"| node_domain_model
node_repositories -->|"JPA/Hibernate"| node_postgres
node_domain_model -->|"mapped for API"| node_dto_mapper
node_dto_mapper -->|"DTO responses"| node_controllers
node_application -->|"runs at startup"| node_super_admin_seeder
node_super_admin_seeder -->|"creates admin"| node_repositories
node_container -->|"runs"| node_application

click node_controllers "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/controller/ReservationController.java"
click node_errors "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/controller/controllerAdvice/GlobalExceptionHandler.java"
click node_security_config "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/config/SecurityConfig.java"
click node_jwt_filter "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java"
click node_auth_service "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/auth/AuthenticationService.java"
click node_token_blacklist "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/auth/TokenBlacklist.java"
click node_super_admin_seeder "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/seeder/SuperAdminSeeder.java"
click node_catalogue_services "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java"
click node_show_service "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ShowServiceImpl.java"
click node_show_seat_service "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ShowSeatServiceImpl.java"
click node_reservation_service "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ReservationServiceImpl.java"
click node_seat_lock "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/lock/SeatLock.java"
click node_dto_mapper "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/mapper/show/ShowMapper.java"
click node_domain_model "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/model/ShowSeat.java"
click node_repositories "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java"
click node_application "https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/CineTicketApplication.java"
click node_container "https://github.com/mroy8202/cine-ticket/blob/main/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_controllers,node_errors toneBlue
class node_security_config,node_jwt_filter,node_auth_service,node_token_blacklist,node_super_admin_seeder toneAmber
class node_catalogue_services,node_show_service,node_show_seat_service,node_reservation_service,node_seat_lock,node_dto_mapper toneMint
class node_domain_model,node_repositories,node_postgres toneRose
class node_application,node_container toneIndigo
```

## Components

### HTTP API

- **API clients**: HTTP callers
- [REST controllers](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/controller/ReservationController.java): Spring MVC · Movie, theatre, show, reservation, and user endpoints. · `src/main/java/com/mritunjay/cineticket/controller/ReservationController.java`
- [Global error handler](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/controller/controllerAdvice/GlobalExceptionHandler.java): controller advice · Maps application exceptions to HTTP responses. · `src/main/java/com/mritunjay/cineticket/controller/controllerAdvice/GlobalExceptionHandler.java`

### Identity & Access

- [Security configuration](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/config/SecurityConfig.java): Spring Security · Configures stateless access, roles, and password encoding. · `src/main/java/com/mritunjay/cineticket/config/SecurityConfig.java`
- [JWT filter](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java): security filter · Authenticates requests and rejects blacklisted tokens. · `src/main/java/com/mritunjay/cineticket/filter/JWTFilter.java`
- [Authentication service](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/auth/AuthenticationService.java): auth service · Issues JWTs and handles authentication flows. · `src/main/java/com/mritunjay/cineticket/service/auth/AuthenticationService.java`
- [Token blacklist](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/auth/TokenBlacklist.java): in-process state · Logout invalidation is local to one application instance. · `src/main/java/com/mritunjay/cineticket/service/auth/TokenBlacklist.java`
- [Super Admin seeder](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/seeder/SuperAdminSeeder.java): startup seeder · Creates the initial Super Admin. · `src/main/java/com/mritunjay/cineticket/seeder/SuperAdminSeeder.java`

### Domain Services

- [Catalogue & venue services](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java): service layer · Manages movies, theatres, screens, seats, and shows. · `src/main/java/com/mritunjay/cineticket/service/impl/TheatreServiceImpl.java`
- [Show service](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ShowServiceImpl.java): service layer · Creates reservable show inventory from screen seats. · `src/main/java/com/mritunjay/cineticket/service/impl/ShowServiceImpl.java`
- [Show-seat service](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ShowSeatServiceImpl.java): service layer · Exposes per-show seat availability. · `src/main/java/com/mritunjay/cineticket/service/impl/ShowSeatServiceImpl.java`
- [Reservation service](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/service/impl/ReservationServiceImpl.java): service layer · Validates, books, and cancels reservations. · `src/main/java/com/mritunjay/cineticket/service/impl/ReservationServiceImpl.java`
- [Seat lock](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/lock/SeatLock.java): JVM lock manager · Sorted, non-blocking per-seat locks prevent local booking races. · `src/main/java/com/mritunjay/cineticket/lock/SeatLock.java`
- [Show mapper](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/mapper/show/ShowMapper.java): DTO mapper · Separates API representations from JPA entities. · `src/main/java/com/mritunjay/cineticket/mapper/show/ShowMapper.java`

### Persistence

- [Cinema domain model](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/model/ShowSeat.java): JPA entities · Theatre/screens/seats are durable layout; shows own ShowSeat inventory and reservations. · `src/main/java/com/mritunjay/cineticket/model/ShowSeat.java`
- [JPA repositories](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java): persistence boundary · Persists show-seat and reservation state. · `src/main/java/com/mritunjay/cineticket/repository/ShowSeatRepository.java`
- **PostgreSQL**: managed database

### Runtime & Deployment

- [Spring Boot application](https://github.com/mroy8202/cine-ticket/blob/main/src/main/java/com/mritunjay/cineticket/CineTicketApplication.java): Java 21 runtime · Application entry point. · `src/main/java/com/mritunjay/cineticket/CineTicketApplication.java`
- [Docker image](https://github.com/mroy8202/cine-ticket/blob/main/Dockerfile): deployable unit · Configured by environment-supplied database and JWT properties. · `Dockerfile`

## Connections

- API clients → JWT filter: HTTP request
- Security configuration → JWT filter: configures
- JWT filter → Token blacklist: checks logout token
- JWT filter → REST controllers: authenticated request
- REST controllers → Authentication service: authentication
- REST controllers → Catalogue & venue services: catalogue/admin operations
- REST controllers → Show-seat service: availability reads
- REST controllers → Reservation service: booking and cancellation
- REST controllers → Global error handler: exceptions
- Authentication service → Token blacklist: logout invalidation
- Catalogue & venue services → Show service: schedule show
- Show service → Cinema domain model: creates ShowSeat inventory
- Show-seat service → JPA repositories: queries availability
- Reservation service → Seat lock: acquires selected seats
- Reservation service → JPA repositories: updates seats and reservation
- Catalogue & venue services → JPA repositories: persists lifecycle changes
- JPA repositories → Cinema domain model: maps entities
- JPA repositories → PostgreSQL: JPA/Hibernate
- Cinema domain model → Show mapper: mapped for API
- Show mapper → REST controllers: DTO responses
- Spring Boot application → Super Admin seeder: runs at startup
- Super Admin seeder → JPA repositories: creates admin
- Docker image → Spring Boot application: runs
