imchine
FinTech-Solution
TypeScriptโœจ New

FinTech AI Solution for SMEs to calculate financial values

Last updated Jul 28, 2026
131
Stars
940
Forks
0
Issues
0
Stars/day
Attention Score
97
Language breakdown
TypeScript 97.0%
CSS 1.4%
JavaScript 0.8%
Dockerfile 0.5%
Shell 0.3%
โ–ธ Files click to expand
README

FinSight AI โ€” AI Financial Assistant for SMEs

Production-grade SaaS financial intelligence platform powered by GPT-4o, Next.js 15, and PostgreSQL.

Next.js TypeScript PostgreSQL Clerk OpenAI


๐Ÿš€ Features

Core Modules

| Module | Description | |--------|-------------| | Financial Dashboard | Real-time revenue, expenses, profit, invoice metrics | | Invoice Management | Create, send, track, record payments | | Expense Tracking | Manual entry, CSV import, categorization | | Transaction Ledger | Full double-entry transaction history | | Bank Statement Analyzer | Upload PDF/CSV, extract & categorize transactions | | AI Financial Assistant | RAG-based chatbot with real financial data context | | AI Insights Engine | Auto-detected anomalies, risks, opportunities | | Cash Flow Forecasting | Deterministic 3-month linear trend forecasts | | Financial Reports | P&L, Expense Summary, Revenue Trends (PDF/Excel) | | Settings & Security | RBAC, audit logs, MFA, organization management |

Critical Design Principle

AI NEVER calculates financial values. All calculations are deterministic and performed by the backend using Prisma queries. AI only generates explanations, insights, and narratives based on the pre-calculated data.

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Next.js 15 App Router                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   Frontend (RSC)     โ”‚        API Routes                 โ”‚
โ”‚  - Dashboard         โ”‚  - /api/dashboard                 โ”‚
โ”‚  - Invoices          โ”‚  - /api/invoices                  โ”‚
โ”‚  - Expenses          โ”‚  - /api/expenses                  โ”‚
โ”‚  - AI Assistant      โ”‚  - /api/ai/chat (SSE streaming)   โ”‚
โ”‚  - Cash Flow         โ”‚  - /api/cash-flow                 โ”‚
โ”‚  - Reports           โ”‚  - /api/reports                   โ”‚
โ”‚  - Insights          โ”‚  - /api/insights                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚                          โ”‚
    Clerk Auth                  Prisma ORM
           โ”‚                          โ”‚
    PostgreSQL DB              OpenAI GPT-4o
           โ”‚                          โ”‚
    Qdrant Vector DB         RAG Pipeline

RAG Pipeline

User Question
โ†’ Intent Classification (GPT-4o-mini)
โ†’ Data Retrieval (Prisma queries = REAL numbers)
โ†’ Context Assembly
โ†’ OpenAI GPT-4o Response Generation
โ†’ Streaming SSE to Frontend

๐Ÿ“‹ Tech Stack

Frontend

  • Next.js 15 (App Router, RSC, Streaming)
  • TypeScript 5
  • Tailwind CSS + ShadCN UI components
  • Recharts (interactive financial charts)
  • React Query (server state management)
  • Zustand (client state)
Backend
  • Next.js API Routes
  • Prisma ORM with PostgreSQL
  • Zod validation (all inputs)
  • Rate limiting via Redis when REDIS_URL is set (in-process fallback otherwise)
  • Redis-backed dashboard metrics cache with version invalidation on writes
AI
  • OpenAI GPT-4o (assistant responses)
  • OpenAI text-embedding-3-small (embeddings)
  • RAG architecture for financial context
  • Qdrant vector database
Auth & Security
  • Clerk Authentication (OAuth, MFA, RBAC)
  • OWASP Top 10 compliant
  • CSRF protection in middleware
  • SQL injection prevention (Prisma parameterized queries)
  • Complete audit logging

๐Ÿ—„๏ธ Database Schema

Organizations โ”€โ”€โ”ฌโ”€โ”€ OrganizationMembers โ”€โ”€ Users
                โ”œโ”€โ”€ Clients
                โ”œโ”€โ”€ Vendors
                โ”œโ”€โ”€ Categories
                โ”œโ”€โ”€ Transactions โ”€โ”€ Categories
                โ”œโ”€โ”€ Invoices โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€ InvoiceItems
                โ”‚                 โ””โ”€โ”€ Payments
                โ”œโ”€โ”€ Expenses โ”€โ”€ Categories
                โ”œโ”€โ”€ BankStatements โ”€โ”€ Transactions
                โ”œโ”€โ”€ Reports
                โ”œโ”€โ”€ AIChats โ”€โ”€ AIChatMessages
                โ”œโ”€โ”€ Insights
                โ”œโ”€โ”€ CashFlowForecasts
                โ”œโ”€โ”€ Notifications
                โ”œโ”€โ”€ AuditLogs
                โ””โ”€โ”€ Anomalies

๐Ÿ”’ Security Implementation

| Security Layer | Implementation | |----------------|---------------| | Authentication | Clerk JWT + MFA | | Authorization | RBAC (Admin/Accountant/Employee/Viewer) | | CSRF Protection | Origin/Host validation in middleware | | Rate Limiting | Per-IP sliding window (100 req/min default) | | Input Validation | Zod schemas on all API endpoints | | SQL Injection | Prisma ORM parameterized queries | | XSS Prevention | Next.js built-in + CSP headers | | Audit Logging | All CRUD operations logged with user/IP | | Sensitive Data | Prisma field-level encryption ready | | File Upload | Type validation, size limits, S3 signed URLs |


