# shivam8761/cineverse-moviebookingapplication-backend architecture

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

- Interactive diagram: https://gitdiagram.com/shivam8761/cineverse-moviebookingapplication-backend
- Repository: https://github.com/shivam8761/cineverse-moviebookingapplication-backend

## Overview

#### Purpose and Runtime
CineVerse is a Spring Boot REST backend for movie-ticket booking. It provides JWT-secured, role-based APIs for users and administrators to manage catalog data, schedule shows, and create/maintain bookings. The application starts from `src/main/java/com/sv/CineVerseApplication.java`; Maven builds and runs it through `pom.xml`.

#### HTTP API Layer
Controllers expose resource-oriented endpoints and separate public/user/admin operations:
- Authentication: `src/main/java/com/sv/controller/AuthController.java`
- Movie, theater, and show APIs: `src/main/java/com/sv/controller/MovieController.java`, `src/main/java/com/sv/controller/TheaterController.java`, `src/main/java/com/sv/controller/ShowController.java`
- Booking and administrative operations: `src/main/java/com/sv/controller/BookingController.java`, `src/main/java/com/sv/controller/AdminController.java`

Requests enter controllers, are mapped through DTOs, and delegate business rules to services rather than directly to persistence.

#### Authentication and Authorization Boundary
Spring Security is configured as a stateless JWT boundary in `src/main/java/com/sv/security/SecurityConfig.java`. `src/main/java/com/sv/jwt/JwtAuthenticationFilter.java` intercepts requests, validates bearer tokens via `src/main/java/com/sv/jwt/JwtService.java`, and establishes authenticated context. `src/main/java/com/sv/service/AuthenticationService.java` handles registration/login flows, while `src/main/java/com/sv/service/CustomUserDetailsService.java` loads persisted users. Roles distinguish USER and ADMIN access, protecting management endpoints.

#### Domain Model and Persistence
JPA/Hibernate persists the booking domain in MySQL. Core aggregates are:
- Users and bookings: `src/main/java/com/sv/entity/User.java`, `src/main/java/com/sv/entity/Booking.java`
- Movie/show/theater scheduling: `src/main/java/com/sv/entity/Movie.java`, `src/main/java/com/sv/entity/Show.java`, `src/main/java/com/sv/entity/Theater.java`
- Booking lifecycle state: `src/main/java/com/sv/entity/BookingStatus.java`

Relationships model one user to many bookings, movie/theater to many shows, and show to many bookings. Spring Data repository interfaces isolate database access, including `src/main/java/com/sv/repository/BookingRepository.java` and `src/main/java/com/sv/repository/ShowRepository.java`.

#### Catalog and Scheduling Flow
Movie and theater services own CRUD/search behavior, backed by their repositories: `src/main/java/com/sv/service/MovieService.java` and `src/main/java/com/sv/service/TheaterService.java`. `src/main/java/com/sv/service/ShowService.java` links a movie and theater into a scheduled show, enabling retrieval by movie or theater. Administrative authorization is the control boundary for mutating these resources; browsing feeds booking selection.

#### Booking Lifecycle
`src/main/java/com/sv/service/BookingService.java` is the principal transactional business component. It accepts booking input, resolves the user/show context, validates requested seats against existing show bookings and theater capacity, calculates total ticket cost, and persists a status-bearing booking. It also governs confirmation, cancellation, cancellation-time restrictions, and user/show/status booking queries. `src/main/java/com/sv/DTO/BookingDTO.java` is the API-facing booking shape, insulating controllers from JPA entities.

#### Data Contracts and External Infrastructure
DTOs define request/response boundaries for auth and primary resources, notably `src/main/java/com/sv/DTO/LoginRequestDTO.java`, `src/main/java/com/sv/DTO/LoginResponseDTO.java`, and `src/main/java/com/sv/DTO/ShowDTO.java`. Material infrastructure is Java/Spring Boot, Spring Security, JWT, Spring Data JPA/Hibernate, and MySQL; no payment, notification, cache, message broker, or frontend integration is present. API documentation configuration exists at `src/main/java/com/sv/security/SwaggerConfig.java`.

Main entry points: [`src/main/java/com/sv/service/BookingService.java`](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/BookingService.java) (Booking service), [`src/main/java/com/sv/repository/BookingRepository.java`](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/repository/BookingRepository.java) (Spring Data repositories), [`src/main/java/com/sv/jwt/JwtAuthenticationFilter.java`](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/jwt/JwtAuthenticationFilter.java) (JWT filter), [`src/main/java/com/sv/CineVerseApplication.java`](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/CineVerseApplication.java) (Spring Boot app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_controllers["Resource controllers<br/>REST controllers"]
  node_auth_controller["Auth controller<br/>REST controller"]
  node_booking_dto["Booking DTO<br/>API contract<br/>[BookingDTO.java]"]
  node_auth_dtos["Login DTOs<br/>API contracts"]
end

subgraph group_security["Security"]
  node_security_config{{"Security config<br/>security boundary"}}
  node_jwt_filter["JWT filter<br/>authentication filter"]
  node_jwt_service["JWT service<br/>token service<br/>[JwtService.java]"]
  node_authentication_service["Authentication service<br/>application service"]
  node_user_details["User details service<br/>identity service"]
end

subgraph group_domain["Booking Domain"]
  node_catalog_services["Catalog services<br/>application services<br/>[MovieService.java]"]
  node_show_service["Show service<br/>scheduling service<br/>[ShowService.java]"]
  node_booking_service["Booking service<br/>transactional service"]
  node_booking["Booking<br/>JPA entity<br/>[Booking.java]"]
  node_show["Show<br/>JPA entity<br/>[Show.java]"]
  node_user["User<br/>JPA entity<br/>[User.java]"]
end

subgraph group_data["Persistence"]
  node_repositories["Spring Data repositories<br/>repository layer"]
  node_mysql[("MySQL<br/>database")]
end

node_app{{"Spring Boot app<br/>runtime"}}
node_build["Maven build<br/>[pom.xml]"]

node_build -->|"builds and runs"| node_app
node_app -->|"configures"| node_security_config
node_app -->|"serves"| node_controllers
node_security_config -->|"installs"| node_jwt_filter
node_jwt_filter -->|"validates tokens"| node_jwt_service
node_jwt_filter -->|"loads identity"| node_user_details
node_auth_controller -->|"login and registration"| node_authentication_service
node_auth_controller -->|"uses"| node_auth_dtos
node_controllers -->|"maps requests"| node_booking_dto
node_controllers -->|"catalog operations"| node_catalog_services
node_controllers -->|"scheduling operations"| node_show_service
node_controllers -->|"booking operations"| node_booking_service
node_booking_service -->|"creates and updates"| node_booking
node_booking_service -->|"checks availability"| node_show
node_booking_service -->|"resolves customer"| node_user
node_catalog_services -->|"persists catalog"| node_repositories
node_show_service -->|"persists shows"| node_repositories
node_booking_service -->|"persists bookings"| node_repositories
node_user_details -->|"loads users"| node_repositories
node_repositories -->|"JPA/Hibernate"| node_mysql
node_show -->|"has bookings"| node_booking
node_user -->|"has bookings"| node_booking

click node_app "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/CineVerseApplication.java"
click node_build "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/pom.xml"
click node_auth_controller "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/controller/AuthController.java"
click node_booking_dto "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/DTO/BookingDTO.java"
click node_auth_dtos "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/DTO/LoginRequestDTO.java"
click node_security_config "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/security/SecurityConfig.java"
click node_jwt_filter "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/jwt/JwtAuthenticationFilter.java"
click node_jwt_service "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/jwt/JwtService.java"
click node_authentication_service "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/AuthenticationService.java"
click node_user_details "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/CustomUserDetailsService.java"
click node_catalog_services "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/MovieService.java"
click node_show_service "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/ShowService.java"
click node_booking_service "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/BookingService.java"
click node_booking "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/Booking.java"
click node_show "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/Show.java"
click node_user "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/User.java"
click node_repositories "https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/repository/BookingRepository.java"

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_controllers,node_auth_controller,node_booking_dto,node_auth_dtos toneBlue
class node_security_config,node_jwt_filter,node_jwt_service,node_authentication_service,node_user_details toneAmber
class node_catalog_services,node_show_service,node_booking_service,node_booking,node_show,node_user toneMint
class node_repositories,node_mysql toneRose
class node_app,node_build toneNeutral
```

## Components

### HTTP API

- **Resource controllers**: REST controllers · Movie, theater, show, booking, and admin endpoints.
- [Auth controller](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/controller/AuthController.java): REST controller · `src/main/java/com/sv/controller/AuthController.java`
- [Booking DTO](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/DTO/BookingDTO.java): API contract · Insulates booking APIs from JPA entities. · `src/main/java/com/sv/DTO/BookingDTO.java`
- [Login DTOs](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/DTO/LoginRequestDTO.java): API contracts · `src/main/java/com/sv/DTO/LoginRequestDTO.java`

### Security

- [Security config](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/security/SecurityConfig.java): security boundary · Stateless JWT and role authorization rules. · `src/main/java/com/sv/security/SecurityConfig.java`
- [JWT filter](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/jwt/JwtAuthenticationFilter.java): authentication filter · `src/main/java/com/sv/jwt/JwtAuthenticationFilter.java`
- [JWT service](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/jwt/JwtService.java): token service · `src/main/java/com/sv/jwt/JwtService.java`
- [Authentication service](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/AuthenticationService.java): application service · Registration and login flows. · `src/main/java/com/sv/service/AuthenticationService.java`
- [User details service](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/CustomUserDetailsService.java): identity service · Loads persisted users for authentication. · `src/main/java/com/sv/service/CustomUserDetailsService.java`

### Booking Domain

- [Catalog services](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/MovieService.java): application services · Movie and theater CRUD and search. · `src/main/java/com/sv/service/MovieService.java`
- [Show service](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/ShowService.java): scheduling service · Links movies and theaters into scheduled shows. · `src/main/java/com/sv/service/ShowService.java`
- [Booking service](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/service/BookingService.java): transactional service · Validates seats and capacity, prices, and manages lifecycle. · `src/main/java/com/sv/service/BookingService.java`
- [Booking](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/Booking.java): JPA entity · Status-bearing reservation tied to a user and show. · `src/main/java/com/sv/entity/Booking.java`
- [Show](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/Show.java): JPA entity · Scheduled movie at a theater. · `src/main/java/com/sv/entity/Show.java`
- [User](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/entity/User.java): JPA entity · `src/main/java/com/sv/entity/User.java`

### Persistence

- [Spring Data repositories](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/repository/BookingRepository.java): repository layer · Database access for bookings, shows, and catalog data. · `src/main/java/com/sv/repository/BookingRepository.java`
- **MySQL**: database · JPA/Hibernate persistence store.

### Other components

- [Spring Boot app](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/src/main/java/com/sv/CineVerseApplication.java): runtime · Application entry point. · `src/main/java/com/sv/CineVerseApplication.java`
- [Maven build](https://github.com/shivam8761/cineverse-moviebookingapplication-backend/blob/main/pom.xml): build · `pom.xml`

## Connections

- Maven build → Spring Boot app: builds and runs
- Spring Boot app → Security config: configures
- Spring Boot app → Resource controllers: serves
- Security config → JWT filter: installs
- JWT filter → JWT service: validates tokens
- JWT filter → User details service: loads identity
- Auth controller → Authentication service: login and registration
- Auth controller → Login DTOs: uses
- Resource controllers → Booking DTO: maps requests
- Resource controllers → Catalog services: catalog operations
- Resource controllers → Show service: scheduling operations
- Resource controllers → Booking service: booking operations
- Booking service → Booking: creates and updates
- Booking service → Show: checks availability
- Booking service → User: resolves customer
- Catalog services → Spring Data repositories: persists catalog
- Show service → Spring Data repositories: persists shows
- Booking service → Spring Data repositories: persists bookings
- User details service → Spring Data repositories: loads users
- Spring Data repositories → MySQL: JPA/Hibernate
- Show → Booking: has bookings
- User → Booking: has bookings
