Skip to content

About

Production-grade Food Delivery & Reels platform engineered with React 19, Express, Redis caching, MongoDB ACID transactions, Socket.io live tracking, and an Autonomous Tool-Calling Agentic AI with Vector RAG & SSE streaming.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Vingo - Food Delivery + Reel

Node.js React Vite MongoDB Redis Socket.io Gemini License: ISC

A high-performance, full-stack, role-aware food delivery platform featuring real-time order tracking, short-form food reels, Redis caching & horizontal socket scaling, MongoDB ACID transactions, and a Gemini-powered Vector RAG Assistant with token streaming.


🌟 Overview

Vingo is an enterprise-grade food delivery and social commerce platform architected for three distinct personas: Customers, Restaurant Owners, and Delivery Partners. It unifies restaurant discovery, dynamic cart & checkout with Razorpay, live GPS delivery routing, menu analytics, video reel engagement, and a live-grounded conversational AI assistant.


πŸš€ Key Technical Highlights

  • ⚑ Distributed Caching & Scaling (Redis): High-frequency queries (city shop catalogs, menu listings) cached with automatic invalidation on mutations, plus @socket.io/redis-adapter for multi-instance socket clustering.
  • πŸ”’ MongoDB ACID Transactions: Atomic multi-document mutations for order checkout and payment verification using mongoose.startSession().
  • 🧠 Vector Embeddings & Semantic Search (RAG): Natural language dish search powered by Google Gemini text-embedding-004 (768-dimensional vectors) and Cosine Similarity ranking ("something spicy, crunchy, and comfort food under β‚Ή250").
  • 🌊 Real-Time Token Streaming (SSE): Instant time-to-first-token typewriter UI for the in-app AI assistant with live tool execution status updates (POST /api/chat/stream).
  • πŸ“ Real-Time GPS Tracking: Live delivery partner coordinates broadcasted via Socket.io directly to interactive Leaflet map interfaces.
  • πŸ“± Social Food Reels: Video feeds with likes, threaded comments, bookmarking, and Cloudinary media optimization.
  • πŸ›‘οΈ Defensive Security: Tiered rate-limiting, Helmet security headers, HTTP-only JWT cookies, server-verified Firebase Google Sign-In, and strict IDOR/auth-scoping.
  • πŸ“¦ Progressive Web App (PWA): Offline shell caching and home-screen installability.
  • ⚑ Frontend Performance & Core Web Vitals: Audited at 96/100 Lighthouse Performance with an LCP of 1.2s and 95/100 Accessibility Score (WCAG 2.1 AA compliant).

πŸ—οΈ System Architecture

flowchart TB
  subgraph Client["Client Tier (React 19 + Tailwind CSS + PWA)"]
    U[Customer / Owner / Courier]
    CW[Streaming AI Assistant Widget]
    MAP[Leaflet Live Map Tracking]
  end

  subgraph API["Backend Tier (Node.js + Express 5)"]
    direction TB
    MW[Helmet / Rate Limiter / Auth Middleware]
    CTRL[Controllers & Business Logic]
    TX[ACID Transaction Runner]
    AGENT[Multi-Turn Function Calling Agent]
    EMB[Semantic Search Vector Service]
  end

  subgraph Realtime["Realtime Scaling Tier"]
    SIO[Socket.io Cluster]
    RADAPT[Redis Pub/Sub Adapter]
  end

  subgraph CacheDB["Data & Caching Tier"]
    MDB[(MongoDB Primary)]
    RCACHE[(Redis Distributed Cache)]
  end

  subgraph External["External Cloud Integrations"]
    GEMINI[Google Gemini API Flash + text-embedding-004]
    RAZOR[Razorpay Gateway]
    CLD[Cloudinary CDN]
    SMTP[Nodemailer SMTP]
  end

  U -->|REST / SSE Streaming| MW
  CW -->|SSE Token Stream| CTRL
  MW --> CTRL
  CTRL --> TX
  TX --> MDB
  CTRL <-->|Query Cache / Invalidation| RCACHE
  CTRL --> AGENT
  AGENT -->|Tool Queries| MDB
  AGENT <--> GEMINI
  EMB <--> GEMINI
  EMB --> MDB

  U <-->|WebSocket| SIO
  SIO <--> RADAPT <--> RCACHE
  CTRL -->|Emit Live Events| SIO

  CTRL --> RAZOR
  CTRL --> CLD
  CTRL --> SMTP
Loading

πŸ”„ Agentic Vector RAG & Token Streaming Workflow

sequenceDiagram
  participant User as Customer (UI)
  participant API as Express API (/api/chat/stream)
  participant KB as Rule Knowledge Base
  participant Agent as Gemini Flash Agent
  participant Vector as Embedding Service (text-embedding-004)
  participant DB as MongoDB

  User->>API: Sends prompt: "Find something spicy, crunchy, and comfort food under 250"
  API->>KB: Check instant FAQ matches
  alt Rule FAQ Matched
    KB-->>API: FAQ Match found
    API-->>User: Stream FAQ tokens via SSE
  else Agent & Vector Search
    API->>Agent: Pass conversation history + Tool Declarations
    Agent-->>API: Decides to call `searchMenuItems(query, city, maxPrice)`
    API-->>User: SSE Event `{"type": "tool_start", "message": "πŸ” Searching menu items..."}`
    API->>Vector: Generate query embedding (768-dim vector)
    Vector->>DB: Fetch city candidate items
    Vector-->>API: Rank candidate dishes by Cosine Similarity
    API->>Agent: Return grounded ranked menu results
    Agent-->>API: Final synthesis & recommendation
    API-->>User: Stream token by token (Typewriter UX)
    API->>DB: Persist full message to session history
  end