๐Ÿš€ Quick Start

Prerequisites

  • Node.js 20+
  • PostgreSQL 16+
  • OpenAI API key
  • Clerk account

1. Clone & Install

git clone https://github.com/imchine/FinTech-Solution.git
cd finsight-ai
npm install

2. Environment Setup

cp .env.example .env.local

Fill in your API keys

3. Database Setup

# Apply schema
npx prisma migrate dev --name init

Generate client

npx prisma generate

4. Run Development

npm run dev

Open http://localhost:3000

5. Docker (Full Stack)

docker-compose up -d

Redis (optional)

Redis is optional but recommended for production and multi-instance deployments.

docker compose up -d redis

set in .env.local:

REDIS_URL=redis://localhost:6379

When REDIS_URL is set:

  • Rate limiting โ€” shared across API routes (/api/transactions, /api/invoices, /api/ai/chat, etc.)
  • Dashboard cache โ€” metrics cached for 2 minutes; invalidated when transactions, expenses, or invoices change
  • Health check โ€” GET /api/health reports whether Redis is configured
Without Redis, rate limits and dashboard metrics use in-process behaviour only.

๐Ÿ“ Folder Structure

finsight-ai/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ (auth)/          # Sign in/up pages (Clerk)
โ”‚   โ”‚   โ”œโ”€โ”€ (dashboard)/     # All protected dashboard pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/   # Main financial dashboard
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ invoices/    # Invoice management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ expenses/    # Expense tracking
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ transactions/# Transaction ledger
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ai-assistant/# AI chatbot interface
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cash-flow/   # Cash flow & forecasting
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ insights/    # AI insights engine
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ reports/     # Financial reports
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ bank-statements/ # Bank statement analyzer
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ settings/    # Account & org settings
โ”‚   โ”‚   โ””โ”€โ”€ api/             # All API routes
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ ui/              # ShadCN UI components
โ”‚   โ”‚   โ”œโ”€โ”€ charts/          # Recharts wrappers
โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/       # Dashboard-specific components
โ”‚   โ”‚   โ”œโ”€โ”€ layout/          # Sidebar, Header
โ”‚   โ”‚   โ””โ”€โ”€ shared/          # Providers, theme
โ”‚   โ”œโ”€โ”€ lib/
โ”‚   โ”‚   โ”œโ”€โ”€ prisma.ts        # Database client
โ”‚   โ”‚   โ”œโ”€โ”€ auth.ts          # Auth helpers & audit logging
โ”‚   โ”‚   โ”œโ”€โ”€ openai.ts        # AI integration & RAG
โ”‚   โ”‚   โ”œโ”€โ”€ financial-calculations.ts  # ALL financial math
โ”‚   โ”‚   โ”œโ”€โ”€ validations.ts   # Zod schemas
โ”‚   โ”‚   โ”œโ”€โ”€ rate-limit.ts    # API rate limiting
โ”‚   โ”‚   โ””โ”€โ”€ utils.ts         # Utilities & formatters
โ”‚   โ”œโ”€โ”€ middleware.ts         # Auth & security middleware
โ”‚   โ””โ”€โ”€ types/               # TypeScript types
โ”œโ”€โ”€ prisma/
โ”‚   โ””โ”€โ”€ schema.prisma        # Complete DB schema
โ”œโ”€โ”€ docker-compose.yml       # Full stack Docker setup
โ”œโ”€โ”€ Dockerfile               # Production container
โ””โ”€โ”€ .env.example             # Environment template

๐Ÿ“Š API Endpoints

| Method | Endpoint | Description | |--------|----------|-------------| | GET | /api/health | Health check | | GET | /api/dashboard | Dashboard metrics | | GET | /api/dashboard/trends | Monthly trends | | GET | /api/dashboard/categories | Expense categories | | GET/POST | /api/invoices | List/create invoices | | GET/PATCH/DELETE | /api/invoices/[id] | Invoice operations | | GET/POST | /api/expenses | List/create expenses | | GET/POST | /api/transactions | List/create transactions | | POST | /api/ai/chat | AI chat (SSE streaming) | | GET | /api/ai/chat | Chat history | | GET | /api/cash-flow | Historical + forecasts | | GET/POST | /api/reports | Report management | | GET | /api/insights | AI insights |


๐Ÿšข Deployment

Vercel (Frontend)

vercel deploy --prod

Environment Variables (Production)

Set all variables from .env.example in your deployment platform.

Database Migration (Production)

npx prisma migrate deploy

๐Ÿงช Testing Strategy

  • Unit Tests: Financial calculation functions (Jest)
  • Integration Tests: API routes with Prisma mocks
  • E2E Tests: Playwright for critical user flows
  • Security Tests: OWASP ZAP scanning
  • Load Tests: k6 for API performance

๐Ÿ“ˆ Performance

  • Server-side rendering for initial dashboard load
  • React Query caching (60s stale time)
  • Optimized Prisma queries with proper indexes
  • Streaming AI responses (SSE)
  • Image optimization via Next.js
  • Lazy loading of chart components

๐Ÿค Contributing

  • Fork the repository
  • Create a feature branch
  • Make changes with tests
  • Submit a PR

๐Ÿ“„ License

MIT License โ€” see LICENSE file.


Built with โค๏ธ for SMEs worldwide

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท imchine/FinTech-Solution ยท Updated daily from GitHub