How juliorbk/visco-sg works
1. System shape
- This is a single Spring Boot 3 backend, not a multi-service system.
- It follows a classic layered architecture: controllers → services → repositories → PostgreSQL.
- The main application entry point is SystemApplication, with most business logic concentrated in service classes and persistence in Spring Data JPA repositories.
2. Core runtime and persistence
- The app runs on Java 21, uses Hibernate/JPA for ORM, and persists business state in PostgreSQL.
- Domain state is modeled as JPA entities under models/entities, while transport contracts are kept separate in models/dtos.
- This DTO/entity split is important: controllers should not be drawing directly from entities as API payloads.
3. Security boundary
- Authentication is stateless JWT-based, with the token stored in an HttpOnly cookie.
- Request authentication is enforced by JwtAuthFilter, while SecurityConfig defines authorization rules by role.
- CustomUserDetailsService and UserPrincipal bridge persisted users into Spring Security’s auth model.
4. Cross-cutting request protection
- RateLimitFilter adds per-IP throttling on sensitive endpoints such as login, registration, inventory, procurement, and dashboard access.
- GlobalExceptionHandler centralizes error translation for the API, so controller failures are converted into consistent HTTP responses.
- JpaAuditingConfig suggests created/updated metadata is managed automatically on entities.
5. Main business domains
- The repository is organized around enterprise procurement and inventory workflows:
- Auth / Users / Admin
- Suppliers
- Products / Inventory
- Warehouses / Locations / Stock movements
- Requisitions
- Procurement / Purchase orders
- Invoices
- Dashboard / Stats
- Cost centers, employees, management, general management
- Each domain has its own controller and service layer, with repositories tied to the corresponding entity set.
6. Primary workflow chain
- The most important data flow is the purchasing lifecycle:
- a requisition is created and approved,
- it can be converted into a purchase order,
- the order is approved and sent,
- goods are received in warehouse,
- inventory is updated through stock movements,
- and invoices are matched against ordered and received quantities.
- This flow ties together requisitions, procurement, warehouse, inventory, and invoices into one business process.
7. Inventory and warehouse boundary
- Inventory is not just a product catalog; it includes operational stock state.
- Entities like StockLevel, InventoryMovement, GoodReceipt, DispatchNote, and Warehouse indicate the system tracks:
- current stock by warehouse/location,
- movement history,
- receiving and dispatch operations,
- manual adjustments and transfers.
- Controllers and services in WarehouseController and WarehouseService are the main boundary for these operations.
8. Master data and administrative modules
- Product, Supplier, Category, Uom, Location, CostCenter, Employee, and Management are master-data style domains.
- These modules support the transactional flows above by providing reference data used in requisitions, purchasing, and inventory allocation.
- UserController and AdminController likely handle account lifecycle, role assignment, and administrative operations.
9. Reporting subsystem
- There is a distinct reporting package under com.visco.backend.reports, which behaves like a submodule inside the same application.
- It has its own controllers, entities, repositories, services, DTOs, enums, and utilities.
- This subsystem generates reports in multiple formats, including Excel and PDF, and includes scheduled reporting support (ScheduledReportService).
- Utilities such as chart generation and formatting suggest reports are assembled from business data, then exported and/or emailed.
10. Operational integrations
- The app integrates with SMTP email for notifications and scheduled report delivery.
- WeeklyReportService and the README’s scheduled report description imply a time-based job sends reports automatically.
- Dockerfile, docker-compose.yml, and Render deployment notes show it is intended to run containerized in production.
11. API documentation and developer experience
- OpenApiConfig and the Swagger/OpenAPI setup expose the REST surface for interactive exploration.
- The repository also includes HealthController for operational checking and ANALISIS_BRECHAS.md for security/gap analysis.
- This is a backend-first repo with strong emphasis on API contracts and operational visibility.
12. Import/export and batch operations
- The presence of Apache POI and Apache Commons CSV in the README maps to two important backend capabilities:
- Excel report generation
- bulk product import from CSV
- These are not core request/response endpoints but batch-oriented side flows that feed into the same product and reporting domains.
13. Testing boundary
- Tests are focused on service-layer behavior, not full end-to-end UI flows.
- Existing unit tests cover auth, invoice, procurement, requisition, stats, supplier, and warehouse services.
- That reinforces the architecture: the service layer is the main place where business rules are expected to live and be verified.
14. What to show in an architecture diagram
- A clean diagram for this repo should center on:
- Frontend client calling the Spring Boot API
- Security filter chain in front of controllers
- Domain services grouped by business area
- JPA repositories persisting to PostgreSQL
- Reporting/email scheduling as a side subsystem
- External dependencies: PostgreSQL, SMTP, and deployment/runtime infrastructure on Render.
Main entry points: SecurityConfig.java Security Config · ReportService.java Report Service · repositories JPA Repos · AuthService.java Auth Service
Components 24
Core API
Spring Boot entrypoint, controllers, services, and persistence for the main business domains.
- SystemApplication · Main Spring Boot application entry point.
src/main/java/com/visco/backend/SystemApplication.java - Auth API · Login, registration, and session-related endpoints.
src/main/java/com/visco/backend/controllers/AuthController.java - Procurement API · Requisitions and purchase-order workflow endpoints.
src/main/java/com/visco/backend/controllers/ProcurementController.java - Warehouse API · Stock, receiving, dispatch, and transfer endpoints.
src/main/java/com/visco/backend/controllers/WarehouseController.java - Product API · Product master data and import operations.
src/main/java/com/visco/backend/controllers/ProductController.java - Dashboard API · Operational stats and summary endpoints.
src/main/java/com/visco/backend/controllers/DashboardController.java - Admin API · Administrative account and role management endpoints.
src/main/java/com/visco/backend/controllers/AdminController.java - Auth Service · Authentication flow, cookie handling, and JWT issuance.
src/main/java/com/visco/backend/services/AuthService.java - Procurement Service · Requisition approval and purchase-order lifecycle.
src/main/java/com/visco/backend/services/ProcurementService.java - Warehouse Service · Inventory movements, receiving, dispatch, and stock operations.
src/main/java/com/visco/backend/services/WarehouseService.java - Stats Service · Dashboard metrics and business aggregates.
src/main/java/com/visco/backend/services/StatsService.java
Security
Authentication, authorization, and request protection.
- JWT Filter · Validates stateless JWT authentication from requests.
src/main/java/com/visco/backend/config/JwtAuthFilter.java - Rate Limit · Per-IP throttling for sensitive endpoints.
src/main/java/com/visco/backend/config/RateLimitFilter.java - Security Config · Authorization rules and security chain configuration.
src/main/java/com/visco/backend/config/SecurityConfig.java - User Details · Maps persisted users into Spring Security principals.
src/main/java/com/visco/backend/config/CustomUserDetailsService.java
Reporting
Standalone reporting subsystem within the same application.
- Report API · Report creation, export, and scheduling endpoints.
src/main/java/com/visco/backend/reports/controllers/ReportController.java - Report Service · Report generation orchestration and export workflow.
src/main/java/com/visco/backend/reports/services/ReportService.java - Scheduled Reports · Time-based report generation and delivery.
src/main/java/com/visco/backend/reports/services/ScheduledReportService.java - Export Utils · Excel, PDF, charting, and formatting helpers for reports.
src/main/java/com/visco/backend/reports/services/ExcelExportService.java
Infrastructure
Cross-cutting runtime, persistence, and external integrations.
- API Errors · Central exception translation for controller failures.
src/main/java/com/visco/backend/exception/GlobalExceptionHandler.java - JPA Models · Core domain entities for users, procurement, inventory, and master data.
src/main/java/com/visco/backend/models/entities - JPA Repos · Spring Data repositories for the main application domain.
src/main/java/com/visco/backend/repositories - PostgreSQL · Primary persistent store for business state.
- Email Service · SMTP-based notification and report delivery.
src/main/java/com/visco/backend/services/EmailService.java
Connections 28
- SystemApplication → Security Config: boots with · Application initializes the security configuration and request pipeline.
- SystemApplication → JPA Repos: wires · Spring Boot wires repositories and services at startup.
- Auth API → Auth Service: calls · Authentication endpoints delegate login and registration logic.
- Admin API → Auth Service: uses · Administrative account actions rely on auth/user services.
- Procurement API → Procurement Service: calls · Procurement endpoints delegate workflow orchestration.
- Warehouse API → Warehouse Service: calls · Warehouse endpoints delegate operational stock logic.
- Product API → JPA Repos: reads/writes · Product management persists through repositories.
- Dashboard API → Stats Service: calls · Dashboard endpoints query aggregates and KPIs.
- Auth Service → User Details: authenticates via · Auth service integrates with Spring Security user lookup.
- Auth Service → Email Service: notifies · Authentication flows may trigger email notifications.
- JWT Filter → Security Config: enforced by · JWT authentication participates in the security chain.
- Rate Limit → Security Config: enforced by · Rate limiting is applied within the security/request pipeline.
- Security Config → Auth API: protects · Authorization rules gate API endpoints.
- Security Config → Procurement API: protects · Authorization applies to procurement operations.
- Security Config → Warehouse API: protects · Authorization applies to warehouse operations.
- Security Config → Dashboard API: protects · Authorization applies to dashboard access.
- User Details → JPA Repos: loads users from · Security bridge resolves users via repositories.
- JPA Repos → JPA Models: maps · Repositories operate on JPA entities.
- JPA Models → PostgreSQL: persists to · JPA entities are stored in PostgreSQL.
- API Errors → Auth API: handles errors for · Central error handling normalizes API responses.
- API Errors → Procurement API: handles errors for · Central error handling normalizes API responses.
- API Errors → Warehouse API: handles errors for · Central error handling normalizes API responses.
- Report API → Report Service: calls · Report endpoints delegate generation and export.
- Report Service → Export Utils: uses · Report generation uses export and chart helpers.
- Scheduled Reports → Report Service: triggers · Scheduled jobs invoke report generation workflows.
- Scheduled Reports → Email Service: delivers via · Scheduled reports are sent through SMTP email.
- Report Service → JPA Repos: reads data from · Reports aggregate business data through repositories.
- Report Service → PostgreSQL: exports from · Reports ultimately derive from persisted operational data.