How ajaysinghratnawat/404-debuggers works
1. This repository is a small multi-service backend system for a pharmacy domain, with two Java Spring Boot backend variants and one Python AI service. The main architectural split is between the core transactional backend and a separate AI recommendation/search service.
2. The Java backend is organized as a classic layered monolith: HTTP controllers at the edge, service implementations for business logic, Spring Data repositories for persistence, and JPA-style domain entities for the data model. The main package is com.pharmazone.
3. The domain model centers on users, medicines, orders, prescriptions, consultations, and platform pricing. The entities and enums suggest workflows for customer ordering, prescription handling, doctor consultations, order status tracking, and role-based access control.
4. The exposed API surface is divided by concern into controllers such as AuthController, MedicineController, OrderController, PrescriptionController, and ConsultationController. In the v2 backend there is also an AIController, which is the integration point for AI-driven features.
5. Business logic lives in service classes under service/impl, including AuthService, MedicineService, OrderService, PrescriptionService, and ConsultationService. In v2, AIServiceClient acts as an outbound client to the Python AI service rather than embedding AI logic in the Java app.
6. Persistence is handled through repository interfaces for each aggregate or major entity: user, medicine, order, prescription, consultation, and platform price. This implies the backend reads and writes a relational datastore through the repository layer, with controllers never talking directly to persistence.
7. Security is a first-class boundary in the Java backend. SecurityConfig, JwtAuthFilter, JwtUtil, and CustomUserDetailsService indicate stateless JWT-based authentication with role-aware authorization, which is reinforced by the Role enum and the authentication DTOs.
8. Cross-cutting concerns are centralized in exception and configuration packages. GlobalExceptionHandler and custom exceptions provide consistent API error handling, while AppConfig and RestTemplateConfig wire infrastructure beans. In v2, ai.properties isolates configuration for the AI endpoint.
9. The Python AI service is a separate deployable application under pharmazone-ai-service/pharmazone-ai. Its structure resembles a FastAPI app: app/main.py is the entry point, routers/ contains feature endpoints for search, pricing, demand, and substitutes, models/schemas.py defines request/response shapes, and services/model_loader.py loads the underlying model or scoring assets.
10. The main data flow for AI features is: client calls the Java backend, the backend controller/service invokes AIServiceClient, and that client calls the Python service over HTTP. The AI service then returns ranked or generated outputs such as substitute drugs, price insights, demand signals, or search results back to the Java API.
11. The presence of both pharmazone-backend and pharmazone-backend-v2 suggests two versions of the same Spring Boot backend. For architecture diagrams, treat v2 as the evolved version: it contains the same transactional core plus explicit AI integration, while the older backend is the non-AI baseline.
12. Overall, the system boundaries are: API/security at the edge, domain/services in the middle, repositories/database access below, and an external Python AI microservice on the side. The likely deployment shape is a Java Spring Boot API backed by a database, with a separate Python inference service called only for AI-related endpoints.
Main entry points: pharmazone/controller Controllers · service/impl Services · pharmazone/controller Controllers · service/impl Services
Components 20
Backend v1
Baseline Spring Boot transactional API
- Boot app · Application entrypoint for the baseline backend
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/PharmaZoneApplication.java - Config · Core application and security wiring
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/config - Controllers · Auth, medicine, order, prescription, and consultation endpoints
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/controller - Services · Transactional orchestration for core pharmacy workflows
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/service/impl - Repositories · Spring Data persistence interfaces
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/repository - Domain model · Users, medicines, orders, prescriptions, consultations, roles, and statuses
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/entity - Security · JWT filter, token utility, and user details service
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/security - Errors · Global exception handling and custom API exceptions
pharmazone-backend/pharmazone/src/main/java/com/pharmazone/exception
Backend v2
Evolved Spring Boot API with AI integration
- Boot app · Application entrypoint for the AI-enabled backend
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/PharmaZoneApplication.java - Config · Application, REST client, security, and AI endpoint configuration
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/config - Controllers · Auth, medicine, order, prescription, consultation, and AI endpoints
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/controller - Services · Transactional orchestration plus outbound AI client
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/service/impl - Repositories · Spring Data persistence interfaces
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/repository - Domain model · Users, medicines, orders, prescriptions, consultations, roles, and statuses
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/entity - Security · JWT filter, token utility, and user details service
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/security - Errors · Global exception handling and custom API exceptions
pharmazone-backend-v2/pharmazone/src/main/java/com/pharmazone/exception
AI service
Separate Python inference service
- App · Python service entrypoint
pharmazone-ai-service/pharmazone-ai/app/main.py - Routers · Search, price, demand, and substitutes endpoints
pharmazone-ai-service/pharmazone-ai/app/routers - Schemas · Request and response shapes for AI features
pharmazone-ai-service/pharmazone-ai/app/models/schemas.py - Model loader · Loads model or scoring assets used by the AI service
pharmazone-ai-service/pharmazone-ai/app/services/model_loader.py
Connections 20
- Boot app → Config: wires · Bootstraps application configuration and security
- Boot app → Controllers: starts · Exposes the HTTP API
- Controllers → Services: calls · Delegates business operations
- Services → Repositories: persists via · Uses repository interfaces for storage
- Services → Domain model: operates on · Reads and mutates core pharmacy entities
- Config → Security: configures · Sets up JWT-based auth and request filtering
- Controllers → Errors: handled by · API failures flow through global exception handling
- Security → Domain model: uses roles · Authorization depends on user and role model
- Boot app → Config: wires · Bootstraps application configuration and security
- Boot app → Controllers: starts · Exposes the HTTP API
- Controllers → Services: calls · Delegates business operations
- Services → Repositories: persists via · Uses repository interfaces for storage
- Services → Domain model: operates on · Reads and mutates core pharmacy entities
- Config → Security: configures · Sets up JWT-based auth and request filtering
- Controllers → Errors: handled by · API failures flow through global exception handling
- Services → Model loader: invokes · Outbound client calls the Python AI service
- Controllers → App: via AI endpoints · AI features are exposed through the backend API boundary
- App → Routers: mounts · Registers feature routers
- Routers → Schemas: validates with · Uses schemas for request and response contracts
- Routers → Model loader: loads · Routers depend on model-loading support