How vasuantala049/milk-production-and-prediction-system works
1. Overall shape
- This is a full-stack dairy management platform with three main layers: a React/Vite frontend, a Spring Boot backend API, and infrastructure/deployment code for AWS + Kubernetes.
- The core business flow is farm operations and milk commerce: manage farms/sheds/cattle, track milk production and inventory, and support customer buying/subscriptions.
2. Frontend: role-based single-page app
- The frontend is a React SPA built with Vite and served behind Nginx.
- It is organized around user roles and workflows: customer, worker, and owner dashboards, plus screens for login/register, forgot password, farm/cattle management, milk entry, subscriptions, orders, and profile management.
- The UI also includes internationalization support for English and Gujarati, a barcode scanner component, and reusable UI primitives.
3. Frontend-to-backend interaction
- The frontend talks to the backend through dedicated API clients for cattle, farm, order, and subscription flows.
- Route protection is handled in the client, so authenticated navigation is a frontend concern, but authorization is ultimately enforced by the backend.
4. Backend architecture: classic layered Spring Boot
- The backend follows a standard Controller → Service → Repository → Entity structure.
- Controllers expose REST endpoints by domain area: auth, user, farm, shed, cattle, milk, buy milk, order, and subscription.
- Services contain business rules; repositories wrap persistence; DTOs isolate API contracts from JPA entities.
5. Core domain model
- The main entities are Farm, Shed, Cattle, MilkInventory, CattleMilkEntry, MilkAllocation, Orders, Subscription, User, and worker/invitation linkage objects.
- The domain is built around operational relationships: farms contain sheds and cattle, cattle generate milk entries, milk is aggregated into inventory and allocated for sale, and orders/subscriptions consume that inventory.
- Worker assignments and invitations indicate multi-tenant, role-scoped access to farm resources.
6. Security and identity
- Authentication is JWT-based, with a custom user-details service and a JWT authentication filter in the request pipeline.
- Password handling uses a bounded bcrypt encoder, and user roles are modeled explicitly in the domain.
- Auth-related APIs support login, registration, forgot-password, and OTP/reset flows, which suggests email-driven account recovery.
7. Persistence and runtime dependencies
- The backend uses a relational persistence layer via Spring Data repositories and JPA entities.
- Redis is a first-class runtime dependency: there is dedicated Redis cache configuration plus a startup check, so the application expects Redis to be available and healthy.
- There is also a database health controller, implying operational readiness/liveness checks are part of the backend surface.
8. Payments and commerce workflows
- The buy-milk, order, and subscription modules are separate, but connected through shared inventory and payment request/response DTOs.
- Razorpay-specific response DTOs indicate external payment-gateway integration for purchase and subscription checkout.
- Orders and subscriptions have explicit status enums, which suggests stateful payment lifecycle handling.
9. Operational support and cross-cutting concerns
- A global exception handler centralizes API error translation.
- Mapper configuration suggests DTO/entity conversion is a formal concern rather than ad hoc mapping.
- Email service implementation supports notification-style workflows such as OTP, password reset, and worker invitations.
10. Deployment and platform
- The repo includes Kubernetes Helm charts for the application stack, with separate templates for backend, frontend, Redis, ingress, namespace, secrets, and autoscaling.
- Nginx ingress is included as part of the platform layer, which means external traffic is routed into the cluster through ingress resources rather than direct pod exposure.
- The frontend also has cert assets and an Nginx config, indicating HTTPS-aware static serving or reverse-proxy deployment.
11. Infrastructure as code and GitOps
- Terraform provisions the AWS environment; the README specifically calls out DB credentials as Terraform inputs, so infrastructure and application bootstrap are meant to be repeatable.
- There are Argo CD and image updater manifests, which points to GitOps-based rollout of container images into Kubernetes.
- CI files for GitHub Actions and Jenkins indicate automated build/test/package pipelines feed the deployment process.
12. How data moves through the system
- Users interact with the SPA, which calls REST endpoints on the Spring Boot API.
- The backend authenticates requests with JWT, reads/writes relational state through repositories, uses Redis for cache or fast access, and emits updates through payment/email flows when needed.
- Deployed services run in Kubernetes behind ingress, with AWS-provisioned infrastructure underneath and image updates managed through CI/CD/GitOps.
Main entry points: ingress.yml Helm stack · App.jsx SPA shell · AuthController.java REST API · FarmServiceImpl.java Business services
Components 19
Frontend
React/Vite SPA with role-based dashboards and API clients
- SPA shell · Entry app and shared routing/layout for the dairy portal
frontend/src/App.jsx - Dashboards · Owner, worker, and customer dashboard screens and farm operations views
frontend/src/components/dashboard/OwnerDashboard.jsx - Auth screens · Login, registration, password reset, and protected navigation
frontend/src/components/Login.jsx - API clients · Client layer for cattle, farm, order, subscription, and shared requests
frontend/src/api/client.js - i18n · English/Gujarati translations and language switching
frontend/src/config/i18n.js
Backend
Spring Boot API with layered domain and security stack
- API app · Main backend application bootstrap and runtime wiring
backend/backend/src/main/java/com/example/backend/BackendApplication.java - REST API · Domain controllers for auth, farm, cattle, milk, orders, and subscriptions
backend/backend/src/main/java/com/example/backend/Controller/AuthController.java - Business services · Core business rules for farm access, cattle, milk, buying, orders, and subscriptions
backend/backend/src/main/java/com/example/backend/Service/impl/FarmServiceImpl.java - Repositories · Spring Data repositories for relational persistence
backend/backend/src/main/java/com/example/backend/Repository/FarmRepository.java - Domain model · Farms, sheds, cattle, milk inventory, orders, subscriptions, users, and worker linkage
backend/backend/src/main/java/com/example/backend/Entity/Farm.java - Security · JWT filter, token provider, user details service, and password encoding
backend/backend/src/main/java/com/example/backend/Security/SecurityConfig.java - Cross-cutting · Exception handling, mapping config, cache config, and Redis startup checks
backend/backend/src/main/java/com/example/backend/Config/GlobalExceptionHandler.java - Redis · Redis cache dependency and health/startup validation
backend/backend/src/main/java/com/example/backend/Config/RedisCacheConfig.java
Platform
Kubernetes, GitOps, and cloud infrastructure
- Helm stack · Application deployment charts for frontend, backend, Redis, ingress, secrets, and scaling
helm/dairy-flow/templates/ingress.yml - Ingress · Nginx ingress controller and exposure layer for cluster traffic
helm/dairy-flow/nginx-ingress/templates/controller-deployment.yaml - Terraform · AWS environment provisioning and bootstrap inputs
terraform/main.tf
Delivery
CI/CD and automation around builds and rollout
- GitHub Actions · Automated backend workflow execution and build orchestration
.github/workflows/backend.yml - Jenkins · Additional build and delivery automation
Jenkinsfile - Argo CD · GitOps manifests and image updater configuration for deployment synchronization
argocd/milk-img-updater.yml
Connections 24
- SPA shell → Dashboards: renders · SPA composes role-based operational views
- SPA shell → Auth screens: routes · Login and recovery flows are handled in the client
- SPA shell → API clients: calls · UI actions use dedicated API clients
- SPA shell → i18n: localizes · Language selection and translations are shared across screens
- API clients → REST API: REST · Frontend clients consume backend endpoints
- API app → Security: configures · Security pipeline is applied at application startup
- API app → REST API: hosts · Spring Boot exposes the REST surface
- REST API → Business services: delegates · Controllers hand off business logic to services
- Business services → Repositories: persists · Services load and save through repositories
- Repositories → Domain model: maps · Repositories operate on JPA entities
- Business services → Domain model: uses · Business rules are expressed over the domain model
- Security → REST API: guards · JWT authentication protects API access
- Security → Cross-cutting: supports · Security depends on shared configuration and error handling
- Cross-cutting → Redis: checks · Redis is validated during backend startup
- Business services → Redis: caches · Runtime access may use Redis-backed cache or fast state
- REST API → Cross-cutting: errors · Exceptions are translated into API responses centrally
- Helm stack → Ingress: includes · Application charts rely on ingress resources and Nginx exposure
- Helm stack → API app: deploys · Backend is packaged for Kubernetes deployment
- Helm stack → SPA shell: deploys · Frontend is packaged for Kubernetes deployment
- Helm stack → Redis: deploys · Redis is deployed as part of the application stack
- Terraform → Helm stack: provisions · Cloud infrastructure underpins the Kubernetes release
- GitHub Actions → API app: builds · GitHub Actions drives backend automation
- Jenkins → Helm stack: delivers · Jenkins supports packaging and rollout workflows
- Argo CD → Helm stack: syncs · Argo CD keeps cluster state aligned with git manifests