AI-Driven Hyper-Local Business Advisory & Concessional Financial Structuring Platform
Developed for Smart India Hackathon (SIH) | Ministry of Social Justice & Empowerment (MoSJE)
Problem Statements: PS 26091 (Hyper-Local Advisory) & PS 26092 (Scheme Matching & Channel Routing)
Gram Vyapaar is an institutional-grade digital platform designed to bridge the gap between marginalized rural micro-entrepreneurs (Scheduled Caste beneficiaries) and government-backed concessional credit schemes (NSFDC / NSKFDC).
While the government provides concessional loans covering up to 90% of project costs (with a 10% beneficiary margin contribution), rural entrepreneurs frequently struggle due to lack of localized market intelligence, financial structuring confusion, and difficulty navigating the offline Channel Finance System.
Gram Vyapaar delivers a unified solution:
- Deterministic Financial Structuring: Computes exact project costs, loan eligibility, concessional interest rates, and quarterly reducing-balance amortization schedules with statutory moratoriums.
- AI Hyper-Local Business Feasibility Advisory: Generates actionable, location-specific business feasibility reports (Market Reach, SWOT, Threats, Pricing, Underserved Niches) grounded in official scheme circulars.
- Real-Time Competitor Density Mapping: Integrates OpenStreetMap (Overpass API) to analyze local commercial saturation within a 5β10 km radius.
- Intelligent Channel Partner Routing: Directs applications to the nearest authorized State Channelizing Agencies (SCAs), Public Sector Banks (PSBs), and RRBs while automatically filtering out institutions with high Non-Performing Assets (NPAs).
- Privacy-Preserving Deduplication: Protects public funds using salted Aadhaar cryptographic hashing and PostgreSQL trigram similarity to detect duplicate applications without storing sensitive identity data.
GRAM VYAPAAR ARCHITECTURE
[ Rural Entrepreneur / CSC Operator / Channel Partner / Admin ]
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND LAYER (React 18 + Vite + TS) β
β β’ Tailwind CSS Design System (High-contrast, accessible UI) β
β β’ Multilingual Localization Engine (i18next: English & Hindi) β
β β’ Dynamic Amortization & Cashflow Visualization (Recharts) β
β β’ Geospatial Competitor & Partner Map (Leaflet / React-Leaflet) β
β β’ 1-Click Bank-Ready PDF Business Plan Generator β
βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β HTTP REST APIs
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND API (Node.js + Express + TS) β
β β’ Dual-Token Auth (15-min Access JWT + 7-day httpOnly Refresh Cookie) β
β β’ Role-Based Access Control (ENTREPRENEUR, PARTNER, ADMIN) β
β β’ Pure Deterministic Financial Math & Amortization Engine β
β β’ Overpass OpenStreetMap Geo-Density Aggregator β
β β’ Salted Aadhaar Hash + Trigram Duplicate Detection Engine β
β β’ Structured Logging (Pino) & Distributed Rate Limiting (Redis) β
βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β DATABASE LAYER β β AI & RAG ENGINE β
β β’ PostgreSQL (Neon Serverless) β β β’ Google Gemini 2.0 Flash β
β β’ Prisma ORM β β (Structured JSON Schema) β
β β’ pgvector (Embedding Search) β β β’ Grounded Fallback Engine β
β β’ pg_trgm (Fuzzy Trigram Index) β β (Zero-latency demo mode) β
ββββββββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
The core calculation strictly enforces MoSJE/NSFDC lending rules with 100% mathematical precision:
-
Project Cost =
$\text{Margin Capital} / 0.10$ -
Loan Amount =
$\text{Project Cost} \times 0.90$ -
Micro Finance Scheme (
$\text{Project Cost} \le \text{βΉ1,40,000}$ ):- Interest Rate: 6.50% p.a.
- Tenure: 36 Months (12 Quarters)
- Moratorium: 3 Months (1 Quarter principal moratorium)
-
Term Loan Scheme (
$\text{βΉ1,40,000} < \text{Project Cost} \le \text{βΉ50,00,000}$ ):- Interest Rate: 8.00% p.a.
- Tenure: 84 Months (28 Quarters)
- Moratorium: 6 Months (2 Quarters principal moratorium)
- Generates a complete quarterly reducing-balance amortization table including opening balance, principal repayment, interest component, quarterly installment, and closing balance.
- Utilizes Google Gemini 2.0 Flash with strict JSON Schema constraints.
- Injects vector-retrieved scheme chunks (
pgvector) into the context window to prevent hallucinations. - Features an integrated Grounded Fallback Engine that generates realistic, data-backed reports even during API quota exhaustion or offline hackathon demo conditions.
- Queries live Overpass API nodes (
shop=*,amenity=*,craft=*) within the applicant's village/block coordinates. - Returns real competitor density counts and map markers to calculate market saturation.
- Gracefully defaults to regional demographic baselines if external OSM servers experience latency.
- Calculates Haversine distances to nearby State Channelizing Agencies (SCAs), Public Sector Banks (PSBs), and Regional Rural Banks (RRBs).
- Automatically filters out institutions with
hasHighNPA = trueto protect applicants from disbursement stalls.
- Computes a salted cryptographic hash:
$\text{SHA256}(\text{AadhaarLast4} + \text{DOB} + \text{SALT})$ . - Uses PostgreSQL
pg_trgmfuzzy similarity across names, villages, and blocks. - Suspicious matches are routed to an administrative review queue rather than auto-rejected, preventing false positives on common rural names.
| Layer | Technologies |
|---|---|
| Frontend | React 18, TypeScript, Vite, Tailwind CSS, Lucide React, Framer Motion, Recharts, React-Leaflet, i18next, html2canvas, jsPDF |
| Backend | Node.js, Express.js, TypeScript, Prisma ORM, Zod, Argon2, JSON Web Tokens, Pino Logger, Helmet, CORS |
| Database | PostgreSQL (Neon Serverless compatible), pgvector extension, pg_trgm extension |
| Cache & Queue | Redis (Docker / Upstash compatible) for rate limiting |
| AI / ML | Google Gemini API (gemini-2.0-flash, text-embedding-004), Grounded Rule-Engine Fallback |
| Geodata | OpenStreetMap Overpass API, Leaflet Tiles |
| Testing | Vitest (Unit & Integration tests), Playwright (E2E testing) |
| DevOps | Docker, Docker Compose, GitHub Actions CI |
.
βββ backend/
β βββ prisma/
β β βββ schema.prisma # Database schema (PostgreSQL + pgvector + pg_trgm)
β β βββ seed.ts # Official NSFDC scheme data & Sunita demo persona
β βββ src/
β β βββ config/ # Environment validation, Pino logger, rate-limiter
β β βββ controllers/ # Auth, Calculator, Report, Admin, Partner, Geodata handlers
β β βββ middleware/ # JWT auth, Role-Based Access Control, Error handling
β β βββ routes/ # API route definitions
β β βββ services/
β β β βββ ai/ # Gemini Provider & Grounded Fallback Provider
β β β βββ duplicate.service.ts # Salted Aadhaar hash & trigram fuzzy matching
β β β βββ financial.service.ts # Deterministic financial math & amortization schedules
β β β βββ overpass.service.ts # OpenStreetMap Overpass API competitor client
β β β βββ rag.service.ts # pgvector semantic search over scheme documentation
β β βββ utils/ # Custom ApiError, hashing, and math helpers
β β βββ app.ts # Express application configuration
β β βββ index.ts # Server entry point
β βββ tests/
β β βββ financial.test.ts # Vitest boundary condition tests for financial engine
β β βββ health.test.ts # Health check tests
β βββ .env.example # Backend environment template
β βββ package.json
β
βββ frontend/
β βββ public/
β β βββ locales/ # English (en.json) & Hindi (hi.json) translations
β βββ src/
β β βββ components/
β β β βββ calculator/ # Interactive financial sliders & amortization tables
β β β βββ common/ # Navbar, Footer, LanguageToggle, DemoPersonaBanner
β β β βββ map/ # Leaflet OSM Competitor & Partner locator
β β β βββ pdf/ # 1-Click Bank-Ready Business Plan PDF template
β β β βββ report/ # Dynamic AI feasibility cards (SWOT, Pricing, Threats)
β β β βββ ui/ # Reusable accessible UI primitives
β β β βββ wizard/ # Multi-step intake wizard (Location, Capital, Category)
β β βββ context/ # AuthContext & LanguageContext
β β βββ hooks/ # Custom application hooks
β β βββ pages/ # LandingPage, IntakeWizard, Report, Admin, Partner Dashboards
β β βββ services/ # Axios API clients
β β βββ types/ # Shared TypeScript interfaces
β β βββ App.tsx
β β βββ main.tsx
β βββ .env.example # Frontend environment template
β βββ tailwind.config.js
β βββ vite.config.ts
β βββ package.json
β
βββ docker-compose.yml # Multi-container orchestration (Backend + Frontend + Redis)
βββ Dockerfile.backend
βββ Dockerfile.frontend
βββ README.md
- Node.js: v18.0.0 or higher
- npm: v9.0.0 or higher
- PostgreSQL Database: Neon Serverless Postgres instance (recommended) or local PostgreSQL with
vectorandpg_trgmextensions enabled.
# Clone the repository
git clone https://github.com/your-username/gram-vyapaar.git
cd gram-vyapaar
# Setup backend environment
cp backend/.env.example backend/.env
# Setup frontend environment
cp frontend/.env.example frontend/.envPORT=4000
NODE_ENV=development
FRONTEND_ORIGIN=http://localhost:5173
# Neon PostgreSQL connection string
DATABASE_URL="postgresql://user:password@ep-sample-123.ap-southeast-1.aws.neon.tech/neondb?sslmode=require"
# Auth secrets
JWT_SECRET="your-secure-jwt-secret-key-32-chars-min"
JWT_ACCESS_EXPIRES_IN="15m"
REFRESH_TOKEN_SECRET="your-secure-refresh-token-secret-key-32-chars-min"
REFRESH_TOKEN_EXPIRES_IN="7d"
REFRESH_TOKEN_COOKIE_NAME="gv_refresh_token"
# Google Gemini API key (optional β built-in fallback operates if left empty)
GEMINI_API_KEY="your-gemini-api-key"
GEMINI_MODEL="gemini-2.0-flash"
GEMINI_EMBEDDING_MODEL="text-embedding-004"
# Identity hashing salt
AADHAAR_HASH_SALT="your-custom-salt-value"
DUPLICATE_SIMILARITY_THRESHOLD="0.45"
# Geodata
OVERPASS_API_URL="https://overpass-api.de/api/interpreter"- Open your Neon SQL Editor and execute:
CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS pg_trgm;
- Run database migrations and seed official scheme data:
cd backend npm install npx prisma migrate dev --name init npm run seed
Terminal 1 (Backend API):
cd backend
npm run dev
# Server running at http://localhost:4000Terminal 2 (Frontend Client):
cd frontend
npm install
npm run dev
# Client running at http://localhost:5173docker-compose up --build# Run backend financial engine unit tests
cd backend
npx vitest run tests/financial.test.ts
# Run full backend test suite
npm test
# Verify frontend TypeScript types and build bundle
cd ../frontend
npm run buildPOST /api/auth/registerβ Register new beneficiary (with Aadhaar hash deduplication).POST /api/auth/loginβ Authenticate and issue access JWT + httpOnly refresh cookie.POST /api/auth/refreshβ Rotate refresh token and issue new access token.POST /api/auth/logoutβ Revoke active token version and clear cookies.POST /api/calculator/computeβ Pure deterministic financial calculation and amortization schedule.POST /api/applicationsβ Create business application.POST /api/reports/generate/:applicationIdβ Generate AI feasibility report.GET /api/reports/:applicationIdβ Retrieve existing feasibility report.GET /api/partners/nearbyβ Query nearby channel partners filtered by NPA status.
GET /api/admin/schemesβ View active lending schemes and interest slabs.PUT /api/admin/schemes/:idβ Update scheme interest rates, slabs, and tenures.GET /api/admin/duplicatesβ View flagged duplicate applicant review queue.POST /api/admin/duplicates/:id/resolveβ Approve or reject flagged duplicate applications.GET /api/partner/applicationsβ Channel partner incoming applications queue.PUT /api/partner/applications/:id/decisionβ Channel partner application decision (ACCEPTED / REJECTED).
For judging and evaluation, the database seed includes pre-configured personas:
| Role | Phone | Password | Description |
|---|---|---|---|
| Entrepreneur | 9999900001 |
Demo@12345 |
"Sunita" β Dairy Entrepreneur persona with pre-generated report |
| Channel Partner | 9999900002 |
Partner@12345 |
Branch Manager at State Channelizing Agency (SCA) |
| Administrator | 9999900003 |
Admin@12345 |
MoSJE Department Administrator |
Note: Clicking "See a sample report" on the landing page loads the complete Sunita feasibility report instantly without requiring login or live API connectivity.
This project is developed for the Smart India Hackathon 2026 under the Ministry of Social Justice & Empowerment (MoSJE). Distributed under the MIT License.