How vaibhavsandi/rentmanagementsystem_backend works
1. This is a Spring Boot monolith for rent management, organized as a layered backend application. The main runtime entrypoint is DemoApplication, with configuration and component scanning rooted under com.app.rentmanagement.demo.
2. The domain is centered on property-rental operations: flats, renters, rent payments, rent revisions, parking details, expenses, settlements, pending rent, and dashboard summaries. Those concepts are represented consistently across entities, DTOs, services, controllers, and repositories.
3. The primary request flow is standard controller → service → repository → entity. Controllers expose the API, services implement business rules, repositories provide persistence access, and entities model the database state. DTOs are used at the API boundary so controllers do not directly expose persistence models.
4. Persistence is built on Spring Data JPA-style repositories with a relational database model. The entity layer includes User, Flat, Renter, RentPayment, RentRevision, ParkingDetails, Expense, and Settlement, plus enums such as PaymentMode, RenterStatus, and UserRole.
5. Authentication and authorization are a distinct subsystem. AuthController works with JwtUtil, JwtAuthenticationFilter, CustomUserDetailsService, and CustomUserDetails to secure the API with JWT-based login and request filtering. User is the security principal stored in the domain model.
6. There is a clear separation between API contracts and internal models through the mapper layer. Mappers convert between entities and DTOs for flats, renters, parking details, rent payments, revisions, expenses, and settlements, which keeps controller payloads stable and limits coupling to persistence shape.
7. Business services are split by feature area, each with its own interface and implementation pair. The service layer includes Flat, Renter, Parking, RentPayment, Expense, Settlement, PendingRent, and Dashboard services, indicating a modular but single-process architecture rather than separate microservices.
8. Reporting is a separate output path from the core CRUD flows. ReportController delegates to ExcelReportService and PdfReportService, which likely aggregate data from the same domain services/repositories and render downloadable reports in spreadsheet and PDF formats.
9. Cross-cutting concerns are centralized. GlobalExceptionHandler turns domain and validation failures into structured API errors, while custom exceptions such as ResourceNotFoundException, DuplicateRecordException, BadRequestException, and FlatDeleteException define business-specific failure boundaries.
10. Auditing and shared utilities support the domain model. BaseEntity and AuditAwareImpl indicate created/modified metadata tracking via JPA auditing, while AppConstants, CommonUtil, and DateUtil provide shared application-level helpers used across features.
11. AppConfig and SwaggerConfig show that the app also exposes API documentation and general Spring configuration. Swagger/OpenAPI is part of the developer-facing interface, but it does not change the runtime business flow.
12. Overall, the architecture is a classic layered Spring Boot backend with a security boundary in front of feature controllers, a service-centered business layer, repository-backed persistence, and specialized report/export paths for operational outputs.
Main entry points: FlatController.java Feature APIs · Flat.java Domain Models · FlatService.java Flat Service · ParkingService.java Ops Services
Components 23
Bootstrap
Application entrypoint and configuration
API Layer
Controllers exposed to clients
- Auth API · Login and authentication endpoints
src/main/java/com/app/rentmanagement/demo/controller/AuthController.java - Feature APIs · Flat, renter, payment, parking, expense, settlement, pending-rent, and dashboard endpoints
src/main/java/com/app/rentmanagement/demo/controller/FlatController.java - Report API · Export endpoints for spreadsheet and PDF reports
src/main/java/com/app/rentmanagement/demo/report/ReportController.java
Domain Layer
Feature services and supporting mappers
- Flat Service · Flat management business rules
src/main/java/com/app/rentmanagement/demo/service/FlatService.java - Renter Service · Renter lifecycle and status rules
src/main/java/com/app/rentmanagement/demo/service/RenterService.java - Payment Service · Rent payment processing and revisions
src/main/java/com/app/rentmanagement/demo/service/RentPaymentService.java - Ops Services · Parking, expense, settlement, pending rent, and dashboard logic
src/main/java/com/app/rentmanagement/demo/service/ParkingService.java - Mappers · Entity-to-DTO conversions for API boundaries
src/main/java/com/app/rentmanagement/demo/mapper/FlatMapper.java
Persistence
Repositories and entities
- Flat Repo · Persistence access for flats
src/main/java/com/app/rentmanagement/demo/repository/FlatRepository.java - Renter Repo · Persistence access for renters
src/main/java/com/app/rentmanagement/demo/repository/RenterRepository.java - Payment Repo · Persistence access for rent payments and revisions
src/main/java/com/app/rentmanagement/demo/repository/RentPaymentRepository.java - Ops Repos · Parking, expense, settlement, and user persistence access
src/main/java/com/app/rentmanagement/demo/repository/ParkingRepository.java - Domain Models · Flats, renters, payments, revisions, parking, expenses, settlements, and users
src/main/java/com/app/rentmanagement/demo/entity/Flat.java
Security
JWT authentication and principal loading
- Auth Service · JWT login support and user principal loading
src/main/java/com/app/rentmanagement/demo/security/CustomUserDetailsService.java - JWT Filter · Validates incoming bearer tokens on secured requests
src/main/java/com/app/rentmanagement/demo/security/JwtAuthenticationFilter.java - JWT Utils · Token creation and validation utilities
src/main/java/com/app/rentmanagement/demo/security/JwtUtil.java - User Details · Spring Security user wrapper around domain users
src/main/java/com/app/rentmanagement/demo/security/CustomUserDetails.java
Shared
Auditing, exceptions, utilities, and reporting
- Auditing · Base entity metadata and auditor provider
src/main/java/com/app/rentmanagement/demo/audit/BaseEntity.java - Errors · Global handler and business exceptions
src/main/java/com/app/rentmanagement/demo/exception/GlobalExceptionHandler.java - Reports · Excel and PDF report generation
src/main/java/com/app/rentmanagement/demo/report/ExcelReportService.java - Utilities · Shared constants and date/common helpers
src/main/java/com/app/rentmanagement/demo/util/AppConstants.java
Connections 32
- DemoApp → Config: loads · Bootstraps Spring configuration and component scanning
- DemoApp → Auth API: starts · Exposes the API runtime
- DemoApp → Feature APIs: starts · Registers feature endpoints
- DemoApp → Report API: starts · Registers report endpoints
- Auth API → Auth Service: authenticates · Delegates login and user lookup
- Auth Service → JWT Utils: uses · Creates and validates JWTs
- JWT Filter → JWT Utils: verifies · Checks bearer tokens on requests
- JWT Filter → Auth Service: loads user · Resolves authenticated principal
- Auth Service → User Details: builds · Wraps domain users as security principals
- Feature APIs → Flat Service: delegates · Flat API calls into business logic
- Feature APIs → Renter Service: delegates · Renter API calls into business logic
- Feature APIs → Payment Service: delegates · Payment API calls into business logic
- Feature APIs → Ops Services: delegates · Parking, expense, settlement, pending-rent, and dashboard requests
- Feature APIs → Mappers: translates · Uses DTO mappings at the API boundary
- Report API → Reports: generates · Produces Excel and PDF outputs
- Report API → Ops Services: aggregates · Pulls operational data for reports
- Flat Service → Flat Repo: persists · Reads and writes flat records
- Renter Service → Renter Repo: persists · Reads and writes renter records
- Payment Service → Payment Repo: persists · Reads and writes payment and revision records
- Ops Services → Ops Repos: persists · Uses specialized repositories for operations
- Flat Service → Domain Models: models · Operates on flat domain state
- Renter Service → Domain Models: models · Operates on renter domain state
- Payment Service → Domain Models: models · Operates on rent payment and revision state
- Ops Services → Domain Models: models · Operates on parking, expense, settlement, and dashboard state
- Mappers → Domain Models: converts · Maps entities to DTOs and back
- Mappers → Utilities: uses · Relies on shared helpers for formatting and dates
- Domain Models → Auditing: extends · Common base entity metadata and audit fields
- Errors → Flat Service: guards · Surfaces service and validation failures
- Errors → Renter Service: guards · Surfaces service and validation failures
- Errors → Payment Service: guards · Surfaces service and validation failures
- Utilities → Flat Service: supports · Shared constants and date utilities
- Utilities → Ops Services: supports · Shared constants and helper functions