How medina-felipe/sanus-corpus works
1. This is a Spring Boot backend named backendpill for a pharmacy-oriented system (“Sanus-Corpus / Pagina de Farmacia Fruna”). The architecture is organized by business capability rather than by technical layer alone.
2. The top-level domain areas are:
- auth for user identity and access control
- catalog for products, categories, brands, stock, and medicine type
- favorites for user-saved items
- legal for legal documents
- support for support tickets
- shared for cross-cutting concerns
3. Each feature module follows a consistent three-part structure:
- infrastructure: REST controllers, repositories, security integration
- application: services and DTOs
- domain: core entities and domain enums
This makes the package layout suitable for a layered diagram with clear dependency direction: controllers call services, services use repositories, and domain objects sit at the center.
4. The request path is typical of a REST API:
client/requester → controller (infrastructure) → service (application) → repository (infrastructure) → persistence store.
DTOs are used for external API contracts, while domain entities model persisted business state.
5. Authentication is its own subsystem. AuthController, UserController, UserService, and JwtService indicate token-based security using JWT. SecurityConfig is the boundary where authentication/authorization is enforced before requests reach business controllers.
6. User and role modeling is in auth.domain (User, Role). The presence of login/user request-response DTOs suggests the system issues auth responses and likely supports user registration, login, and user management flows.
7. The catalog subsystem models the pharmacy inventory domain. Product, Category, Brand, Stock, and TypeMedicine indicate product metadata plus inventory/medicine classification. ProductService and CategoryService coordinate catalog operations, while product/category repositories persist them.
8. The favorites subsystem is user-centric and likely connects authenticated users to saved products. FavoriteService, FavoriteController, and FavoriteRepository suggest a simple CRUD-style capability that depends on both user identity and catalog references.
9. The legal and support subsystems are separate business modules. LegalDocument with DocumentType models regulatory/content management, while SupportTicket with SupportCategory models user support intake and tracking. Both follow the same service/controller/repository pattern.
10. The shared package contains cross-cutting infrastructure used by multiple modules:
- ApiResponse for standardized responses
- custom exceptions (BusinessException, NotFoundException, UnauthorizedException)
- GlobalExceptionHandler for centralized error mapping
- DateTimeUtil, FileStorageService, NotificationService for reusable utilities/services
This boundary is important in the diagram because it reduces duplication across feature modules.
11. Persistence is repository-driven, likely through Spring Data JPA/Hibernate given the Repository naming and entity-style domain classes. The diagram should show repositories as the data access boundary for each module rather than direct database access from controllers.
12. Configuration is profile-based: application.properties plus application-dev.properties, application-prod.properties, and application-test.properties. That indicates environment-specific runtime behavior, especially for database and deployment settings.
13. Tests are set up with a dedicated test application and TestcontainersConfiguration, which suggests integration testing against ephemeral infrastructure instead of only mocks. This matters in the architecture because tests validate the real wiring of Spring, persistence, and containerized dependencies.
14. In short, the repository is a modular monolith backend: one Spring Boot application, multiple business subdomains, shared cross-cutting services, JWT-secured REST endpoints, and repository-based persistence. A clear diagram should emphasize module boundaries and the common request/response pipeline through security, controllers, services, and repositories.
Main entry points: FileStorageService.java Shared core · UserService.java Auth core · ProductService.java Catalog core · FavoriteService.java Favorites core
Components 25
Runtime
Spring Boot bootstrap and test wiring
- App boot · Main application entry point
backendpill/src/main/java/com/backendpill/BackendpillApplication.java - Test wiring · Test application and container setup
backendpill/src/test/java/com/backendpill/TestcontainersConfiguration.java
Auth
Identity, JWT, and access control
- Auth API · Login, user, and security-facing endpoints
backendpill/src/main/java/com/backendpill/auth/infrastructure/AuthController.java - Auth core · JWT issuing and user operations
backendpill/src/main/java/com/backendpill/auth/application/UserService.java - Auth model · Users and roles
backendpill/src/main/java/com/backendpill/auth/domain/User.java - Auth repo · Persistence boundary for users
backendpill/src/main/java/com/backendpill/auth/infrastructure/UserRepository.java - Security · JWT and request protection boundary
backendpill/src/main/java/com/backendpill/auth/infrastructure/SecurityConfig.java
Catalog
Products, categories, brands, and stock
- Catalog API · Product and category endpoints
backendpill/src/main/java/com/backendpill/catalog/infrastructure/ProductController.java - Catalog core · Product and category orchestration
backendpill/src/main/java/com/backendpill/catalog/application/ProductService.java - Catalog model · Products, brands, stock, and medicine types
backendpill/src/main/java/com/backendpill/catalog/domain/Product.java - Catalog repo · Persistence boundary for catalog data
backendpill/src/main/java/com/backendpill/catalog/infrastructure/ProductRepository.java
Favorites
User-saved catalog items
- Favorites API · Saved-item endpoints
backendpill/src/main/java/com/backendpill/favorites/infrastructure/FavoriteController.java - Favorites core · User-to-product favorites logic
backendpill/src/main/java/com/backendpill/favorites/application/FavoriteService.java - Favorites model · Favorite association state
backendpill/src/main/java/com/backendpill/favorites/domain/Favorite.java - Favorites repo · Persistence boundary for favorites
backendpill/src/main/java/com/backendpill/favorites/infrastructure/FavoriteRepository.java
Legal
Regulatory documents
- Legal API · Document endpoints
backendpill/src/main/java/com/backendpill/legal/infrastructure/LegalController.java - Legal core · Legal document operations
backendpill/src/main/java/com/backendpill/legal/application/LegalService.java - Legal model · Legal documents and types
backendpill/src/main/java/com/backendpill/legal/domain/LegalDocument.java - Legal repo · Persistence boundary for legal content
backendpill/src/main/java/com/backendpill/legal/infrastructure/LegalRepository.java
Support
Support tickets and intake
- Support API · Ticket intake endpoints
backendpill/src/main/java/com/backendpill/support/infrastructure/SupportController.java - Support core · Ticket workflow and categorization
backendpill/src/main/java/com/backendpill/support/application/SupportService.java - Support model · Support tickets and categories
backendpill/src/main/java/com/backendpill/support/domain/SupportTicket.java - Support repo · Persistence boundary for support tickets
backendpill/src/main/java/com/backendpill/support/infrastructure/SupportRepository.java
Shared
Cross-cutting responses, errors, and utilities
- Shared core · Reusable services such as date, file, and notification helpers
backendpill/src/main/java/com/backendpill/shared/application/FileStorageService.java - Shared errors · Standard API response and centralized exception mapping
backendpill/src/main/java/com/backendpill/shared/infrastructure/GlobalExceptionHandler.java
Connections 24
- App boot → Security: starts · Bootstraps security and module wiring
- Security → Auth API: guards · Enforces authentication and authorization before controllers
- Auth API → Auth core: calls · Controller delegates to auth service layer
- Auth core → Auth repo: uses · Service persists and loads user data through repository
- Auth core → Auth model: maps · Service operates on user and role domain objects
- Catalog API → Catalog core: calls · Catalog requests flow into application services
- Catalog core → Catalog repo: uses · Service uses repositories for catalog persistence
- Catalog core → Catalog model: maps · Catalog logic centers on product and inventory entities
- Favorites API → Favorites core: calls · Favorites endpoints delegate to service logic
- Favorites core → Favorites repo: uses · Favorites service persists saved items
- Favorites core → Favorites model: maps · Favorites logic revolves around favorite associations
- Legal API → Legal core: calls · Legal endpoints delegate to service logic
- Legal core → Legal repo: uses · Service persists legal documents
- Legal core → Legal model: maps · Legal service works with document entities and types
- Support API → Support core: calls · Support endpoints delegate to ticket services
- Support core → Support repo: uses · Support service persists tickets
- Support core → Support model: maps · Support service centers on ticket and category domain objects
- Shared core → Shared errors: supports · Shared utilities feed standardized responses and exception handling
- Auth core → Shared core: reuses · Auth uses shared reusable services
- Catalog core → Shared core: reuses · Catalog uses shared reusable services
- Favorites core → Shared core: reuses · Favorites uses shared reusable services
- Legal core → Shared core: reuses · Legal uses shared reusable services
- Support core → Shared core: reuses · Support uses shared reusable services
- Test wiring → App boot: verifies · Integration tests validate the Spring wiring and runtime setup