# vatsalvarma/fg-test-2-pwa- architecture

> Architecture diagram of the GitHub repository vatsalvarma/fg-test-2-pwa-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vatsalvarma/fg-test-2-pwa-
- Repository: https://github.com/vatsalvarma/fg-test-2-pwa-

## Overview

1. **Overall shape**
   - This is a two-tier product: a **Spring Boot backend** and a **Next.js frontend**, packaged for local/dev and Docker-based deployment.
   - The backend owns business logic, persistence, security, integrations, and real-time messaging. The frontend is a role-based UI shell that consumes the backend API.

2. **Backend core architecture**
   - The Java backend is a layered monolith under `com.farmgearconnect`.
   - Main layers are: **controllers** for HTTP entry points, **services** for business workflows, **repositories** for database access, **entities** for JPA models, and **DTOs** for API input/output.
   - `FarmGearConnectApplication` is the Spring Boot entry point; Flyway migrations initialize and evolve the schema on startup.

3. **Primary domain boundaries**
   - The backend is organized around the product’s main business domains:
     - **Authentication & user management**
     - **Equipment marketplace**
     - **Bookings**
     - **Chat / calling / notifications**
     - **Payments / subscriptions**
     - **Admin moderation**
   - Each domain has its own controller/service/repository slice rather than a separate service process.

4. **Authentication and authorization flow**
   - Auth is JWT-based with refresh tokens, enforced by `SecurityConfig`, `JwtAuthenticationFilter`, `JwtTokenProvider`, and `CustomUserDetailsService`.
   - The auth flow likely starts at `AuthController` and `AuthService`, persists tokens and OTPs in `RefreshToken` and `OtpVerification`, and uses `User` as the principal record.
   - Role-based access is central: the UI and API both distinguish **FARMER**, **OWNER**, and **ADMIN**.

5. **Marketplace and equipment management**
   - `EquipmentController` and `EquipmentService` handle listing lifecycle: create, update, submit for approval, and image upload.
   - `Equipment`, `EquipmentImage`, and `Coupon` are key marketplace entities; `EquipmentRepository` and `EquipmentImageRepository` back the data access.
   - The public marketplace and nearby search are distinct from owner/admin listing management, which matters for diagramming boundaries.

6. **Booking workflow**
   - `BookingController` and `BookingService` coordinate the booking state machine: farmer creates a booking, owner approves/rejects, and bookings can be cancelled.
   - `Booking`, `BookingRequest`, and `BookingResponse` define the contract.
   - This domain is a core transaction boundary because it connects users, equipment, notifications, and payments.

7. **Communication and real-time features**
   - Chat and notifications are separate but related subsystems:
     - `ChatController` / `ChatService` with `Message` and `MessageRepository`
     - `NotificationController` / `NotificationService` with `Notification` and `NotificationRepository`
   - `WebSocketConfig` indicates real-time delivery via **WebSocket + STOMP**.
   - `MaskedCallingService` suggests a protected calling flow that integrates with external telephony providers without exposing phone numbers.

8. **Payments, subscriptions, and revenue**
   - `PaymentController` / `PaymentService` handle monetary workflows, especially subscriptions and deposits.
   - `Subscription`, `RefreshToken`, and `Coupon` imply recurring plan management with promo support.
   - The README references **Razorpay** as the payment provider; this is an external boundary worth showing as separate from core business data.

9. **External integrations and infrastructure**
   - `MailConfig` + `EmailService`, `SmsService`, and `StorageService` point to external services for OTP email, SMS delivery, and file storage.
   - `StorageConfig` indicates S3-compatible object storage, with the README naming **MinIO** locally and possibly AWS S3 in other environments.
   - `RestTemplateConfig` suggests synchronous outbound HTTP calls for integrations such as telephony or payment verification.

10. **Persistence model**
   - MySQL is the primary relational store, accessed through Spring Data repositories.
   - Entities include operational records (`Booking`, `Message`, `Notification`, `Review`), identity records (`User`, `RefreshToken`, `OtpVerification`), and governance records (`AuditLog`, `Subscription`).
   - `AuditLog` and the log files under `backend/logs/` show that the system captures both application logs and database-level audit history.

11. **Admin and moderation boundary**
   - `AdminController` is a separate boundary for listing approvals, user management, analytics, and moderation.
   - This is not just another UI section; it represents a privileged workflow that sits above normal farmer/owner operations.
   - In the architecture diagram, admin actions should be shown as directly acting on marketplace and user records, but through constrained endpoints and role checks.

