Skip to content

techySPHINX/Nivesh

Repository files navigation

Nivesh β€” Your AI Financial Strategist

AI-Native Financial Reasoning Platform - Democratizing intelligent financial planning through explainable AI

License Tech Stack Status Documentation

⚠️ IMPORTANT LEGAL NOTICE

THIS IS PROPRIETARY SOFTWARE - ALL RIGHTS RESERVED

  • 🚫 NO LICENSE IS GRANTED for any use without explicit written permission
  • πŸ“– VIEWING ONLY: You may view the source code for educational reference ONLY
  • πŸ’Ό COMMERCIAL LICENSE REQUIRED: Contact jaganhotta357@outlook.com for licensing
  • βš–οΈ LEGAL CONSEQUENCES: Unauthorized use will result in civil and criminal prosecution
  • πŸ“œ Read Full Terms: See LICENSE file for complete legal agreement

To use this software for ANY purpose (personal, commercial, research), you MUST obtain a written license.


🎯 Vision

Nivesh is not a fintech app with AI features β€” it is an AI reasoning system with fintech data connectors.

Core Philosophy

Financial Data β†’ Structured Knowledge Graph
     ↓
Knowledge Graph β†’ AI Reasoning Layer
     ↓
Reasoning β†’ Simulations + Explanations
     ↓
Output β†’ Conversational, Visual, Voice-First Insights

Mission: Enable users to confidently answer:

  • "Can I afford this?"
  • "What should I do next?"
  • "What happens if I choose option A vs B?"
  • "Am I on track for my life goals?"

Positioning: From dashboards to decision-making. Nivesh is financial reasoning + strategic planning on real user data.


πŸ“š Table of Contents


πŸš€ Quick Start

New to Nivesh? Get started in under 10 minutes:

πŸ‘‰ SETUP.md - Follow this guide to:

  • Install prerequisites (Node.js, Docker)
  • Start all services (Postgres, Neo4j, Redis)
  • Run database migrations
  • Make your first API call
  • Troubleshoot common issues

After setup, dive deeper:


✨ Features

πŸ€– AI-Powered Financial Intelligence

  • Natural Language Understanding - Ask questions in plain English/Hindi
  • Context-Aware Reasoning - Understands your complete financial situation via graph database
  • Explainability-First - Every recommendation includes assumptions, alternatives, and risks
  • Multi-Modal Interface - Text, voice, and visual interactions

πŸ“Š Comprehensive Financial Analysis

  • Income & Expense Tracking - Automated categorization with anomaly detection (LSTM)
  • Investment Portfolio Management - Multi-asset class tracking and optimization
  • Goal-Based Planning - Retirement, education, home purchase with milestone tracking
  • Life Event Modeling - Marriage, children, relocation financial impact analysis

🧠 Advanced Capabilities

  • Graph-Based Reasoning - Neo4j powered financial relationship mapping
  • Monte Carlo Simulations - 10,000+ scenario probability analysis for projections
  • Risk Profiling - XGBoost-based risk assessment and tolerance matching
  • Real-Time Insights - Kafka event-driven architecture for instant updates

πŸ”’ Privacy & Compliance

  • GDPR Compliant - User data ownership and export capabilities
  • RBI/SEBI Ready - Designed for Indian financial regulatory requirements
  • Explainable Decisions - Full audit trail (7-year retention) for every AI recommendation
  • Consent Management - Granular data access controls

🎯 Key Differentiators

βœ… Real financial data ingestion via Fi MCP
βœ… AI financial reasoning layer (not just analytics)
βœ… Scenario simulation engine for what-if analysis
βœ… Privacy & portability as user-owned insights
βœ… Optional future: Financial Digital Twin


πŸ—οΈ Architecture

High-Level System Architecture (End-to-End)

