How commoner02/rento works
1. This is a server-rendered Spring Boot MVC application, not a SPA or pure REST service. The primary request flow is browser → Spring MVC controllers → service layer → JPA repositories → PostgreSQL, then back to Thymeleaf views.
2. The presentation boundary is Thymeleaf templates under src/main/resources/templates, with shared layout fragments and role-specific pages for auth, products, rentals, buyer, seller, and admin. Static assets are minimal and live in static/css/main.css.
3. The controller layer is the main routing boundary. AuthController, ProductController, RentalController, AdminController, and DashboardController translate HTTP requests into application actions and select views or redirects. The app is organized around page workflows such as login/register, product management, rental lifecycle, and admin user/payment management.
4. Business logic is concentrated in the service layer: UserService, ProductService, and RentalService. These services enforce domain rules such as role behavior, rental state transitions, product availability, quantity checks, and ownership/permission constraints before persistence occurs.
5. The core domain model is centered on User, Product, Rental, RentalItem, and Payment. The important relationship boundary is that rentals are the aggregate root for rental transactions, with line items in RentalItem connecting rentals to products and storing per-rental pricing/quantity details; Payment is associated with a rental for financial tracking and refunds.
6. Persistence is handled through Spring Data JPA repositories for each aggregate: UserRepository, ProductRepository, RentalRepository, RentalItemRepository, and PaymentRepository. These repositories are the only layer that directly touches the database, keeping controllers and views free of SQL concerns.
7. Security is a major architectural boundary. SecurityConfig and UserDetailsServiceImpl integrate Spring Security for authentication and authorization, with role-based access for ADMIN, SELLER, and BUYER. This is reflected both in controller access rules and in the separate role-specific dashboard pages.
8. Error handling is centralized through GlobalExceptionHandler plus custom exceptions such as ResourceNotFoundException and InsufficientQuantityException. This indicates a domain-driven failure model: missing resources and stock/rental constraint violations are handled consistently rather than ad hoc in controllers.
9. DataInitializer seeds the application with initial users and likely demo data, which matters for architecture because the system expects predefined roles and sample accounts on startup. That makes the app suitable for first-run demonstration without manual database setup.
10. The runtime and infrastructure are standard Spring Boot 3.2 / Java 17 / Maven, with PostgreSQL for production persistence and H2 in tests. Docker and docker-compose.yml package the app and database together, while GitHub Actions performs test/build automation and can trigger Render deployment on mainline changes.
11. Testing is split by layer: unit tests for services/security and integration tests for controllers and repositories. The presence of H2 test configuration means the test boundary is intentionally isolated from external infrastructure, which keeps CI stable and fast.
12. For an architecture diagram, the key flows to show are: authentication and role resolution, product CRUD by admin, rental creation by buyers, rental state changes by seller/admin, and payment/refund oversight by admin. These flows all converge on the same domain and repository layers, with authorization enforced before business operations and persistence.
Main entry points: templates Thymeleaf · AdminController.java Admin controller · SecurityConfig.java Security config · AuthController.java Auth controller
Components 29
Presentation
Browser-facing MVC pages, templates, and static assets.
- Browser · User entry point for server-rendered MVC flows.
- Thymeleaf · Server-rendered pages for auth, products, rentals, and role dashboards.
src/main/resources/templates - Base layout · Shared page shell and reusable fragments.
src/main/resources/templates/fragments/base.html - Main CSS · Minimal shared styling for the app.
src/main/resources/static/css/main.css
Application
Controllers, services, security, and exception handling.
- Auth controller · Login and registration flow.
src/main/java/com/rento/controller/AuthController.java - Product controller · Product browsing and management pages.
src/main/java/com/rento/controller/ProductController.java - Rental controller · Rental creation, listing, detail, and return flows.
src/main/java/com/rento/controller/RentalController.java - Admin controller · Admin oversight for users and payments.
src/main/java/com/rento/controller/AdminController.java - Dashboard controller · Role-specific landing pages.
src/main/java/com/rento/controller/DashboardController.java - Security config · Authentication and authorization rules for roles and pages.
src/main/java/com/rento/config/SecurityConfig.java - User details · Loads users for Spring Security authentication.
src/main/java/com/rento/security/UserDetailsServiceImpl.java - Exception handler · Centralized handling for not-found and stock/rule violations.
src/main/java/com/rento/exception/GlobalExceptionHandler.java - User service · User and role-related application logic.
src/main/java/com/rento/service/UserService.java - Product service · Product rules, ownership, and availability checks.
src/main/java/com/rento/service/ProductService.java - Rental service · Rental lifecycle, quantity checks, and state transitions.
src/main/java/com/rento/service/RentalService.java
Domain
Core rental and catalog entities.
- User · Application user and role principal.
src/main/java/com/rento/model/User.java - Product · Rentable catalog item.
src/main/java/com/rento/model/Product.java - Rental · Rental transaction aggregate root.
src/main/java/com/rento/model/Rental.java - Rental item · Per-rental line item with quantity and pricing.
src/main/java/com/rento/model/RentalItem.java - Payment · Payment and refund tracking linked to a rental.
src/main/java/com/rento/model/Payment.java
Persistence
Spring Data repositories and database boundary.
- User repo · Persistence boundary for users.
src/main/java/com/rento/repository/UserRepository.java - Product repo · Persistence boundary for products.
src/main/java/com/rento/repository/ProductRepository.java - Rental repo · Persistence boundary for rentals.
src/main/java/com/rento/repository/RentalRepository.java - Rental item repo · Persistence boundary for rental line items.
src/main/java/com/rento/repository/RentalItemRepository.java - Payment repo · Persistence boundary for payments.
src/main/java/com/rento/repository/PaymentRepository.java
Runtime
Startup seeding and deployment/infrastructure.
- PostgreSQL · Primary production database.
- Data initializer · Seeds users and demo data on startup.
src/main/java/com/rento/config/DataInitializer.java - Docker Compose · Containerized app and database runtime.
docker-compose.yml - CI/CD · Build, test, and deployment automation.
.github/workflows/ci-cd.yml
Connections 42
- Browser → Auth controller: login/register · Browser submits auth requests to MVC endpoints.
- Browser → Product controller: browse/manage · Browser reaches product pages and actions.
- Browser → Rental controller: rent/return · Browser drives rental workflows.
- Browser → Admin controller: admin pages · Browser reaches admin oversight screens.
- Browser → Dashboard controller: dashboards · Browser opens role-specific landing pages.
- Auth controller → Security config: authz · Authentication flows are governed by security rules.
- Product controller → Security config: authz · Product actions are protected by role rules.
- Rental controller → Security config: authz · Rental actions require authenticated, authorized users.
- Admin controller → Security config: authz · Admin functions require elevated access.
- Dashboard controller → Security config: authz · Dashboard routing depends on resolved roles.
- Security config → User details: users · Security loads principals through user details service.
- Auth controller → User service: account flow · Registration and user operations delegate to user service.
- Product controller → Product service: catalog flow · Product pages delegate to product service.
- Rental controller → Rental service: rental flow · Rental workflows delegate to rental service.
- Admin controller → User service: user admin · Admin user management uses user service.
- Admin controller → Rental service: payments · Admin payment oversight uses rental service operations.
- User service → User repo: persist · User service persists through the repository layer.
- Product service → Product repo: persist · Product service persists through the repository layer.
- Rental service → Rental repo: persist · Rental service persists rentals through JPA.
- Rental service → Rental item repo: line items · Rental service persists rental line items.
- Rental service → Payment repo: payments · Rental service persists payment records.
- User repo → PostgreSQL: JPA · User data is stored in PostgreSQL.
- Product repo → PostgreSQL: JPA · Product data is stored in PostgreSQL.
- Rental repo → PostgreSQL: JPA · Rental data is stored in PostgreSQL.
- Rental item repo → PostgreSQL: JPA · Rental item data is stored in PostgreSQL.
- Payment repo → PostgreSQL: JPA · Payment data is stored in PostgreSQL.
- Thymeleaf → Base layout: fragments · Views share a common base layout.
- Auth controller → Thymeleaf: render · Auth controller selects auth views or redirects.
- Product controller → Thymeleaf: render · Product controller renders product templates.
- Rental controller → Thymeleaf: render · Rental controller renders rental templates.
- Admin controller → Thymeleaf: render · Admin controller renders admin templates.
- Dashboard controller → Thymeleaf: render · Dashboard controller renders role dashboards.
- Thymeleaf → Main CSS: style · Templates use shared styling from the CSS asset.
- Data initializer → User repo: seed · Startup seeding creates initial users.
- Data initializer → Product repo: seed · Startup seeding may create demo catalog data.
- Data initializer → PostgreSQL: bootstrap · Seed data is written to the database on startup.
- Exception handler → Auth controller: errors · Controller exceptions are normalized centrally.
- Exception handler → Product controller: errors · Controller exceptions are normalized centrally.
- Exception handler → Rental controller: errors · Controller exceptions are normalized centrally.
- Exception handler → Admin controller: errors · Controller exceptions are normalized centrally.
- Docker Compose → PostgreSQL: runs · Docker Compose packages the database with the app.
- CI/CD → Docker Compose: build/deploy · CI/CD automates container build and deployment.