12. **Frontend structure**
   - The frontend is a **Next.js 15 App Router** application organized by route groups and role-based areas.
   - Distinct route trees exist for **auth**, **public**, **admin**, **farmer**, **owner**, **marketplace**, and **equipment detail** pages.
   - Shared client-side layers include `src/lib/api` for backend calls, `src/lib/store` for auth state, `src/lib/i18n` for English/Telugu translations, and `ThemeProvider`/UI components for app-wide presentation.

13. **Frontend-to-backend data flow**
   - The frontend does not appear to own business state; it mainly reads/writes through Axios-based API clients in `src/lib/api`.
   - Authentication state is centralized in Zustand (`authStore`), and route-specific pages likely consume role information to render the correct experience.
   - The key data path is: browser UI → Next.js API client → Spring Boot REST API → JPA/MySQL, with WebSocket used for live events like notifications/chat.

14. **Deployment and operational boundaries**
   - `docker-compose.yml` and Dockerfiles indicate a containerized deployment that can bring up backend, frontend, MySQL, Redis, and MinIO together.
   - GitHub Actions workflows exist for frontend and deployment automation, so CI/CD is part of the repo’s operational architecture.
   - Redis is referenced in the README as a cache/auxiliary store, but it is not the primary system of record.

15. **What to emphasize in an architecture diagram**
   - Draw the backend as one monolithic application with clear internal modules, not as microservices.
   - Show the main external dependencies separately: **MySQL**, **Redis**, **MinIO/S3**, **SMTP/email**, **SMS provider**, **payment gateway**, and **telephony provider**.
   - Highlight the real-time channel (WebSocket/STOMP) as separate from normal REST traffic, since chat and notifications depend on it.

