How fakytop/optify works
Project type and purpose
• This is a Spring Boot–based REST API whose sole purpose is to compare supermarket prices, manage users, stores, products and simulate shopping carts.
• Key use-cases: user authentication, CRUD on stores/products/categories, import and manual matching of product data, cart simulation, price comparison.
File structure
• Top‐level artifacts: Dockerfile (containerization), pom.xml (Maven build), gcloudignore (Google Cloud deployment hints), logs folder.
• src/main/java/com/optify:
• config: application‐wide Spring and CORS settings
• controllers: HTTP endpoints (CartController, ProductController, UserController, etc.)
• domain: JPA entity classes mapping to database tables
• dto: API request/response models decoupled from domain
• facade: coarse‐grained orchestrator combining multiple services
• services: business logic (CartService, ProductService, MatchManagerService, etc.)
• repository: Spring Data JPA interfaces for persistence
• security: JWT filters, API key filter, security configuration
• specifications: criteria builders for dynamic queries
• utilities & utils: helper classes (Console logging, ComparisonUtils)
• src/main/resources: application.properties, logback‐spring.xml
• src/test: unit/integration tests for controllers and services
Architectural patterns and principles
• Layered MVC: Controllers → Facade → Services → Repositories → Database
• DTO pattern at the API boundary
• Specification pattern for dynamic filtering
• Stateless, token-based authentication with JWT and API keys
• Dockerized microservice, ready for cloud deployment
Main components and interactions
a. Components:
• Client (Web/Mobile/UIs or API consumers)
• API Gateway or Load Balancer (optional entry point)
• Spring Boot App subdivided into:
• API Layer (Controllers + DTOs)
• Facade Layer
• Business Layer (Services)
• Persistence Layer (Repositories)
• Relational Database (PostgreSQL/MySQL)
• Authentication subsystem (JWT provider, API key store)
• External sources (file imports for manual matching)
b. Interactions:
1. Client sends HTTP request → passes through API Key/JWT filters
2. Spring MVC routes to appropriate Controller → maps payload to DTO
3. Controller calls Facade (if present) or directly Service
4. Service runs business logic, uses Specification classes for queries
5. Service invokes Repository → executes SQL on Database
6. Response assembled into DTO → returned to Client
7. DataImportService reads files → invokes ProductService/ManualMatchService → persists via Repositories
c. Technologies:
• Spring Boot, Spring Web MVC, Spring Data JPA (Hibernate), Spring Security (JWT)
• Maven, Docker, Logback
• (Optional) Google Cloud Run/App Engine
Detailed call sequence (optional inset)
• A sample path for “Compare Cart Prices”:
Client → JWT Filter → CartController → Facade → MatchManagerService → ProductService → ProductRepository → Database → up through layers → Response.