From Approved Mermaid Diagrams - Complete Data Flow:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    NIVESH AI PLATFORM                            β”‚
β”‚                                                                  β”‚
β”‚  User (App/Web/Voice) β†’ Frontend UI (Chat + Dashboard + Sims)   β”‚
β”‚                              ↓                                   β”‚
β”‚                      Firebase Auth                               β”‚
β”‚                              ↓                                   β”‚
β”‚                   API Gateway (Kong OSS)                         β”‚
β”‚                              ↓                                   β”‚
β”‚         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚         ↓                                          ↓             β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚   β”‚  Fi MCP      β”‚                      β”‚    NestJS    β”‚        β”‚
β”‚   β”‚  Server      β”‚                      β”‚   Backend    β”‚        β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚          β”‚                                     β”‚                β”‚
β”‚          ↓                                     ↓                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚   β”‚     Data     β”‚                      β”‚  PostgreSQL  β”‚        β”‚
β”‚   β”‚Normalization β”‚                      β”‚(Source Truth)β”‚        β”‚
β”‚   β”‚+ Enrichment  β”‚                      β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                             β”‚                β”‚
β”‚          β”‚                                     β”‚                β”‚
β”‚          ↓                                     ↓                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚   β”‚  Feature Store       │◄──────────── Kafka Event   β”‚        β”‚
β”‚   β”‚  (Neo4j Graph +      β”‚            β”‚     Bus       β”‚        β”‚
β”‚   β”‚   Firestore/Redis)   β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚                β”‚
β”‚          β”‚                                     β”‚                β”‚
β”‚          ↓                                     ↓                β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚   β”‚   AI Orchestrator    β”‚            β”‚   MongoDB     β”‚        β”‚
β”‚   β”‚                      β”‚            β”‚  (Chat Logs)  β”‚        β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β”‚  β”‚ Local LLM     β”‚   β”‚                    β”‚                β”‚
β”‚   β”‚  β”‚(LLaMA3/Mistr) β”‚   β”‚                    ↓                β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚   β”‚          β”‚            β”‚            β”‚  ClickHouse   β”‚        β”‚
β”‚   β”‚          ↓            β”‚            β”‚  (Analytics)  β”‚        β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β”‚  β”‚  Tool Router  β”‚   β”‚                                     β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚                                     β”‚
β”‚   β”‚          β”‚            β”‚                                     β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                             β”‚
β”‚   β”‚  β”‚                           β”‚                             β”‚
β”‚   β”‚  ↓               ↓           ↓         ↓                   β”‚
β”‚   β”‚ Finance      Category    Anomaly    Risk      Personalize  β”‚
β”‚   β”‚ Engine      Model       Detection  Profile    Engine       β”‚
β”‚   β”‚(Simulations) (XGBoost)  (Prophet)  (XGBoost) (Ranker)     β”‚
β”‚   β”‚              (BERT)     (IsoForest)                        β”‚
β”‚   β”‚  β”‚               β”‚           β”‚         β”‚          β”‚        β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚   β”‚                      β”‚                                     β”‚
β”‚   β”‚                      ↓                                     β”‚
β”‚   β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                             β”‚
β”‚   β”‚              β”‚   Response    β”‚                             β”‚
β”‚   β”‚              β”‚   Builder     β”‚                             β”‚
β”‚   β”‚              β”‚(Charts+Actions)β”‚                            β”‚
β”‚   β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                             β”‚
β”‚   β”‚                      β”‚                                     β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚                          ↓                                      β”‚
β”‚                      UI Output                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Why This Architecture?

Design Decision Rationale Technology Choice
Graph-First Feature Store Financial reasoning requires relationship traversal ("How does X affect Y?") Neo4j for complex graph queries
Hybrid AI (LLM + Logic) LLMs explain, deterministic code calculates - avoids hallucination in finance LLaMA-3-8B + Mistral-7B (local) + NumPy/SciPy
Tool Router Pattern Specialized models (categorization, anomaly, risk) are better than one LLM FastAPI microservices architecture
Event-Driven Pipeline Real-time sync from transactions β†’ enrichment β†’ graph without blocking API Kafka for async data flow
Polyglot Persistence Each data type in optimal DB (relations in Postgres, graphs in Neo4j, docs in MongoDB) PostgreSQL + Neo4j + MongoDB + ClickHouse
Explainability-First Every recommendation must be auditable for RBI/SEBI compliance MongoDB audit logs + decision trace IDs

πŸ› οΈ Tech Stack

Complete Technology Breakdown

Frontend Layer

Technology Purpose Why Where Used
React Native Mobile app (iOS/Android) Cross-platform, native performance Chat interface, dashboard, goal tracking
Next.js 14 Web app with SSR SEO-friendly, fast page loads Public website, web chat, simulations
Recharts Data visualization React-native charts library Financial charts, goal progress, trends
Firebase Auth Authentication Free tier, phone OTP, OAuth Sign-up, login, session management

Backend Layer

Technology Purpose Why Where Used
NestJS REST API server TypeScript, modular, enterprise-grade CRUD operations, user management, Fi MCP sync
FastAPI AI/ML microservice Async Python, automatic OpenAPI docs AI orchestrator, tool router, ML inference
Kong OSS API Gateway Rate limiting, JWT validation, routing Centralized entry point for all APIs
gRPC Inter-service communication Binary protocol, low latency NestJS ↔ FastAPI communication

AI & Machine Learning Stack

Technology Purpose Why Where Used
LLaMA-3-8B-Instruct Primary LLM (Local) Best finance reasoning, fits 8GB VRAM Natural language Q&A, explanation generation
Mistral-7B-Instruct Fallback LLM (Local) Fast, concise financial reasoning Backup model, numerical explanations
Ollama Local LLM Runtime 100% free, local, GPU-accelerated Serves both LLaMA-3 and Mistral models
XGBoost Risk scoring, categorization Explainable, fast, production-ready Transaction categorization, risk profiling
Prophet Time-series forecasting Handles seasonality, missing data Income growth, expense trends, inflation
IsolationForest Anomaly detection Unsupervised, works with high dimensions Fraud detection, unusual spending alerts
Sentence-Transformers Embeddings Open-source semantic search Chat history search, similar scenario matching
XLM-RoBERTa Multilingual sentiment Supports Hindi + 100 languages Detect financial anxiety, adjust tone
LangChain LLM orchestration Tool calling, prompt templates, memory AI orchestrator, RAG pipeline

Database Layer (Polyglot Persistence)

Technology Purpose Why Data Flow
Neo4j Community Graph DB (Feature Store) Financial relationship reasoning via Cypher Fi MCP β†’ Enrichment β†’ Neo4j β†’ AI Orchestrator
PostgreSQL 15+ Relational DB (Source of Truth) ACID compliance, audit trail Fi MCP β†’ API Gateway β†’ PostgreSQL
Firestore Real-time feature store Low-latency reads for ML models Enrichment Layer β†’ Firestore β†’ AI Orchestrator
Redis 7+ Cache + Session Store Sub-millisecond latency, pub/sub Session tokens, feature caching
MongoDB Document store Flexible schema for AI logs, conversations AI Orchestrator β†’ Response Builder β†’ MongoDB
ClickHouse Time-series analytics Columnar storage, fast aggregations PostgreSQL β†’ ETL β†’ ClickHouse (OLAP)
MinIO Object storage S3-compatible, self-hosted User reports (PDFs), model artifacts

Event Streaming & Data Pipeline

Technology Purpose Why Where Used
Apache Kafka Event streaming backbone Distributed, durable, high-throughput Fi MCP β†’ Kafka β†’ All downstream services
Kafka Connect Database connectors No-code CDC (Change Data Capture) PostgreSQL β†’ Kafka β†’ Neo4j sync
Avro Schema registry Strongly-typed events, schema evolution Transaction events, simulation events
Debezium PostgreSQL CDC Real-time sync OLTP β†’ OLAP PostgreSQL changes β†’ Kafka β†’ ClickHouse

Infrastructure & DevOps

Technology Purpose Why Where Used
Docker Containerization Reproducible builds, isolation All services containerized
Kubernetes Container orchestration Auto-scaling, self-healing, declarative Production deployments (V1 phase)
Prometheus Metrics & monitoring Time-series metrics, alerting System health, API latency, DB performance
Grafana Observability dashboards Rich visualizations, multi-source support Real-time monitoring, SLA tracking
OpenTelemetry Distributed tracing Trace requests across microservices Debug latency, track AI decision paths

Technology Selection Philosophy

βœ… 100% Open Source - No vendor lock-in, community-driven
βœ… Cloud-Agnostic - Deploy on AWS, GCP, Azure, or on-premise
βœ… Production-Grade - Battle-tested at scale by industry leaders
βœ… Compliance-Ready - GDPR, RBI, SEBI audit requirements built-in
βœ… Free Tiers Available - Firebase Auth, Local LLMs (free), Firestore free quotas βœ… 100% Local AI - LLaMA-3 & Mistral-7B run locally via Ollama, no API costs

All technologies chosen are either free/open-source or have generous free tiers for MVP phase


πŸ“ Project Structure

nivesh/
β”‚
β”œβ”€β”€ apps/                                      # Application Services
β”‚   β”œβ”€β”€ backend-nest/                          # NestJS API Server
β”‚   β”‚   └── src/
β”‚   β”‚       β”œβ”€β”€ modules/
β”‚   β”‚       β”‚   β”œβ”€β”€ auth/                      # Firebase Auth
β”‚   β”‚       β”‚   β”œβ”€β”€ transactions/              # Fi MCP Data Ingestion
β”‚   β”‚       β”‚   β”œβ”€β”€ graph/                     # Neo4j Feature Store
β”‚   β”‚       β”‚   β”œβ”€β”€ kafka/                     # Event Streaming
β”‚   β”‚       β”‚   └── audit/                     # Explainability Logs
β”‚   β”‚
β”‚   β”œβ”€β”€ ai-engine/                             # FastAPI ML Service
β”‚   β”‚   └── src/
β”‚   β”‚       β”œβ”€β”€ orchestrator/                  # AI Orchestrator (Mermaid Diagram 2)
β”‚   β”‚       β”œβ”€β”€ tools/
β”‚   β”‚       β”‚   β”œβ”€β”€ router.py                  # Tool Router
β”‚   β”‚       β”‚   β”œβ”€β”€ simulation/                # Finance Engine (Monte Carlo)
β”‚   β”‚       β”‚   β”œβ”€β”€ categorization/            # Txn Categorization (XGBoost+BERT)
β”‚   β”‚       β”‚   β”œβ”€β”€ anomaly/                   # Anomaly Detection (IsolationForest)
β”‚   β”‚       β”‚   β”œβ”€β”€ risk/                      # Risk Profiling (XGBoost)
β”‚   β”‚       β”‚   └── personalization/           # Recommendation Engine (Ranker)
β”‚   β”‚       β”œβ”€β”€ llm/                           # Local LLM Integration (LLaMA-3/Mistral-7B via Ollama)
β”‚   β”‚       β”œβ”€β”€ enrichment/                    # Data Enrichment Layer
β”‚   β”‚       └── response_builder/              # Charts + Actions Generator
β”‚   β”‚
β”‚   └── frontend/                              # Next.js Web + React Native Mobile
β”‚       └── src/
β”‚           β”œβ”€β”€ pages/                         # Next.js Pages
β”‚           β”œβ”€β”€ components/                    # Chat UI, Dashboard, Simulations
β”‚           └── lib/                           # API Client, Firebase Auth
β”‚
β”œβ”€β”€ libs/                                      # Shared Libraries
β”‚   β”œβ”€β”€ proto/                                 # gRPC/Kafka Avro Schemas
β”‚   β”œβ”€β”€ compliance/                            # RBI/GDPR Rules Engine
β”‚   └── prompts/                               # LLM Prompt Templates
β”‚
β”œβ”€β”€ infra/                                     # Infrastructure as Code
β”‚   β”œβ”€β”€ docker/
β”‚   β”‚   └── docker-compose.yml                 # Local Dev Stack (11 services)
β”‚   β”œβ”€β”€ kubernetes/                            # K8s Manifests (Production)
β”‚   └── terraform/                             # Cloud Provisioning (AWS/GCP/Azure)
β”‚
β”œβ”€β”€ data/                                      # Data Assets
β”‚   β”œβ”€β”€ models/                                # ML Models (.pkl files)
β”‚   β”‚   β”œβ”€β”€ xgboost_risk.pkl                   # Risk Profiling
β”‚   β”‚   β”œβ”€β”€ xgboost_category.pkl               # Transaction Categorization
β”‚   β”‚   └── isolation_forest.pkl               # Anomaly Detection
β”‚   β”œβ”€β”€ embeddings/                            # Sentence Transformers
β”‚   └── migrations/                            # Database Migrations
β”‚       β”œβ”€β”€ postgres/                          # SQL Scripts
β”‚       β”œβ”€β”€ neo4j/                             # Cypher Scripts
β”‚       └── clickhouse/                        # ClickHouse Tables
β”‚
β”œβ”€β”€ docs/                                      # Documentation
β”‚   β”œβ”€β”€ TECH_STACK.md                          # Technology Stack Details
β”‚   β”œβ”€β”€ DATABASE_STRATERGY.md                  # Polyglot Persistence Strategy
β”‚   β”œβ”€β”€ STRUCTURE.md                           # Monorepo Organization
β”‚   β”œβ”€β”€ CONTAINERIZATION.md                    # Docker Architecture
β”‚   β”œβ”€β”€ LLM_GUIDE.md                           # LLM Integration Guide
β”‚   └── GUARDRAILS_SAFEGUARDS.md               # AI Safety Architecture
β”‚
β”œβ”€β”€ Mermaid codes.md                           # Approved Architecture Diagrams
β”œβ”€β”€ NIVESH.md                                  # Technical Vision Document
β”œβ”€β”€ PRD.md                                     # Product Requirements Document
β”œβ”€β”€ REQUIREMENTS.md                            # Lean Canvas - Business Model
β”œβ”€β”€ README.md                                  # This File
└── docker-compose.yml                         # Quick Start Configuration

Architecture Mapping (Code ↔ Mermaid Diagrams)

Mermaid Component Codebase Location Technology
Fi MCP Server apps/backend-nest/src/modules/mcp/ NestJS + Fi MCP SDK
Data Normalization apps/ai-engine/src/enrichment/ Python Pandas + Kafka
Feature Store (Neo4j) apps/backend-nest/src/modules/graph/ Neo4j Bolt Driver
AI Orchestrator apps/ai-engine/src/orchestrator/ FastAPI + LangChain
Local LLM apps/ai-engine/src/llm/llm_client.py LLaMA-3-8B / Mistral-7B via Ollama
Tool Router apps/ai-engine/src/tools/router.py FastAPI Router
Finance Engine apps/ai-engine/src/tools/simulation/ NumPy + SciPy
Txn Categorization apps/ai-engine/src/tools/categorization/ XGBoost + BERT
Anomaly Detection apps/ai-engine/src/tools/anomaly/ IsolationForest+Prophet
Risk Profiling apps/ai-engine/src/tools/risk/ XGBoost
Personalization Engine apps/ai-engine/src/tools/personalization/ LightGBM Ranker
Response Builder apps/ai-engine/src/response_builder/ Jinja2 + Plotly

οΏ½ How Nivesh Works - Query Flow

Example: "Can I afford a β‚Ή50L home loan?"

Step-by-Step Flow (From Mermaid Diagram 2):

1. User Input β†’ Chat UI
   ↓
2. Chat UI β†’ API Gateway (Kong) [JWT validation]
   ↓
3. API Gateway β†’ AI Orchestrator (FastAPI)
   ↓
4. Orchestrator β†’ Feature Store (Neo4j)
   β€’ Query: MATCH (u:User {id: $userId})-[:EARNS]->(income)
   β€’ Fetch: Current income, expenses, existing EMIs, net worth
   ↓
5. Orchestrator β†’ Local LLM (LLaMA-3-8B via Ollama)
   β€’ Prompt: "User asks: 'Can I afford β‚Ή50L loan?'"
   β€’ Context: {income: β‚Ή80K/mo, expenses: β‚Ή45K/mo, existing_emi: β‚Ή8K/mo}
   β€’ Request: Extract intent + missing parameters
   ↓
6. LLM Response:
   {
     "intent": "HOUSE_AFFORDABILITY",
     "missing_params": ["loan_tenure", "interest_rate", "down_payment"],
     "confidence": 0.94
   }
   ↓
7. Orchestrator β†’ UI: "What's your preferred loan tenure?"
   ↓
8. User: "20 years, 8.5% interest, β‚Ή10L down payment"
   ↓
9. Orchestrator β†’ Tool Router
   β€’ Route: simulation/loan_affordability
   ↓
10. Tool Router β†’ Finance Engine
    β€’ Calculate: EMI = β‚Ή34,500/mo for β‚Ή40L (after down payment)
    β€’ Cashflow: β‚Ή80K - β‚Ή45K - β‚Ή8K - β‚Ή34,500 = -β‚Ή7,500 (NEGATIVE)
    ↓
11. Finance Engine β†’ Orchestrator
    {
      "affordable": false,
      "monthly_surplus": -7500,
      "recommended_action": "Increase income OR reduce loan amount"
    }
    ↓
12. Orchestrator β†’ Local LLM (Explanation)
    β€’ Prompt: "Explain why β‚Ή50L loan is not affordable"
    β€’ Context: {emi: β‚Ή34,500, surplus: -β‚Ή7,500}
    ↓
13. LLM Response:
    "Based on your β‚Ή80K monthly income and β‚Ή45K expenses, a β‚Ή50L loan
     would result in a β‚Ή34,500 EMI, leaving you β‚Ή7,500 short each month.

     Alternatives:
     1. Increase down payment to β‚Ή20L (EMI becomes β‚Ή25,800 - AFFORDABLE)
     2. Extend tenure to 25 years (EMI becomes β‚Ή31,200 - STILL TIGHT)
     3. Look for β‚Ή40L loan instead (EMI β‚Ή27,600 - COMFORTABLE)

     Assumptions:
     β€’ Interest rate: 8.5%
     β€’ No change in income/expenses
     β€’ Emergency fund: β‚Ή5K/month recommended"
    ↓
14. Orchestrator β†’ Response Builder
    β€’ Generate: Chart showing EMI vs Income breakdown
    β€’ Action buttons: ["Adjust Loan Amount", "Add Goal", "Export Report"]
    ↓
15. Response Builder β†’ UI
    {
      "text": "...",
      "charts": [income_breakdown_chart, emi_comparison_chart],
      "actions": ["adjust_loan", "add_goal", "export_pdf"],
      "decision_trace_id": "DT-2026-01-16-001",
      "confidence": 0.94
    }
    ↓
16. UI β†’ User (Final Output)

Key Technologies in This Flow

Step Technology Used Why
1-2 Next.js + Firebase Auth Secure authentication, session management
3 Kong API Gateway Rate limiting, JWT validation, routing
4 Neo4j Cypher Queries Fast relationship traversal for user context
5-6 LLaMA-3-8B-Instruct (Local LLM) Intent detection, parameter extraction
9-10 Python NumPy/SciPy (Finance Engine) Deterministic EMI calculation (no hallucination risk)
12-13 LLaMA-3 / Mistral-7B (Explanation) Natural language explanation with alternatives
14 Jinja2 + Plotly Response formatting with charts
16 MongoDB (Audit Log) Store decision trace for explainability/compliance

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn
  • Python 3.11+
  • Docker & Docker Compose
  • Git

Quick Start (Recommended - One Command)

# Clone the repository
git clone https://github.com/techySPHINX/Nivesh.git
cd nivesh

# Start all 11 services with Docker Compose
docker-compose up -d

# Wait for services to initialize (~2 minutes)
# Watch logs: docker-compose logs -f

# Access the services
# Frontend:        http://localhost:3000
# Backend API:     http://localhost:3001/api
# AI Engine:       http://localhost:8000/docs
# Neo4j Browser:   http://localhost:7474 (user: neo4j, pass: changeme)
# Kafka UI:        http://localhost:8080
# Grafana:         http://localhost:3001 (user: admin, pass: admin)

What Docker Compose Starts:

  1. frontend - Next.js web app
  2. backend-nest - NestJS API server
  3. ai-engine - FastAPI ML service
  4. postgres - PostgreSQL (source of truth)
  5. neo4j - Graph database (feature store)
  6. redis - Cache + session store
  7. mongodb - Conversation logs
  8. kafka - Event streaming
  9. clickhouse - Analytics database
  10. kong - API gateway
  11. minio - Object storage

Manual Setup (For Development)

# 1. Install backend dependencies
cd apps/backend-nest
npm install
cp .env.example .env
npm run start:dev

# 2. Install AI engine dependencies (separate terminal)
cd apps/ai-engine
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
uvicorn main:app --reload --port 8000

# 3. Install frontend dependencies (separate terminal)
cd apps/frontend
npm install
cp .env.example .env.local
npm run dev

Environment Configuration

Copy .env.example to .env and configure:

# Database Connections
POSTGRES_URI=postgresql://nivesh_user:secure_password@localhost:5432/nivesh_db
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=changeme
MONGODB_URI=mongodb://localhost:27017/nivesh_conversations
REDIS_URL=redis://localhost:6379
CLICKHOUSE_URL=http://localhost:8123

# AI Services - Local LLM (no API keys needed!)
LLM_OLLAMA_BASE_URL=http://localhost:11434
LLM_PRIMARY_MODEL=llama3:8b-instruct-q4_K_M
LLM_FALLBACK_MODEL=mistral:7b-instruct-q4_K_M

# Kafka Configuration
KAFKA_BROKERS=localhost:9092
KAFKA_TOPIC_TRANSACTIONS=nivesh.transactions
KAFKA_TOPIC_ALERTS=nivesh.alerts

# Authentication
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_AUTH_DOMAIN=nivesh-app.firebaseapp.com
JWT_SECRET=your_secure_jwt_secret_here

# Fi MCP Configuration
FI_MCP_API_KEY=your_fi_mcp_api_key
FI_MCP_WEBHOOK_SECRET=your_webhook_secret

# Storage
MINIO_ENDPOINT=localhost:9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET=nivesh-reports

Verify Installation

# Check all services are running
docker-compose ps

# Test backend API
curl http://localhost:3001/api/health

# Test AI engine
curl http://localhost:8000/health

# Test Neo4j connection
docker exec -it nivesh-neo4j cypher-shell -u neo4j -p changeme "MATCH (n) RETURN count(n);"

OPENAI_API_KEY=your_openai_api_key

Kafka

KAFKA_BROKERS=localhost:9092

Auth

KEYCLOAK_URL=http://localhost:8080


---

## πŸ“– Documentation

Comprehensive documentation is available in the [/docs](docs/) directory:

| Document                                                      | Description                                       | What You'll Learn                                        |
| ------------------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------------- |
| **[PRD.md](PRD.md)**                                          | Product Requirements Document                     | Vision, user personas, value proposition, roadmap        |
| **[TECH_STACK.md](docs/TECH_STACK.md)**                       | Complete Technology Stack                         | Every technology, why we use it, where it's used         |
| **[STRUCTURE.md](docs/STRUCTURE.md)**                         | Monorepo Structure                                | Folder organization, code-to-architecture mapping        |
| **[DATABASE_STRATERGY.md](docs/DATABASE_STRATERGY.md)**       | Polyglot Persistence Architecture                 | Database schemas, graph modeling, data flow              |
| **[CONTAINERIZATION.md](docs/CONTAINERIZATION.md)**           | Docker Architecture                               | Container setup, docker-compose, networking              |
| **[KUBERNETES.md](docs/KUBERNETES.md)**                       | Kubernetes Deployment Guide                       | K8s manifests, production deployment                     |
| **[LLM_GUIDE.md](docs/LLM_GUIDE.md)**                         | LLM Integration Guide                             | Prompt engineering, RAG, graph reasoning                 |
| **[GUARDRAILS_SAFEGUARDS.md](docs/GUARDRAILS_SAFEGUARDS.md)** | AI Safety & Compliance                            | Pre/post-LLM filters, refusal logic, content moderation  |

**All documentation is:**
- βœ… Aligned with approved Mermaid architecture diagrams
- βœ… Synchronized with open-source technology choices
- βœ… Production-ready with compliance considerations (RBI/SEBI/GDPR)
- βœ… Continuously updated with implementation progress
- βœ… Cleaned up - removed duplicate and obsolete files



---

## πŸ—ΊοΈ Roadmap

### Phase 1: MVP (8-10 weeks) β€” Q1 2026 βœ…

**Focus:** Core conversations + simulations + explainability

- [x] Architecture documentation (HLD/LLD)
- [x] Technology stack finalization
- [x] Database schema design (PostgreSQL + Neo4j)
- [x] Docker containerization setup
- [x] Mermaid architecture diagrams (stakeholder approved)
- [x] Proprietary license implementation
- [x] Documentation cleanup and organization
- [ ] Core backend implementation (NestJS + FastAPI)
- [ ] AI Orchestrator + Tool Router
- [ ] Finance simulation engine
- [ ] Neo4j graph integration
- [ ] Net worth dashboard
- [ ] Simulations: Retirement, Home Loan, SIP
- [ ] Explainability module
- [ ] Export: CSV/PDF reports
- [ ] Basic anomaly alerts

**Target:** 50-100 beta users, internal testing

---

### Phase 2: V1 (12-16 weeks) β€” Q2 2026

**Focus:** Retention + depth via goal engine + investment advisor

- [ ] Goal planning engine (home, retirement, education)
- [ ] Investment strategy advisor + rebalancing
- [ ] Advanced anomaly detection (LSTM models)
- [ ] Voice support (English + Hindi)
- [ ] Premium tier monetization
- [ ] Kubernetes deployment
- [ ] Mobile app (iOS/Android)

**Target:** 2,000-5,000 early adopters

---

### Phase 3: V2 (6+ months) β€” Q3-Q4 2026

**Focus:** Global expansion + Digital Twin + Life Events

- [ ] Life Events mode (job switch, marriage, kids, relocation)
- [ ] Multi-country personalization (tax/inflation/currency)
- [ ] Financial digital twin (behavioral modeling)
- [ ] B2B version for banks/neo-banks
- [ ] Multi-region deployment
- [ ] Advanced ML models

**Target:** 50,000+ users, international expansion

---

## 🀝 Contributing

We welcome contributions! Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting PRs.

### Development Workflow

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Code Standards

- **TypeScript** for backend (NestJS)
- **Python 3.11+** for AI services
- **ESLint** & **Prettier** for code formatting
- **Jest** for testing
- **Conventional Commits** for commit messages

**Contributing Policy:**
- 🚫 **No Pull Requests Accepted** without prior written permission
- πŸ“§ **Contact First**: Email jaganhotta357@outlook.com to discuss contributions
- πŸ“œ **CLA Required**: All contributors must sign a Contributor License Agreement
- βš–οΈ **Proprietary Code**: All contributions become property of the Licensor

---

## πŸ”’ Security

Security is paramount for financial applications.

**Security Vulnerability Reporting:**
- **Email**: jaganhotta357@outlook.com
- **Subject**: [NIVESH SECURITY] Vulnerability Report
- **Response Time**: 5-7 business days
- **Responsible Disclosure**: We follow a 90-day disclosure timeline

We follow:

- **OWASP Top 10** security practices
- **SOC 2** compliance standards (planned)
- **Regular security audits**
- **Dependency scanning** with Snyk
- **Secrets management** with HashiCorp Vault

**Security Notice**: This software handles sensitive financial data. Unauthorized deployment or use may expose you to significant security and liability risks.

---

## πŸ“„ License

**PROPRIETARY SOFTWARE - ALL RIGHTS RESERVED**