Main entry points: [`backend/src/main/java/com/farmgearconnect/service/AuthService.java`](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/AuthService.java) (Services), [`frontend/src/lib/api/client.ts`](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/lib/api/client.ts) (API Client), [`frontend/src/app/layout.tsx`](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/layout.tsx) (Next.js App), [`backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java`](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java) (Config Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_backend["Backend"]
  node_node_backend_app(("Spring Boot App<br/>entrypoint"))
  node_node_backend_security["Security<br/>authn/authz"]
  node_node_backend_auth["Auth<br/>identity workflow"]
  node_node_backend_users["Users<br/>user profile"]
  node_node_backend_marketplace["Equipment<br/>marketplace domain"]
  node_node_backend_bookings["Bookings<br/>transaction domain"]
  node_node_backend_communication["Chat & Notify<br/>realtime collaboration"]
  node_node_backend_calling["Calling<br/>telephony integration"]
  node_node_backend_payments["Payments<br/>revenue workflow"]
  node_node_backend_admin["Admin<br/>moderation boundary"]
  node_node_backend_services["Services<br/>business logic<br/>[AuthService.java]"]
  node_node_backend_repos[("Repositories<br/>data access")]
  node_node_backend_entities["Entities<br/>domain model<br/>[User.java]"]
  node_node_backend_configs["Config Layer<br/>infrastructure config"]
  node_node_backend_migrations["Migrations<br/>schema evolution"]
end

subgraph group_group_frontend["Frontend"]
  node_node_frontend_app(("Next.js App<br/>ui shell<br/>[layout.tsx]"))
  node_node_frontend_auth["Auth UI<br/>route area<br/>[page.tsx]"]
  node_node_frontend_roles["Role Areas<br/>route area<br/>[page.tsx]"]
  node_node_frontend_marketplace["Marketplace UI<br/>public browse<br/>[page.tsx]"]
  node_node_frontend_client["API Client<br/>frontend data layer<br/>[client.ts]"]
  node_node_frontend_store["Auth Store<br/>state management<br/>[authStore.ts]"]
end

subgraph group_group_infra["Infrastructure"]
  node_node_infra_db[("MySQL<br/>primary datastore<br/>[application.yml]")]
  node_node_infra_cache[("Redis<br/>auxiliary store<br/>[docker-compose.yml]")]
  node_node_infra_storage[("MinIO / S3<br/>object storage<br/>[StorageConfig.java]")]
  node_node_infra_mail["Email<br/>smtp service<br/>[MailConfig.java]"]
  node_node_infra_sms["SMS Provider<br/>external messaging<br/>[SmsService.java]"]
  node_node_infra_payment["Razorpay<br/>payment gateway"]
  node_node_infra_telephony["Telephony<br/>external calling"]
  node_node_infra_realtime{{"WebSocket/STOMP<br/>realtime transport"}}
  node_node_infra_ci["CI/CD<br/>deployment automation<br/>[nextjs.yml]"]
  node_node_infra_docker["Docker Compose<br/>local deployment<br/>[docker-compose.yml]"]
end

node_node_frontend_auth -->|"login/register"| node_node_frontend_client
node_node_frontend_roles -->|"role actions"| node_node_frontend_client
node_node_frontend_marketplace -->|"browse/book"| node_node_frontend_client
node_node_frontend_client -->|"REST"| node_node_backend_auth
node_node_frontend_client -->|"REST"| node_node_backend_marketplace
node_node_frontend_client -->|"REST"| node_node_backend_bookings
node_node_frontend_client -->|"REST"| node_node_backend_communication
node_node_frontend_store -->|"role state"| node_node_frontend_roles
node_node_backend_app -->|"bootstraps"| node_node_backend_security
node_node_backend_app -->|"runs"| node_node_backend_migrations
node_node_backend_security -->|"protects"| node_node_backend_auth
node_node_backend_security -->|"guards"| node_node_backend_admin
node_node_backend_auth -->|"uses"| node_node_backend_services
node_node_backend_users -->|"uses"| node_node_backend_services
node_node_backend_marketplace -->|"uses"| node_node_backend_services
node_node_backend_bookings -->|"uses"| node_node_backend_services
node_node_backend_communication -->|"uses"| node_node_backend_services
node_node_backend_calling -->|"uses"| node_node_backend_services
node_node_backend_payments -->|"uses"| node_node_backend_services
node_node_backend_admin -->|"uses"| node_node_backend_services
node_node_backend_services -->|"persists"| node_node_backend_repos
node_node_backend_repos -->|"maps"| node_node_backend_entities
node_node_backend_entities -->|"stored in"| node_node_infra_db
node_node_backend_services -->|"pushes events"| node_node_infra_realtime
node_node_backend_configs -->|"connects"| node_node_infra_storage
node_node_backend_configs -->|"connects"| node_node_infra_mail
node_node_backend_services -->|"sends"| node_node_infra_sms
node_node_backend_payments -->|"integrates"| node_node_infra_payment
node_node_backend_calling -->|"integrates"| node_node_infra_telephony
node_node_backend_configs -->|"configures"| node_node_infra_realtime
node_node_backend_services -.->|"optional cache"| node_node_infra_cache
node_node_frontend_app -->|"routes to"| node_node_frontend_auth
node_node_frontend_app -->|"routes to"| node_node_frontend_roles
node_node_frontend_app -->|"routes to"| node_node_frontend_marketplace
node_node_infra_docker -->|"runs"| node_node_backend_app
node_node_infra_docker -->|"runs"| node_node_frontend_app
node_node_infra_ci -.->|"ships"| node_node_infra_docker

click node_node_backend_app "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/FarmGearConnectApplication.java"
click node_node_backend_security "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/SecurityConfig.java"
click node_node_backend_auth "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/AuthController.java"
click node_node_backend_users "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/UserController.java"
click node_node_backend_marketplace "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/EquipmentController.java"
click node_node_backend_bookings "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/BookingController.java"
click node_node_backend_communication "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/ChatController.java"
click node_node_backend_calling "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/CallingController.java"
click node_node_backend_payments "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/PaymentController.java"
click node_node_backend_admin "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/AdminController.java"
click node_node_backend_services "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/AuthService.java"
click node_node_backend_repos "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/repository/UserRepository.java"
click node_node_backend_entities "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/entity/User.java"
click node_node_backend_configs "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java"
click node_node_backend_migrations "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/resources/db/migration/V1__init_schema.sql"
click node_node_frontend_app "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/layout.tsx"
click node_node_frontend_auth "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/(auth)/login/page.tsx"
click node_node_frontend_roles "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/admin/dashboard/page.tsx"
click node_node_frontend_marketplace "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/marketplace/page.tsx"
click node_node_frontend_client "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/lib/api/client.ts"
click node_node_frontend_store "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/lib/store/authStore.ts"
click node_node_infra_db "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/resources/application.yml"
click node_node_infra_cache "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/docker-compose.yml"
click node_node_infra_storage "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/StorageConfig.java"
click node_node_infra_mail "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/MailConfig.java"
click node_node_infra_sms "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/SmsService.java"
click node_node_infra_payment "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/PaymentService.java"
click node_node_infra_telephony "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/MaskedCallingService.java"
click node_node_infra_realtime "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java"
click node_node_infra_ci "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/.github/workflows/nextjs.yml"
click node_node_infra_docker "https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/docker-compose.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_backend_app,node_node_backend_security,node_node_backend_auth,node_node_backend_users,node_node_backend_marketplace,node_node_backend_bookings,node_node_backend_communication,node_node_backend_calling,node_node_backend_payments,node_node_backend_admin,node_node_backend_services,node_node_backend_repos,node_node_backend_entities,node_node_backend_configs,node_node_backend_migrations toneBlue
class node_node_frontend_app,node_node_frontend_auth,node_node_frontend_roles,node_node_frontend_marketplace,node_node_frontend_client,node_node_frontend_store toneAmber
class node_node_infra_db,node_node_infra_cache,node_node_infra_storage,node_node_infra_mail,node_node_infra_sms,node_node_infra_payment,node_node_infra_telephony,node_node_infra_realtime,node_node_infra_ci,node_node_infra_docker toneMint
```

## Components

### Backend

Spring Boot monolith with layered domain modules

- [Spring Boot App](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/FarmGearConnectApplication.java): entrypoint · Application bootstrap and startup orchestration · `backend/src/main/java/com/farmgearconnect/FarmGearConnectApplication.java`
- [Security](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/SecurityConfig.java): authn/authz · JWT authentication, refresh tokens, and role checks · `backend/src/main/java/com/farmgearconnect/config/SecurityConfig.java`
- [Auth](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/AuthController.java): identity workflow · Login, registration, verification, and token issuance · `backend/src/main/java/com/farmgearconnect/controller/AuthController.java`
- [Users](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/UserController.java): user profile · User profile and account data access · `backend/src/main/java/com/farmgearconnect/controller/UserController.java`
- [Equipment](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/EquipmentController.java): marketplace domain · Equipment lifecycle, images, and public listing flows · `backend/src/main/java/com/farmgearconnect/controller/EquipmentController.java`
- [Bookings](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/BookingController.java): transaction domain · Booking state machine and reservation workflow · `backend/src/main/java/com/farmgearconnect/controller/BookingController.java`
- [Chat & Notify](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/ChatController.java): realtime collaboration · Messages, notifications, and live delivery · `backend/src/main/java/com/farmgearconnect/controller/ChatController.java`
- [Calling](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/CallingController.java): telephony integration · Masked calling and phone privacy workflow · `backend/src/main/java/com/farmgearconnect/controller/CallingController.java`
- [Payments](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/PaymentController.java): revenue workflow · Payments, subscriptions, and coupon-supported billing · `backend/src/main/java/com/farmgearconnect/controller/PaymentController.java`
- [Admin](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/controller/AdminController.java): moderation boundary · Privileged moderation, approvals, and user management · `backend/src/main/java/com/farmgearconnect/controller/AdminController.java`
- [Services](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/AuthService.java): business logic · Core workflow layer for auth, bookings, marketplace, chat, notifications, and payments · `backend/src/main/java/com/farmgearconnect/service/AuthService.java`
- [Repositories](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/repository/UserRepository.java): data access · Spring Data persistence for domain records · `backend/src/main/java/com/farmgearconnect/repository/UserRepository.java`
- [Entities](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/entity/User.java): domain model · JPA models for users, bookings, equipment, messages, notifications, and subscriptions · `backend/src/main/java/com/farmgearconnect/entity/User.java`
- [Config Layer](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java): infrastructure config · WebSocket, storage, mail, and HTTP client configuration · `backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java`
- [Migrations](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/resources/db/migration/V1__init_schema.sql): schema evolution · Flyway schema initialization, seed data, and fixes · `backend/src/main/resources/db/migration/V1__init_schema.sql`

### Frontend

Next.js role-based UI shell

- [Next.js App](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/layout.tsx): ui shell · App Router frontend with role-based route trees · `frontend/src/app/layout.tsx`
- [Auth UI](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/(auth)/login/page.tsx): route area · Login, registration, and verification pages · `frontend/src/app/(auth)/login/page.tsx`
- [Role Areas](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/admin/dashboard/page.tsx): route area · Admin, farmer, and owner dashboards and workflows · `frontend/src/app/admin/dashboard/page.tsx`
- [Marketplace UI](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/app/marketplace/page.tsx): public browse · Public marketplace and equipment detail pages · `frontend/src/app/marketplace/page.tsx`
- [API Client](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/lib/api/client.ts): frontend data layer · Axios-based backend API access and auth-aware requests · `frontend/src/lib/api/client.ts`
- [Auth Store](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/frontend/src/lib/store/authStore.ts): state management · Centralized client auth state and role awareness · `frontend/src/lib/store/authStore.ts`

### Infrastructure

Datastores, integrations, and deployment surfaces

- [MySQL](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/resources/application.yml): primary datastore · Relational system of record for business data · `backend/src/main/resources/application.yml`
- [Redis](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/docker-compose.yml): auxiliary store · Cache and supporting runtime state · `docker-compose.yml`
- [MinIO / S3](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/StorageConfig.java): object storage · Image and file storage backing equipment media · `backend/src/main/java/com/farmgearconnect/config/StorageConfig.java`
- [Email](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/MailConfig.java): smtp service · Outbound email delivery for OTPs and account flows · `backend/src/main/java/com/farmgearconnect/config/MailConfig.java`
- [SMS Provider](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/SmsService.java): external messaging · SMS delivery for verification and notifications · `backend/src/main/java/com/farmgearconnect/service/SmsService.java`
- [Razorpay](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/PaymentService.java): payment gateway · External payment and subscription provider · `backend/src/main/java/com/farmgearconnect/service/PaymentService.java`
- [Telephony](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/service/MaskedCallingService.java): external calling · Provider used by masked calling flows · `backend/src/main/java/com/farmgearconnect/service/MaskedCallingService.java`
- [WebSocket/STOMP](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java): realtime transport · Live transport for chat and notification delivery · `backend/src/main/java/com/farmgearconnect/config/WebSocketConfig.java`
- [CI/CD](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/.github/workflows/nextjs.yml): deployment automation · GitHub Actions workflows for frontend and deployment automation · `.github/workflows/nextjs.yml`
- [Docker Compose](https://github.com/vatsalvarma/fg-test-2-pwa-/blob/main/docker-compose.yml): local deployment · Container orchestration for backend, frontend, and supporting services · `docker-compose.yml`

## Connections

- Auth UI → API Client: login/register · Auth pages submit credentials through the shared API client
- Role Areas → API Client: role actions · Dashboard areas call backend APIs for protected workflows
- Marketplace UI → API Client: browse/book · Public browsing and booking views use the API client
- API Client → Auth: REST · Frontend auth requests reach the backend auth controller
- API Client → Equipment: REST · Frontend marketplace requests reach equipment APIs
- API Client → Bookings: REST · Booking actions flow from the UI to booking APIs
- API Client → Chat & Notify: REST · Chat and notification screens fetch and mutate via APIs
- Auth Store → Role Areas: role state · Client auth state drives role-specific rendering
- Spring Boot App → Security: bootstraps · Application startup loads security and web infrastructure
- Spring Boot App → Migrations: runs · Flyway migrations run on backend startup
- Security → Auth: protects · Security config governs authentication endpoints and token handling
- Security → Admin: guards · Role-based access constrains privileged admin actions
- Auth → Services: uses · Auth controller delegates workflow logic to services
- Users → Services: uses · User profile operations are handled in the service layer
- Equipment → Services: uses · Equipment lifecycle endpoints delegate to marketplace services
- Bookings → Services: uses · Booking state transitions are orchestrated in services
- Chat & Notify → Services: uses · Chat and notification controllers use shared service workflows
- Calling → Services: uses · Masked calling is coordinated through service logic
- Payments → Services: uses · Payment endpoints delegate to billing and subscription workflows
- Admin → Services: uses · Admin moderation acts through backend services and constraints
- Services → Repositories: persists · Services read and write via Spring Data repositories
- Repositories → Entities: maps · Repositories operate on JPA entities
- Entities → MySQL: stored in · Entities are persisted in MySQL
- Services → WebSocket/STOMP: pushes events · Chat and notification services use the realtime channel
- Config Layer → MinIO / S3: connects · Storage configuration binds the app to object storage
- Config Layer → Email: connects · Mail configuration binds outbound email delivery
- Services → SMS Provider: sends · Verification and alerts can be delivered by SMS
- Payments → Razorpay: integrates · Billing workflow integrates with the payment gateway
- Calling → Telephony: integrates · Masked calling depends on an external telephony provider
- Config Layer → WebSocket/STOMP: configures · WebSocket configuration enables STOMP-based live traffic
- Services → Redis: optional cache · Redis supports auxiliary runtime state and caching
- Next.js App → Auth UI: routes to · Auth route group is part of the Next.js app
- Next.js App → Role Areas: routes to · Role dashboards are part of the Next.js app
- Next.js App → Marketplace UI: routes to · Marketplace routes are part of the Next.js app
- Docker Compose → Spring Boot App: runs · Compose brings up the backend container
- Docker Compose → Next.js App: runs · Compose brings up the frontend container
- CI/CD → Docker Compose: ships · CI/CD supports deployment and image publishing
