How prasadclasher/pricing-app works
1. Overall shape
- This is a two-tier pricing application: a React/Vite frontend and a Spring Boot backend.
- The backend owns all business rules, authentication, persistence, and background processing. The frontend is a thin UI that calls the backend over HTTP.
2. Primary user-facing flows
- Employees authenticate, view their account info, inspect pricing records, update prices, and upload pricing files.
- The app’s core domain is store pricing data, plus audit history and file upload processing.
3. Backend API boundary
- The HTTP layer is organized into three main controllers:
- AuthController for login and current-user/session endpoints.
- PricingRecordController for reading and updating pricing records.
- UploadController for file upload initiation and upload-job status/results.
- A GlobalExceptionHandler centralizes API error translation into consistent responses.
4. Business logic layer
- Services hold the core orchestration:
- AuthService handles login and user/session-related logic.
- PricingRecordService manages pricing retrieval, updates, and audit generation.
- UploadService coordinates file upload lifecycle and job creation.
- CsvProcessingService parses uploaded CSV content and turns it into records/errors.
- ActorContext suggests the backend tracks the current authenticated actor for auditing or business decisions.
5. Persistence model
- The app uses a relational database accessed through Spring Data repositories.
- Key persisted entities are:
- AppUser and UserRole for user access.
- PricingRecord for store price data.
- PricingAuditLog for change history.
- UploadedFile, UploadJob, UploadJobError, and UploadJobStatus for upload tracking.
- Repositories are dedicated per aggregate, which keeps data access separated from controller/service logic.
6. Authentication and authorization boundary
- Security is JWT-based.
- JwtAuthenticationFilter authenticates requests by reading tokens.
- JwtService issues/validates tokens.
- SecurityConfig wires the security rules, and JsonAuthenticationEntryPoint ensures unauthorized responses are returned in API-friendly JSON.
- AuthenticatedUser is the security principal used by the application.
7. Async processing path for file uploads
- Uploads are not just stored; they appear to be processed as a background job.
- The backend has a Kafka-based messaging subsystem:
- UploadJobProducer publishes work.
- UploadJobConsumer consumes and processes upload jobs.
- UploadJobMessage is the payload contract.
- This creates a clear split between synchronous API handling and asynchronous CSV import execution.
8. Data and audit flows
- The pricing update path likely goes: authenticated user → API → pricing service → database update → audit log entry.
- The upload path likely goes: user uploads file → backend stores file/job metadata → job message is published → consumer parses CSV → valid rows become pricing updates → invalid rows are stored as job errors.
- The existence of audit and error entities indicates the system is built for traceability, not just raw data mutation.
9. Schema management
- Database structure is managed with Flyway migrations under src/main/resources/db/migration.
- Migrations show the domain evolved in stages:
- base pricing schema,
- indexes,
- user authentication,
- uploaded file support,
- later schema refinement.
- This means the database is treated as a first-class part of the architecture.
10. Frontend role
- The frontend is a separate TypeScript SPA built with Vite.
- api.ts is the main integration point to the backend API.
- App.tsx and main.tsx wire the UI shell; the built dist/ output is present in the repo, but the architectural source is the src/ tree.
- The frontend does not appear to own business logic; it consumes backend endpoints.
11. Contracts and integration surface
- openapi-mvp.yaml suggests an explicit API contract exists for the backend, which is useful for aligning frontend/backend integration and documenting the exposed endpoints.
- Response/request DTOs in api/request and api/response isolate the public API from persistence entities.
12. Infrastructure assumptions visible from the repo
- The system depends on at least three infrastructure pieces: a relational database, JWT auth, and Kafka.
- Those external services are central to the architecture because they separate concerns into:
- request/response API handling,
- secure user identity,
- durable persistence,
- asynchronous bulk import processing.
Main entry points: api.ts API Client · GlobalExceptionHandler.java Errors · V1__mvp_schema.sql Migrations · AuthService.java Auth Service
Components 20
Frontend
React/Vite single-page app and browser-side API integration
- UI Shell · Main browser application shell and routing/bootstrap entrypoints.
frontend/src/App.tsx - API Client · Frontend integration point for calling backend endpoints.
frontend/src/api.ts - Bootstrap · Application startup and mounting logic.
frontend/src/main.tsx
Backend
Spring Boot API, business logic, security, persistence, and messaging
- Auth API · Login and current-user/session endpoints.
backend/src/main/java/com/pricingfeed/api/AuthController.java - Pricing API · Read and update pricing records and expose audit views.
backend/src/main/java/com/pricingfeed/api/PricingRecordController.java - Upload API · File upload initiation and job status/result endpoints.
backend/src/main/java/com/pricingfeed/api/UploadController.java - Errors · Maps application exceptions to consistent HTTP responses.
backend/src/main/java/com/pricingfeed/api/GlobalExceptionHandler.java - Auth Service · Login and user/session orchestration.
backend/src/main/java/com/pricingfeed/service/AuthService.java - Pricing Service · Pricing retrieval, updates, and audit generation.
backend/src/main/java/com/pricingfeed/service/PricingRecordService.java - Upload Service · Upload lifecycle coordination and job creation.
backend/src/main/java/com/pricingfeed/service/UploadService.java - CSV Parser · Parses uploaded CSV content into rows and errors.
backend/src/main/java/com/pricingfeed/service/CsvProcessingService.java - Actor Context · Tracks the current authenticated actor for business and audit decisions.
backend/src/main/java/com/pricingfeed/service/ActorContext.java - JWT Security · Token issuance, request filtering, entry point, and security rules.
backend/src/main/java/com/pricingfeed/security/JwtService.java - Security Config · Wires authentication and authorization rules.
backend/src/main/java/com/pricingfeed/config/SecurityConfig.java - Pricing Data · Pricing records and audit history persisted in the relational database.
backend/src/main/java/com/pricingfeed/entity/PricingRecord.java - Users · Application users, roles, and user repository boundary.
backend/src/main/java/com/pricingfeed/entity/AppUser.java - Uploads · Uploaded files, jobs, statuses, and error rows.
backend/src/main/java/com/pricingfeed/entity/UploadJob.java - Upload Jobs · Producer/consumer workflow for asynchronous CSV import processing.
backend/src/main/java/com/pricingfeed/messaging/UploadJobProducer.java
Infrastructure
External services and schema management
- Migrations · Database schema migrations for pricing, auth, uploads, and refinements.
backend/src/main/resources/db/migration/V1__mvp_schema.sql - API Contract · Shared API contract for backend endpoints and DTOs.
openapi-mvp.yaml
Connections 26
- Bootstrap → UI Shell: mounts · Bootstraps the SPA shell.
- UI Shell → API Client: calls · Uses the shared API client for backend requests.
- API Client → API Contract: aligned with · Frontend integration follows the published contract.
- API Client → Auth API: HTTP · Sends login and session requests.
- API Client → Pricing API: HTTP · Reads and updates pricing data.
- API Client → Upload API: HTTP · Starts uploads and polls job status.
- Auth API → Auth Service: delegates · Controller layer hands off auth logic.
- Pricing API → Pricing Service: delegates · Controller layer hands off pricing logic.
- Upload API → Upload Service: delegates · Controller layer hands off upload orchestration.
- Errors → Auth API: covers · Translates errors from API endpoints.
- Errors → Pricing API: covers · Translates errors from API endpoints.
- Errors → Upload API: covers · Translates errors from API endpoints.
- Auth Service → JWT Security: issues tokens · Auth service relies on JWT token creation and validation.
- JWT Security → Security Config: wired by · Security config installs JWT filter and auth rules.
- JWT Security → Actor Context: sets actor · Authenticated principal becomes the current actor.
- Auth Service → Users: reads/writes · Validates and loads user accounts and roles.
- Pricing Service → Pricing Data: reads/writes · Persists pricing records and audit history.
- Pricing Service → Actor Context: uses · Captures who performed the pricing change.
- Upload Service → Uploads: creates jobs · Stores upload files, jobs, and results.
- Upload Service → Upload Jobs: publishes · Enqueues asynchronous import work.
- Upload Jobs → CSV Parser: consumes into · Background consumer parses and processes CSV payloads.
- CSV Parser → Pricing Data: updates · Valid rows become pricing changes.
- CSV Parser → Uploads: records errors · Invalid rows are stored as job errors.
- Migrations → Pricing Data: migrates · Defines pricing and audit schema.
- Migrations → Users: migrates · Defines authentication-related tables and roles.
- Migrations → Uploads: migrates · Defines upload tracking tables and refinements.