How nvakulenko/architecture-lab4 works
1. This is a small Spring Boot backend centered on two business areas: accounts and flight bookings. The entry point is BookingApplication, and the app is organized as two feature modules rather than layered globally.
2. The architecture follows a consistent controller → service → repository → persistence model flow. Each feature has its own API package, service package, and repository package, which keeps the account and booking logic separated.
3. The account subsystem exposes AccountRestController for HTTP access, AccountService for business logic, AccountRepository for persistence, and the Account entity as the stored model. AccountDto is used to transfer account data through the API boundary.
4. The account domain has an important rule from the README: the amount field must never be below zero. That constraint is part of the persistence/domain boundary, because it protects the balance data that booking operations depend on.
5. The flight booking subsystem mirrors the same structure: FlyRestApiController, FlyBookingService, FlyBookingRepository, and the FlyBooking entity, with FlyBookingDto at the API boundary. This suggests a classic REST-to-service-to-database path for booking operations.
6. The main business flow is: a client calls the booking API, the booking service checks the customer’s account balance, and then a booking is created while the account is debited. The README explicitly describes the “enough funds” check as a required rule.
7. The two subsystems are coupled through the shared account balance. Booking is not a standalone write; it depends on account state and must fail if the balance is insufficient. That dependency is the key integration boundary in the system.
8. Error handling is explicit in the service layer. There are custom exceptions for account problems (AccountException, AccountNotFoundException) and booking problems (FlyBookingException), which indicates that business validation failures are intended to be translated into API-level error responses.
9. Persistence is repository-based and likely uses Spring Data/JPA-style abstractions, given the repository interfaces and entity classes. The repositories are the only direct data access boundary; controllers should not touch entities directly.
10. application.properties holds runtime configuration, while Fly Booking Service.postman_collection.json is provided for manual API testing and documentation of the HTTP contract. There is no frontend in this repository.
11. For an architecture diagram, the most important boundaries are:
- external client / Postman collection
- REST controllers
- business services
- repositories / database
- shared account balance dependency used by booking logic
12. In short, this is a backend service that manages customer accounts and flight bookings, enforcing a non-negative balance and “sufficient funds before booking” rule through the service layer.
Main entry points: FlyBookingService.java Booking Service · AccountRestController.java Account API · FlyRestApiController.java Booking API · AccountService.java Account Service
Components 16
Application
Spring Boot entry point and runtime config
- BookingApp · Application entry point
src/main/java/org/example/BookingApplication.java - Config · Application properties
src/main/resources/application.properties
Accounts
Customer account API, service, and persistence
- Account API · HTTP boundary for accounts
src/main/java/org/example/account/api/AccountRestController.java - Account DTO · Account data transfer object
src/main/java/org/example/account/api/dto/AccountDto.java - Account Service · Account rules and balance operations
src/main/java/org/example/account/service/AccountService.java - Account Repo · Persistence access for accounts
src/main/java/org/example/account/repository/AccountRepository.java - Account · Stored account model
src/main/java/org/example/account/repository/model/Account.java - Account Errors · Account validation and not-found failures
src/main/java/org/example/account/service/exception/AccountException.java
Bookings
Flight booking API, service, and persistence
- Booking API · HTTP boundary for flight bookings
src/main/java/org/example/flybooking/api/FlyRestApiController.java - Booking DTO · Booking data transfer object
src/main/java/org/example/flybooking/api/dto/FlyBookingDto.java - Booking Service · Checks funds and creates bookings
src/main/java/org/example/flybooking/service/FlyBookingService.java - Booking Repo · Persistence access for bookings
src/main/java/org/example/flybooking/repository/FlyBookingRepository.java - FlyBooking · Stored booking model
src/main/java/org/example/flybooking/repository/FlyBooking.java - Booking Errors · Booking validation failures
src/main/java/org/example/flybooking/service/exception/FlyBookingException.java
External
Client-facing and manual testing integration
- Client · Calls the REST API
- Postman · Manual API testing and contract reference
Fly Booking Service.postman_collection.json
Connections 19
- Client → Account API: calls · HTTP access to account operations
- Client → Booking API: calls · HTTP access to booking operations
- Postman → Account API: exercises · Manual requests for account endpoints
- Postman → Booking API: exercises · Manual requests for booking endpoints
- BookingApp → Account API: wires · Bootstraps account API
- BookingApp → Booking API: wires · Bootstraps booking API
- BookingApp → Config: loads · Runtime configuration
- Account API → Account Service: uses · Delegates account operations
- Account API → Account DTO: maps · API payload boundary
- Account Service → Account Repo: persists · Reads and updates account state
- Account Service → Account Errors: throws · Business validation failures
- Account Repo → Account: stores · Account entity persistence
- Booking API → Booking Service: uses · Delegates booking operations
- Booking API → Booking DTO: maps · API payload boundary
- Booking Service → Booking Repo: persists · Reads and writes bookings
- Booking Service → Account Service: checks balance · Validates sufficient funds before booking
- Booking Service → Booking Errors: throws · Booking validation failures
- Booking Repo → FlyBooking: stores · Booking entity persistence
- Booking Service → Account Repo: reads balance · Accesses account state for fund checks