How preetam-90/agrkserve works
Project Type & Purpose
• Full-stack, server-rendered web application (Next.js App Router)
• Marketplace connecting farmers (“Renters”) with equipment providers and labour services
• Uses Supabase (PostgreSQL + PostGIS) as the primary backend for auth, database, storage, real-time
High-Level File Structure Analysis
• src/app/…: Next.js pages & layouts (landing, auth, dashboards for admin/provider/renter/labour)
• src/app/api/…: Next.js API route handlers (serverless functions)
• src/components/: React UI components (layout, landing sections, admin UI, messaging, notifications, primitives)
• src/lib/services/: Business-logic wrappers around Supabase & external services
• src/lib/store/: Zustand state-management stores
• supabase/migrations/: SQL scripts defining database schema & RPCs
• public/: Static assets served via CDN
• scripts/: Dev/ops helper scripts (migrations, env setup, CI)
Key Architecture & Data Flows
a. Client Browser
• Renders server- and client-side React pages via Next.js
• Fetches data over Next.js API routes or direct Supabase JS client calls
b. Next.js Server (App Router & API)
• Handles page rendering (SSR/SSG)
• Exposes REST/edge functions in src/app/api/…
• Applies middleware (auth, RLS)
c. Business Logic Layer (src/lib/services)
• Encapsulates CRUD and RPC calls to Supabase
• Implements domain services: auth-service, booking-service, media-service, notification-service, etc.
d. Supabase Backend
• PostgreSQL database with PostGIS extension
• Auth module for email/password, OAuth, phone verification, RLS policies
• Storage buckets for media uploads & chat attachments
• Realtime channels for notifications & direct messaging
e. External Integrations
• Cloudinary for advanced image/video processing (via API routes & service wrappers)
• Vercel (hosting & deployments)
Architectural Patterns & Principles
• Jamstack + SSR hybrid: static assets (public/), SSR pages, edgeless API routes
• “API-First” microservices style: each service function lives under src/app/api/…
• Layered separation: UI (components) → state-store (Zustand) → services → database
• Single codebase monorepo with clear module boundaries
• Security via middleware, RLS, separate admin API routes
• Client Browser
• Pages & UI Components
• Zustand store
• Next.js Server
• App Router (SSR & SSG)
• API Routes (serverless functions)
• Middleware (auth, RLS, error handling)
• Business Logic Services
• Auth, Booking, Payment, DM, Notification, Media Audit, etc.
• Supabase
• PostgreSQL + PostGIS
• Auth & RLS
• Storage (uploads)
• Realtime (pub/sub)
• External Services
• Cloudinary API
• Vercel CDN & Functions
• Browser → Next.js App Router (page requests)
• Browser → API Routes (XHR/fetch)
• API Routes → Business Logic → Supabase (queries, RPCs)
• Supabase Realtime → Browser (WebSocket) for notifications & chat
• API Routes ↔ Cloudinary (media operations)