Crop Deal: Microservices Farm-to-Dealer Platform Architecture
A technical case study on building a farm-to-dealer agricultural platform using Spring Boot microservices, Angular, and cloud-native design patterns.
CROP DEAL
A Microservices-Based Farm-to-Dealer Platform
Empowering Farmers | Connecting Dealers | Transforming Agriculture
Microservices Architecture
Spring Boot
Angular
Cloud-Native
Case Study | Full Stack Microservices Implementation
THE PROBLEM
Farmers struggle to get fair prices in traditional markets
High transportation costs to reach markets
Long wait times & unexpected commissions
Multiple intermediaries reduce farmer profits
Lack of price transparency
THE SOLUTION
A digital platform bridging Farmers and Dealers directly — eliminating middlemen, reducing costs, and ensuring transparent payments from farm itself.
Direct Farm-to-Dealer Connection
Transparent Digital Payments
Location-Based Crop Publishing
NO MORE MIDDLEMEN. NO HIDDEN COMMISSIONS. JUST FAIR TRADE.
Microservices Architecture
Cloud-Native | Spring Boot | Spring Cloud
Client Layer
Angular Web App
Mobile app
API Gateway Layer
API Gateway
Spring Cloud Gateway and JWT Validation Layer<br/>
Microservices Layer
Auth Service
(JWT)
Auth DB (MySQL)
User Service
(Farmer / Dealer)
User DB (MySQL)
Crop Listing Service
(Catalog)
Crop DB (MongoDB)
Payment Service
(Transactions)
Payment DB (MySQL)
Notification Service
(Push & Events)
Notification DB (H2)
Infrastructure Layer
Eureka Service Registry
(Service Discovery)
Spring Cloud Config Server
(GitHub)
RabbitMQ
(Message Broker)
Zipkin
(Distributed Tracing)
Use Case Diagram
Actors & System Interactions
CROP DEAL SYSTEM
Manage Farmers (Active/Inactive)
Manage Dealers
Generate Reports
Export Data
Sign Up / Login
Federated Identity
View / Edit Profile
Add Bank Account
Publish Crop Details
View Receipts
Subscribe for Crops
Make Payment
Generate Invoice
Sequence Diagram
Crop Listing & Purchase Flow
USE CASE DIAGRAM
Actor Interactions & System Boundaries
CropDeal System
FARMER
DEALER
ADMIN
Publish Crop Details
Manage Bank Account
View Receipts
Edit Profile
Sign Up / Login
Federated Login (OAuth)
Subscribe to Crops
Make Payment
Generate Invoice
View Ratings
Manage Users
Generate Reports
View Analytics
Activate/Deactivate Users
SEQUENCE DIAGRAM
Crop Listing & Payment Flow — Microservices Interaction
Angular UI
API Gateway
Auth Service
User Service
Crop Service
Payment Service
RabbitMQ
Notification Service
POST /auth/login (JWT Request)
Validate Credentials
Return JWT Token
200 OK + JWT
POST /crops/publish (+ JWT Header)
Validate JWT
Save Crop Listing
201 Created
Publish CropCreated Event
Notify Subscribed Dealers
POST /payment/initiate
Process Payment (Event Sourcing)
Transfer Funds via Feign Client
Publish PaymentSuccess Event
Send Receipt to Farmer
ENTITY DIAGRAM
Database Schema — Microservice Databases
USER
CROP_LISTING
PAYMENT
INVOICE
NOTIFICATION
BANK_ACCOUNT
1:M receives
1:1 has
1:M makes
1:M publishes
1:1
1:1 generates
DESIGN PATTERNS
Patterns Implemented Across Microservices
SERVICE REGISTRY & DISCOVERY
Services auto-register with Eureka Server. Other services discover instances dynamically via Eureka Client, enabling load-balanced service-to-service calls.
All Microservices via Spring Cloud Eureka
<circle cx="12" cy="12" r="10"></circle><line x1="2" y1="12" x2="22" y2="12"></line><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"></path>
EXTERNALIZED CONFIGURATION
All service configurations (DB URLs, ports, secrets) are centralized in a GitHub repo and served via Spring Cloud Config Server at startup.
Spring Cloud Config Server + GitHub
<circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path>
FEDERATED IDENTITY
Users authenticate via Email or Facebook OAuth2. JWT tokens are issued by the Auth Service and validated at the API Gateway for every request.
Auth Service — Spring Security + OAuth2 + JWT
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"></path><path d="M9 12l2 2 4-4"></path>
CQRS<br/><span style='font-size: 15px; font-weight: 600; opacity: 0.9;'>Command Query Responsibility Segregation</span>
Read (query) operations for reports, invoices, and dashboards are separated from write (command) operations — enabling optimized querying across services.
Payment, Invoice & Admin Report Services
<ellipse cx="12" cy="5" rx="9" ry="3"></ellipse><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
EVENT SOURCING
Payment transactions are stored as an immutable sequence of events. Each state change (INITIATED → PROCESSED → COMPLETED) is recorded and replayable via RabbitMQ.
Payment Service + RabbitMQ Event Bus
<polygon points="12 2 2 7 12 12 22 7 12 2"></polygon><polyline points="2 17 12 22 22 17"></polyline><polyline points="2 12 12 17 22 12"></polyline>
TECH STACK & BEST PRACTICES
Implementation Standards & Tools Used
TECHNOLOGY STACK
BEST PRACTICES
Spring Boot 3.x — Microservice Framework
Spring Cloud Gateway — API Gateway
Spring Security + JWT — Authentication
Spring Cloud Eureka — Service Discovery
Spring Cloud Config + GitHub — Ext. Config
Feign Client — Service-to-Service Communication
RabbitMQ — Async Messaging (Event Sourcing)
MySQL / MongoDB / H2 — Independent DBs
Angular 17 — Web Frontend (TypeScript)
Zipkin — Distributed Tracing
Docker — Containerized Deployment
Swagger / OpenAPI 3 — API Documentation
Lombok + SLF4J File Appender Logging
JUnit 5 + Mockito — Unit Testing
JaCoCo — 100% Code Coverage Target
SonarQube Static Analysis (Zero High Issues)
Global Exception Handling (@ControllerAdvice)
Independent Database per Microservice
Async/Parallel Design with RabbitMQ
ALB Routing via API Gateway
JWT Security on All Endpoints
CQRS for Report & Invoice Queries
CROP DEAL — Empowering Farmers. Connecting Dealers. Built on Microservices.
- microservices
- spring-boot
- agriculture-tech
- full-stack-development
- software-architecture
- system-design
- java