How nikhi111/greenshelf works
1. Overall shape: a single Spring Boot backend monolith
GreenSelf is organized as a layered Java/Spring Boot application rather than a set of separate services. The runtime is a REST API server backed by MySQL, with the usual Spring boundaries: controllers at the edge, services for business logic, repositories for persistence, and JPA entities for the domain model.
2. Primary request entry points are controller-based API modules
The API surface is split by domain into UserController, SellerController, AdminController, ProductController, PlantController, PaymentController, RecommendationController, and WebhookController. This makes the main architectural boundary the HTTP API layer, with each controller owning one functional area of the marketplace.
3. Business logic is concentrated in service classes
The service layer contains the real workflows: user account operations, seller/nursery management, product and inventory handling, order/payment orchestration, admin verification flows, payout handling, and plant recommendations. CustomUserService also supports authentication by loading user details for Spring Security.
4. Persistence is split across domain repositories and JPA entities
The data model includes core marketplace entities such as User, Seller, Nursery, Product, Plant, Cart, Order, Payment, Inventory, and related join/detail entities like CartProduct, OrderProduct, and InventoryProduct. Spring Data repositories map each aggregate to the database, which keeps persistence concerns separate from request handling.
5. Authentication and authorization are JWT-based
Security is handled with SecurityConfig, JwtAuthFilter, JwtUtil, and CustomUserDetails. The architecture suggests token-based access control around protected endpoints, with CORS explicitly configured for frontend integration. Public browsing endpoints are separated from authenticated user, seller, and admin operations.
6. Marketplace flow: browse, cart, order, pay
The user journey moves through product discovery, cart management, order creation, and payment verification. Cart, Order, and Payment are distinct domain stages, which is important for diagramming because order placement and payment confirmation are not a single step; they are separate backend responsibilities.
7. Seller and admin workflows form a verification/operations boundary
Sellers can register, create nurseries, manage products, and track inventory, while admins verify sellers and nurseries and oversee platform operations. The existence of SellerRequest, SellerRequestStatus, and admin services indicates a gated onboarding workflow rather than immediate seller activation.
8. Inventory is treated as a first-class subsystem
Inventory is not embedded directly inside product records. Instead, the repo has Inventory, InventoryProduct, and related repositories, which suggests a layered stock-management model where a nursery or seller’s inventory is tracked separately from the marketplace catalog.
9. Recommendations are an external-data-driven subsystem
The recommendation feature is its own module with RecommendationController, RecommendationService, and DTOs for weather and ML request/response data. RestTemplateConfig implies outbound HTTP calls, likely to fetch weather/location data and feed it into a recommendation engine that returns suitable plants.
10. Payments integrate with Razorpay and webhooks
Payment handling is explicitly isolated in PaymentController, RazorpayConfig, and WebhookController. That separation matters architecturally: synchronous payment verification and asynchronous webhook event handling are both present, and seller payout processing is handled as a related but separate concern.
11. DTOs are used heavily as the API boundary
The Dto package is large and covers requests/responses for users, sellers, products, carts, orders, payments, weather, recommendations, and verification flows. This indicates the system avoids exposing entities directly over the wire, which is a clean boundary for a REST backend.
12. Cross-cutting concerns are centralized
Error handling is handled by GlobalExceptionHandler, API docs by OpenApiConfig, CORS by CorsConfig, and external client wiring by RestTemplateConfig. These are infrastructure-level modules that support the feature controllers without mixing into business logic.
13. Testing is layered around controllers and services
The test tree includes controller tests and UserServiceTest, plus a base Spring Boot test. That matches the layered architecture: integration-style checks around the API surface and focused unit/service tests for core business logic.
14. Deployment/runtime context
The project is Maven-based, runs as a Spring Boot application, and is configured for deployment on Render according to the README. Swagger UI is part of the runtime API documentation, which is useful for understanding the exposed backend contract but does not change the core architecture.
Main entry points: User.java Domain model · PaymentService.java Payment service · SecurityConfig.java Security · UserService.java User service
Components 29
API layer
HTTP entry points grouped by functional domain
- Users · User account and authentication endpoints
src/main/java/com/example/GreenSelf/controller/UserController.java - Sellers · Seller onboarding and nursery-facing endpoints
src/main/java/com/example/GreenSelf/controller/SellerController.java - Admin · Verification and platform operations endpoints
src/main/java/com/example/GreenSelf/controller/AdminController.java - Products · Catalog and product browsing endpoints
src/main/java/com/example/GreenSelf/controller/ProductController.java - Plants · Plant data and related browse endpoints
src/main/java/com/example/GreenSelf/controller/PlantController.java - Payments · Payment creation and verification endpoints
src/main/java/com/example/GreenSelf/controller/PaymentController.java - Recommend · Plant recommendation endpoints
src/main/java/com/example/GreenSelf/controller/RecommendationController.java - Webhook · Asynchronous payment callback handling
src/main/java/com/example/GreenSelf/controller/WebhookController.java
Core services
Business workflows and orchestration
- User service · User registration, profile, and cart/order-facing logic
src/main/java/com/example/GreenSelf/service/UserService.java - Seller service · Seller, nursery, and inventory workflows
src/main/java/com/example/GreenSelf/service/SellerService.java - Admin service · Seller verification and admin operations
src/main/java/com/example/GreenSelf/service/AdminService.java - Product service · Catalog and inventory coordination
src/main/java/com/example/GreenSelf/service/ProductService.java - Payment service · Payment verification and settlement workflows
src/main/java/com/example/GreenSelf/service/PaymentService.java - Payout service · Seller payout processing
src/main/java/com/example/GreenSelf/service/PayoutService.java - Rec service · Weather-driven plant recommendations
src/main/java/com/example/GreenSelf/service/RecommendationService.java
Persistence
Entities and repositories backing the monolith
- User repo · User persistence gateway
src/main/java/com/example/GreenSelf/repo/UserRepo.java - Seller repo · Seller and request persistence gateway
src/main/java/com/example/GreenSelf/repo/SellerRepo.java - Product repo · Catalog persistence gateway
src/main/java/com/example/GreenSelf/repo/ProductRepo.java - Order repo · Order persistence gateway
src/main/java/com/example/GreenSelf/repo/OrderRepo.java - Payment repo · Payment persistence gateway
src/main/java/com/example/GreenSelf/repo/PaymentRepo.java - Inventory repo · Inventory persistence gateway
src/main/java/com/example/GreenSelf/repo/InventoryRepo.java - Cart repo · Cart persistence gateway
src/main/java/com/example/GreenSelf/repo/CartRepo.java - Domain model · Core marketplace entities for users, sellers, products, carts, orders, payments, and inventory
src/main/java/com/example/GreenSelf/entity/User.java
Infrastructure
Security, configuration, and cross-cutting concerns
- GreenSelf · Application bootstrap for the backend monolith
src/main/java/com/example/GreenSelf/GreenSelfApplication.java - Security · JWT auth, Spring Security, and user detail loading
src/main/java/com/example/GreenSelf/config/SecurityConfig.java - JWT filter · Token validation on protected requests
src/main/java/com/example/GreenSelf/filter/JwtAuthFilter.java - JWT util · Token generation and parsing helpers
src/main/java/com/example/GreenSelf/util/JwtUtil.java - Configs · CORS, OpenAPI, REST client, and Razorpay wiring
src/main/java/com/example/GreenSelf/config/RazorpayConfig.java - Errors · Central API exception translation
src/main/java/com/example/GreenSelf/exception/GlobalExceptionHandler.java
Connections 32
- GreenSelf → Security: boots with · Application starts through secured web configuration
- GreenSelf → Configs: loads · Bootstraps infrastructure configuration
- GreenSelf → Errors: uses · Centralized exception handling is part of runtime setup
- Security → JWT filter: includes · Security config installs the JWT filter
- Security → JWT util: relies on · Security uses JWT helper utilities
- Security → User service: auth via · Custom user loading supports authentication flows
- Users → User service: calls · User controller delegates account workflows
- Sellers → Seller service: calls · Seller controller delegates seller workflows
- Admin → Admin service: calls · Admin controller delegates verification workflows
- Products → Product service: calls · Product controller delegates catalog workflows
- Plants → Rec service: calls · Plant endpoints support recommendation-related browsing
- Payments → Payment service: calls · Payment controller delegates payment workflows
- Webhook → Payment service: notifies · Webhook callbacks feed asynchronous payment handling
- Recommend → Rec service: calls · Recommendation controller delegates ML/weather workflow
- User service → User repo: persists via · User workflows read and write user data
- User service → Cart repo: manages · User-facing cart logic touches cart storage
- Seller service → Seller repo: persists via · Seller onboarding and management storage
- Seller service → Inventory repo: updates · Seller workflows manage inventory state
- Admin service → Seller repo: verifies · Admin workflows update seller approval state
- Product service → Product repo: reads/writes · Catalog changes flow through product persistence
- Product service → Inventory repo: checks stock · Product availability depends on inventory
- Payment service → Payment repo: persists via · Payment records are stored separately
- Payment service → Order repo: updates · Payment completion advances order state
- Payment service → Payout service: triggers · Seller settlement is handled as a downstream concern
- Rec service → Configs: outbound client · Recommendation workflow uses REST client wiring
- Cart repo → Domain model: maps · Cart persistence is backed by domain entities
- Order repo → Domain model: maps · Order persistence is backed by domain entities
- Payment repo → Domain model: maps · Payment persistence is backed by domain entities
- Inventory repo → Domain model: maps · Inventory persistence is backed by domain entities
- Product repo → Domain model: maps · Product persistence is backed by domain entities
- Seller repo → Domain model: maps · Seller persistence is backed by domain entities
- User repo → Domain model: maps · User persistence is backed by domain entities