Copyright Β© 2026 Prateek (techySPHINX). All Rights Reserved.

This software is licensed under a **Proprietary Software License Agreement**.

### Quick Summary (NOT LEGAL ADVICE):

- ❌ **NO LICENSE** is granted for any use without written permission
- πŸ“– **Viewing Only**: You may view source code for educational purposes ONLY
- 🚫 **No Copying**: You may NOT copy, fork, clone, download, or use this software
- 🚫 **No Commercial Use**: Any commercial use is strictly prohibited
- 🚫 **No Personal Projects**: Personal use requires a license
- πŸ’Ό **License Required**: Contact jaganhotta357@outlook.com for licensing
- βš–οΈ **Legal Action**: Violations will result in civil and criminal prosecution
- πŸ’° **Damages**: Up to $150,000 per violation under copyright law

### To Use This Software:

1. **Contact**: jaganhotta357@outlook.com
2. **Subject**: "Nivesh Commercial License Request"
3. **Obtain**: Written Commercial License Agreement
4. **Pay**: Applicable licensing fees
5. **Comply**: With all license terms

**See the full [LICENSE](LICENSE) file for complete legal terms and conditions.**

**Unauthorized use of this software constitutes copyright infringement and may result in:**
- Civil liability (damages, injunctions, legal fees)
- Criminal prosecution
- Permanent blacklisting from future licenses
- Public disclosure of violation

---

## πŸ™ Acknowledgments

- **Open Source Community** for amazing tools
- **Neo4j** for graph database technology
- **Meta AI** for LLaMA-3 open-source LLM
- **Mistral AI** for Mistral-7B open-source LLM
- **Ollama** for local LLM runtime
- **Apache Foundation** for Kafka
- **CNCF** for cloud-native technologies

---

## πŸ“ž Contact & Support

- **Repository:** [github.com/techySPHINX/Nivesh](https://github.com/techySPHINX/Nivesh)
- **Project Lead:** Prateek
- **Email:** support@nivesh.ai (coming soon)
- **Documentation:** All docs in [/docs](docs/) folder
- **Issues:** [GitHub Issues](https://github.com/techySPHINX/Nivesh/issues)

---

## πŸ“š Quick Reference

### Key Documentation Files

| Need to understand...        | Read this file                                              |
| ---------------------------- | ----------------------------------------------------------- |
| **Overall vision**           | [PRD.md](PRD.md) - Product Requirements                     |
| **Architecture overview**    | [docs/Architecture.md](docs/Architecture.md)                |
| **All technologies**         | [docs/TECH_STACK.md](docs/TECH_STACK.md)                    |
| **Code organization**        | [docs/STRUCTURE.md](docs/STRUCTURE.md)                      |
| **Database design**          | [docs/DATABASE_STRATERGY.md](docs/DATABASE_STRATERGY.md)    |
| **Docker setup**             | [docs/CONTAINERIZATION.md](docs/CONTAINERIZATION.md)        |
| **AI/LLM integration**       | [docs/LLM_GUIDE.md](docs/LLM_GUIDE.md)                      |
| **Project progress**         | [TODO.md](TODO.md)                                          |

### Quick Commands

```bash
# Start everything (development)
docker-compose up -d

# View logs
docker-compose logs -f

# Stop everything
docker-compose down

# Rebuild after code changes
docker-compose up -d --build

# Check service health
docker-compose ps

# Access Neo4j browser
open http://localhost:7474

# Access API documentation
open http://localhost:8000/docs

Technology at a Glance

Layer Technologies Free/OSS
Frontend React Native, Next.js βœ…
Backend NestJS, FastAPI, Kong βœ…
Databases PostgreSQL, Neo4j, MongoDB, Redis βœ…
AI/ML LLaMA-3, Mistral-7B, XGBoost, Prophet βœ…
DevOps Docker, Kubernetes, Prometheus βœ…

*All AI models run locally via Ollama β€” 100% free, no API costs


Built with ❀️ for financial inclusion in India

Empowering every Indian with AI-powered financial intelligence

⭐ Star us on GitHub | πŸ› Report Bug | πŸ’‘ Request Feature


Status: πŸ“ Documentation Complete | 🚧 Development In Progress | 🎯 MVP Target: Q1 2026

Last Updated: January 16, 2026 | Version: 2.0 | Branch: req/ver_1

```

About

Nivesh is a modular, event-driven platform architected for scalable, enterprise-grade financial solutions. The system employs containerization and Kubernetes orchestration for resilient microservices deployment, while supporting LLM-based automation and prompt rollback mechanisms for adaptive AI workflows.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors