How ibraheemd47/ticket_management_system_ works
1. Overall shape
- This is a single Spring Boot 3.3.5 monolith built with Maven and Java 21.
- The app combines backend business logic, persistence, security, and a Vaadin 24 UI in one deployable unit.
- The main runtime entrypoint is TicketManagementSystemApplication.
2. UI / presentation boundary
- The user-facing app is Vaadin-based, with views under src/main/java/.../Frontend and route/page classes under .../endpoints.
- There is also a generated frontend bundle in src/main/frontend/generated, which is Vaadin Flow plumbing rather than hand-written app logic.
- The UI layer talks to backend services directly through Spring-managed beans, not through a separate REST API boundary.
3. Core business domains
- The codebase is organized around several business subdomains: users/auth, events/tickets, orders/checkout, policies, companies, lottery, complaints, and notifications.
- These domains are represented by explicit domain objects in Domain_Layer, DTOs in DTOs, and application services in Application_Layer.
- The event/ticket/order path is the most central flow in the system.
4. Application layer as orchestration
- Application_Layer contains use-case services such as TicketService, EventService, PaymentService, OrderMapper, LotteryService, UserService, SystemAdminService, ComplaintService, and notification services.
- These services coordinate domain objects, repositories, and external gateways.
- This is where most workflows are assembled, including checkout, policy evaluation, role checks, and notification triggering.
5. Domain model and invariants
- Domain_Layer holds the core business entities and rules: Event, Seat, Area, Ticket, Purchase, OrderSaga, Policy, Lottery, Notification, Member, System_admin, and Company.
- The domain model includes explicit rule objects for purchase and discount policy composition, suggesting rich business rules rather than thin CRUD.
- Concurrency-sensitive concepts appear in the domain too, such as Lock, ActiveOrder, and WaitingQueue, which indicate coordinated ticket reservation and checkout behavior.
6. Checkout and order flow
- The order pipeline centers on CheckoutDomainService, ActiveOrderService, PaymentService, Purchase, PaymentDetails, PaymentTransaction, and OrderSaga.
- IPaymentGateway and ITicketSupplierGateway are abstraction points for external integrations, while PaymentGatewayProxy and TicketSupplierGatewayProxy are infrastructure adapters.
- The checkout flow likely goes from UI → application service → domain checks/policy validation → payment/supplier integration → persistence of order state and tickets.
7. Event seating and inventory handling
- Event modeling includes seat/area structures (SeatedArea, StandingArea, Row, Block, Seat) and a TicketGenerator.
- This suggests the system manages ticket allocation against structured event inventory, not just generic ticket records.
- There is also a waiting queue subsystem, implying oversubscription handling when inventory is constrained.
8. User, auth, and authorization
- Authentication is JWT-based with Spring Security; key classes include SecurityConfig, AuthTokenService, AuthToken, and token repositories.
- User/account concerns include registration, verification, password hashing, profiles, suspension, and company roles.
- Authorization is split across user roles, company permissions, and domain services such as CompanyAuthorizationDomainService and PolicyAuthorizationDomainService.
9. Notifications and real-time updates
- Notifications are implemented as a dedicated subsystem spanning application, domain, communication, and infrastructure layers.
- WebSocket support is configured through NotificationWebSocketConfig, with a broadcaster, session registry, handshake handler, and notification controller.
- Infrastructure includes WebSocketNotifier and NotificationRepository, so notifications are both persisted and pushed in real time to connected clients.
10. Persistence and infrastructure
- Persistence is handled by repositories in Infastructure_Layer, using an embedded H2 database per the README.
- Repositories exist for events, tickets, users, companies, complaints, policies, orders, lotteries, notifications, and queue/order state.
- This layer also contains cross-cutting adapters like password hashing, web configuration, and plugin/support classes.
11. Bootstrap and sample data
- DataInitializer and DemoDataLoader seed the application with initial/demo state.
- These are likely used to populate users, events, or policies for local development and testing.
- application.properties and test-specific properties define runtime configuration such as database and security settings.
12. Testing structure
- Tests are organized by domain and include unit, integration, acceptance, concurrency, and end-to-end system tests.
- The presence of many concurrency tests is significant: tickets, orders, lotteries, and users all have contention-sensitive behavior.
- This reflects an architecture where correctness under simultaneous access is a first-class concern.
13. Main architectural boundaries for a diagram
- Best diagram boundaries are: Vaadin UI, application services, domain model, repositories/infrastructure, security/auth, and WebSocket notifications.
- External dependencies to show explicitly are H2, Spring Security/JWT, and WebSocket clients.
- The primary data flow is UI action → application service → domain rule evaluation → repository/gateway persistence or external call → notification/update back to UI.
Main entry points: Frontend Vaadin views · PaymentService.java Checkout services · NotificationService.java Notify service · OrderSaga.java Order model
Components 25
Vaadin UI
User-facing Vaadin views and route pages.
- Vaadin views · Primary UI screens and route-driven views.
src/main/java/com/sdnah/Ticket_Management_System_/Frontend - Generated Flow · Generated frontend bundle and Flow glue code.
src/main/frontend/generated - Route pages · Endpoint classes that wire pages and navigation.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/endpoints
Application
Use-case services and orchestration.
- User services · Registration, verification, profiles, and admin/user flows.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/UserService.java - Event service · Event and ticket use-cases.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/EventService.java - Checkout services · Order, payment, policy, and reservation workflows.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/Order/PaymentService.java - Lottery service · Lottery entry and draw coordination.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/LotteryService.java - Company services · Company roles and management workflows.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/Company/CompanyRoleService.java - Complaint service · Complaint creation and handling workflows.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/ComplaintService.java - Notify service · Notification creation and dispatch coordination.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Application_Layer/Notifications/NotificationService.java
Domain
Core business model and rules.
- Event model · Events, areas, seats, and ticket generation rules.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Event/Event.java - Order model · Purchase, active order, saga, payment, and locking concepts.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Order/OrderSaga.java - Policy model · Purchase and discount policy composition and evaluation.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Policy/Policy.java - User model · Members, admins, auth tokens, roles, and suspensions.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/User/Member.java - Company model · Company entities, permissions, and role assignments.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Company/Company.java - Lottery model · Lottery entries and lottery state.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Lottery/Lottery.java - Complaint model · Complaint entities and status lifecycle.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/User/Complaint.java - Notification model · Notification entities and types.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Domain_Layer/Notifications/Notification.java
Infrastructure
Repositories and external adapters.
- Repositories · JPA/repository layer for events, orders, users, policies, lottery, and complaints.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Infastructure_Layer - Gateways · Payment and ticket-supplier integration proxies.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Infastructure_Layer/PaymentGatewayProxy.java - H2 database · Embedded persistence store used by the application.
Security & Realtime
Authentication, authorization, and notifications.
- WebSocket infra · Session registry, broadcaster, handshake, and notifier plumbing.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/Communication_Layer/Notifications/Broadcaster.java - Security config · Spring Security and JWT/token configuration.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/SecurityConfig.java
Bootstrap
Application startup and seed data.
- Spring Boot app · Main JVM entrypoint for the monolith.
src/main/java/com/sdnah/Ticket_Management_System_/TicketManagementSystemApplication.java - Seed data · Application initializers and demo data loaders.
src/main/java/com/sdnah/Ticket_Management_System_/Backend/DataInitializer.java
Connections 31
- Spring Boot app → Vaadin views: starts UI · Bootstraps the Vaadin application.
- Spring Boot app → Route pages: registers routes · Exposes route/page entrypoints.
- Route pages → Vaadin views: navigates · Pages are rendered through Vaadin views.
- Vaadin views → User services: calls beans · Views invoke Spring-managed services directly.
- Vaadin views → Event service: calls beans · Event screens coordinate through application services.
- Vaadin views → Checkout services: calls beans · Checkout and order screens use orchestration services.
- Vaadin views → Company services: calls beans · Company screens call company services.
- Vaadin views → Complaint service: calls beans · Complaint screens use complaint services.
- Vaadin views → Notify service: receives updates · Notification UI consumes pushed updates.
- Generated Flow → Vaadin views: plumbing · Generated Flow artifacts support the hand-written Vaadin views.
- User services → User model: uses · User orchestration depends on identity domain rules.
- User services → Security config: auth · Integrates with security and token handling.
- Event service → Event model: uses · Event use-cases operate on the event model.
- Checkout services → Order model: uses · Checkout logic centers on order and payment domain objects.
- Checkout services → Policy model: checks policies · Policy evaluation gates purchase and checkout.
- Checkout services → Gateways: integrates · Payments and ticket supply go through gateway adapters.
- Lottery service → Lottery model: uses · Lottery workflows operate on lottery entities.
- Company services → Company model: uses · Company role orchestration depends on company domain objects.
- Complaint service → Complaint model: uses · Complaint handling works on complaint entities.
- Notify service → Notification model: uses · Notification service creates and manages notifications.
- Notify service → WebSocket infra: pushes · Notification service broadcasts over WebSockets.
- Notify service → Repositories: persists · Notifications are stored through repositories.
- Order model → Event model: reserves seats · Orders interact with event inventory and ticket generation.
- Order model → Policy model: enforces · Order saga and checkout follow policy rules.
- User model → Company model: roles · User identities participate in company role assignments.
- Event model → Lottery model: feeds · Lottery can depend on event participation/inventory.
- Repositories → H2 database: stores data · Repositories persist to the embedded H2 database.
- Gateways → Order model: external side effects · Payment/ticket supplier calls are triggered by checkout flows.
- WebSocket infra → Vaadin views: pushes updates · WebSocket notifications update connected clients.
- Security config → User model: authorizes · Security configuration protects user/account actions.
- Seed data → Repositories: seeds · Initial data loaders populate repositories.