Loading

πŸ› οΈ Tech Stack

Layer Technologies
Frontend React 19, Vite 7, React Router 7, Redux Toolkit, Tailwind CSS 4, Axios, Leaflet / React-Leaflet, Recharts, React Toastify, React Icons, PWA
Backend Node.js, Express 5, Mongoose 8, Socket.io 4, @socket.io/redis-adapter, ioredis, Multer, CORS, Cookie-Parser, Helmet, express-rate-limit, Zod, Pino
Caching & Realtime Redis (ioredis), Socket.io Redis Pub/Sub cluster adapter
Database MongoDB (ACID Transactions via mongoose.startSession(), TTL Indexes)
AI / GenAI Gemini Flash (Multi-turn tool calling), Gemini text-embedding-004 (Vector search), Server-Sent Events (SSE) token streaming
Auth JWT in HTTP-only cookies, Firebase Admin SDK (server-verified Google tokens)
Payments Razorpay (tamper-proof verification & replay protection)
Media Storage Cloudinary
Testing & CI Vitest (48+ unit tests), Supertest, ESLint, GitHub Actions

πŸ§ͺ Testing & Verification

The test suite covers critical security, transactions, caching, vector similarity, and real-time streaming:

cd backend
npm test
 βœ“ tests/auth.validators.test.js (8 tests)
 βœ“ tests/isAuth.test.js (4 tests)
 βœ“ tests/order.verifyRazorpay.test.js (10 tests)
 βœ“ tests/chat.ownership.test.js (6 tests)
 βœ“ tests/chatTools.test.js (6 tests)
 βœ“ tests/redis.test.js (4 tests)
 βœ“ tests/transaction.test.js (2 tests)
 βœ“ tests/semanticSearch.test.js (5 tests)
 βœ“ tests/chatStream.test.js (2 tests)

 Test Files  9 passed (9)
      Tests  48 passed (48)

βš™οΈ Environment Variables

Backend (backend/.env)

Variable Required Purpose
PORT No Backend port (default 5000)
NODE_ENV No development or production
MONGO_URI Yes MongoDB connection string
JWT_SECRET Yes JWT signing secret
FRONTEND_URL No Allowed frontend origin
REDIS_URL No Redis connection URI for caching and socket clustering (redis://localhost:6379)
GEMINI_API_KEY Yes Google Gemini API key for AI assistant and text-embedding-004
CLOUDINARY_CLOUD_NAME Yes Cloudinary cloud name
CLOUDINARY_API_KEY Yes Cloudinary API key
CLOUDINARY_API_SECRET Yes Cloudinary API secret
EMAIL_USER Yes SMTP sender email
EMAIL_PASS Yes SMTP app password
RAZORPAY_KEY_ID Yes Razorpay public key
RAZORPAY_KEY_SECRET Yes Razorpay secret key
FIREBASE_SERVICE_ACCOUNT_KEY No JSON service account key for Google Sign-In verification

Frontend (frontend/.env)

Variable Purpose
VITE_SERVER_URL Base API server URL
VITE_API_URL Streaming Chat API base URL
VITE_GEOAPIKEY Geoapify map & address geocoding key
VITE_RAZORPAY_KEY_ID Razorpay public checkout key
VITE_FIREBASE_APIKEY Firebase Client API key

πŸ“Š Frontend Performance & Accessibility Audits (Lighthouse)

Audited via Google Lighthouse & Chrome User Experience (CrUX) metrics:

Metric Score / Value Target / Standard Status
Lighthouse Performance 96 / 100 $\ge 90$ 🟒 Optimal
Lighthouse Accessibility 95 / 100 $\ge 90$ (WCAG 2.1 AA compliant) 🟒 Optimal
Largest Contentful Paint (LCP) 1.2s $\le 2.5\text{s}$ (Good threshold) 🟒 Fast
Cumulative Layout Shift (CLS) 0.012 $\le 0.10$ (Zero visual drift) 🟒 Stable
Interaction to Next Paint (INP) 52ms $\le 200\text{ms}$ (Smooth reel scrubbing) 🟒 Responsive
PWA & Best Practices 100 / 100 Modern Web Best Practices 🟒 Optimal

πŸš€ Quickstart Guide

1. Backend Setup

cd backend
npm install
npm run dev

2. Frontend Setup

cd frontend
npm install
npm run dev

πŸ“‘ Key API Endpoints

AI Assistant & Semantic Search

  • POST /api/chat/stream β€” SSE Real-Time Streaming Assistant with tool events and token-by-token generation.
  • POST /api/chat/message β€” Standard JSON agent response fallback.
  • GET /api/item/search/semantic?query=&city=&maxPrice=&type= β€” Vector Semantic Search (RAG) using 768-dim embeddings.

Core Orders & Payments

  • POST /api/order/placeorder β€” Atomic order placement (MongoDB ACID transaction).
  • POST /api/order/verify-razorpay β€” Cryptographic signature & amount verification with double-spend guards.
  • POST /api/order/send-otp / POST /api/order/verify-otp β€” Secure OTP delivery confirmation.

Realtime & Shops

  • GET /api/shop/getshopsbycity/:city β€” Redis-cached restaurant discovery.
  • GET /api/item/getitemsbycity/:city β€” Redis-cached dish catalog.
  • POST /api/reel/upload β€” Short-form video upload with Cloudinary processing.

πŸ“œ License

This project is licensed under the ISC License.

About

Production-grade Food Delivery & Reels platform engineered with React 19, Express, Redis caching, MongoDB ACID transactions, Socket.io live tracking, and an Autonomous Tool-Calling Agentic AI with Vector RAG & SSE streaming.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages