Skip to content

Bonk1211/Finlytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BorneoHack FastAPI Next.js Gemini LangGraph

🌏 BorneoHack β€” ASEAN Cross-Border Trade & Fintech Platform

An AI-powered platform empowering ASEAN MSMEs (Micro, Small, and Medium Enterprises) with cross-border trade intelligence, alternative credit scoring, supply chain optimization, and real-time market analytics.

Built for the BorneoHack hackathon, this full-stack application combines a FastAPI backend with a Next.js frontend, powered by Google Gemini AI and a LangGraph multi-agent orchestrator.


✨ Key Features

πŸ€– AI-Finance Assist (Multi-Agent Chatbot)

  • LangGraph Multi-Agent Orchestrator β€” Supervisor Agent delegates tasks to specialist sub-agents
  • Researcher Agent (7 tools) β€” Web search, ASEAN news, chart/graph generation, image generation, tariff guidance, TTS
  • Quant Agent (4 tools) β€” Calculator, stock prices, live currency conversion, loan amortization
  • Prompt Injection Protection β€” Hardened system prompts with security directives
  • MCP Integration β€” Model Context Protocol server exposing tools over SSE
  • Markdown-rendered responses with tables, charts, and images inline

🌐 Cross-Border Trade Navigator

  • AI-powered Q&A on ASEAN import/export regulations
  • RAG-based semantic search over trade regulation knowledge base (Supabase pgvector)
  • Auto-generated compliance documents (Commercial Invoice, Certificate of Origin)
  • Tariff lookup with HS code estimation under ATIGA framework

πŸ“Š Alternative Credit Scoring

  • AI credit model using 11+ non-traditional data points
  • Assesses unbanked/offline businesses via digital transaction ratios, mobile payment volume, inventory turnover, supplier reliability, and customer ratings
  • Visual score dial with risk tier classification and AI recommendations

πŸ“¦ Automated Supply Chain Management

  • Smart supplier recommendation engine
  • Demand forecasting and inventory optimization
  • Regional supplier matching across ASEAN countries

πŸ—ΊοΈ World Monitor Command Center

  • Real-time geopolitical risk surveillance with interactive map
  • Live USGS earthquake data layer integration
  • Multi-stream live news (Al Jazeera, Sky News, Euronews, DW)
  • Live webcam feeds from global hotspots
  • Country instability indices with dynamic risk scoring

πŸͺ Business Visibility Engine

  • Digital onboarding for offline businesses
  • Multi-step verified profile creation
  • Supply chain identity generation (MSME-ID)

πŸ“ˆ MSME Dashboard

  • Revenue & expense analytics with interactive Recharts visualizations
  • Smart Process Manager (Kanban-style workflow)
  • Market intelligence summary with regional breakdown

πŸ—οΈ Architecture

BorneoHack/
β”œβ”€β”€ backend/                          # FastAPI Python Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                   # Application entry point & CORS
β”‚   β”‚   β”œβ”€β”€ config.py                 # Pydantic settings from .env
β”‚   β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”‚   β”œβ”€β”€ chatbot.py            # AI-Finance Assist endpoint
β”‚   β”‚   β”‚   β”œβ”€β”€ trade_ai.py           # Trade Navigator (RAG + Compliance)
β”‚   β”‚   β”‚   β”œβ”€β”€ credit.py             # Alternative Credit Scoring
β”‚   β”‚   β”‚   β”œβ”€β”€ supply_chain.py       # Supply Chain Optimization
β”‚   β”‚   β”‚   β”œβ”€β”€ market.py             # Predictive Market Analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ document_ai.py        # Document Processing
β”‚   β”‚   β”‚   β”œβ”€β”€ translation.py        # Multi-language Translation
β”‚   β”‚   β”‚   β”œβ”€β”€ inventory.py          # Inventory Management
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.py          # Dashboard Analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ mcp.py                # Model Context Protocol Server
β”‚   β”‚   β”‚   └── health.py             # Health Check
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ agent.py              # LangGraph Multi-Agent System (11 tools)
β”‚   β”‚   β”‚   β”œβ”€β”€ trade_ai.py           # Trade AI RAG + Semantic Search
β”‚   β”‚   β”‚   β”œβ”€β”€ gemini_client.py      # Google Gemini API Client
β”‚   β”‚   β”‚   β”œβ”€β”€ credit.py             # Credit Scoring Engine
β”‚   β”‚   β”‚   β”œβ”€β”€ supply_chain.py       # Supply Chain Logic
β”‚   β”‚   β”‚   β”œβ”€β”€ market.py             # Market Analytics
β”‚   β”‚   β”‚   β”œβ”€β”€ document_ai.py        # Document AI Service
β”‚   β”‚   β”‚   β”œβ”€β”€ translation.py        # Translation Service
β”‚   β”‚   β”‚   β”œβ”€β”€ inventory.py          # Inventory Service
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.py          # Dashboard Service
β”‚   β”‚   β”‚   β”œβ”€β”€ mem0_client.py        # Mem0 Memory Client
β”‚   β”‚   β”‚   └── supabase_client.py    # Supabase Client
β”‚   β”‚   └── schemas/                  # Pydantic request/response models
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env.example
β”‚
β”œβ”€β”€ frontend/                         # Next.js TypeScript Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx              # Main Dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ trade-navigator/      # Trade Navigator Chat
β”‚   β”‚   β”‚   β”œβ”€β”€ credit-scoring/       # Credit Scoring UI
β”‚   β”‚   β”‚   β”œβ”€β”€ supply-chain/         # Supply Chain Management
β”‚   β”‚   β”‚   β”œβ”€β”€ worldmonitor/         # World Monitor Command Center
β”‚   β”‚   β”‚   β”œβ”€β”€ visibility-engine/    # Business Visibility Engine
β”‚   β”‚   β”‚   └── globals.css           # Design System & Tokens
β”‚   β”‚   └── components/
β”‚   β”‚       β”œβ”€β”€ ai-chat.tsx           # AI-Finance Assist Chat Widget
β”‚   β”‚       β”œβ”€β”€ right-chat-sidebar.tsx# Sliding Chat Drawer
β”‚   β”‚       β”œβ”€β”€ sidebar.tsx           # Navigation Sidebar
β”‚   β”‚       └── world-map.tsx         # Interactive World Map
β”‚   └── package.json
β”‚
└── README.md

🧠 Multi-Agent System

The AI backbone uses LangGraph to orchestrate a Supervisor β†’ Worker multi-agent pattern:

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    User Query ───▢ β”‚  Supervisor  β”‚ ◀─── Structured Routing
                    β”‚ (Orchestrator)β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                         β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚   Researcher    β”‚       β”‚     Quant       β”‚
     β”‚   (7 Tools)     β”‚       β”‚   (4 Tools)     β”‚
     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
     β”‚ β€’ search_web    β”‚       β”‚ β€’ calculator    β”‚
     β”‚ β€’ asean_news    β”‚       β”‚ β€’ stock_price   β”‚
     β”‚ β€’ current_date  β”‚       β”‚ β€’ convert_curr  β”‚
     β”‚ β€’ gen_image     β”‚       β”‚ β€’ calc_loan     β”‚
     β”‚ β€’ gen_graph     β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚ β€’ tariff_info   β”‚
     β”‚ β€’ tts_url       β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Security Features:

  • Prompt injection defense across all agent prompts
  • Domain-confinement (financial/trade topics only)
  • System instruction concealment directives
  • Input length capping on tool parameters

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • npm or yarn

Backend (FastAPI)

cd backend

# Create & activate virtual environment
python -m venv venv
.\venv\Scripts\activate        # Windows
# source venv/bin/activate     # macOS / Linux

# Install dependencies
pip install -r requirements.txt

# Copy env and configure API keys
cp .env.example .env
# Edit .env with your API keys (see Environment Variables below)

# Run dev server
uvicorn app.main:app --reload --port 8000

API docs available at: http://localhost:8000/docs

Frontend (Next.js)

cd frontend

# Install dependencies
npm install --legacy-peer-deps

# Run dev server
npm run dev

App available at: http://localhost:3000


πŸ”‘ Environment Variables

Create a .env file in /backend with:

Variable Description Required
GEMINI_API_KEY Google Gemini API key βœ…
GEMINI_MODEL Gemini model name (e.g. gemini-2.5-flash) βœ…
TAVILY_API_KEY Tavily web search API key βœ…
ALPHAVANTAGE_API_KEY Alpha Vantage stock/forex API key ⬚ Optional
NEWS_API_KEY NewsAPI.org key for ASEAN headlines ⬚ Optional
MEM0_API_KEY Mem0 memory layer API key ⬚ Optional
SUPABASE_URL Supabase project URL ⬚ Optional
SUPABASE_ANON_KEY Supabase anonymous key ⬚ Optional
SUPABASE_SERVICE_KEY Supabase service role key ⬚ Optional

πŸ“‘ API Endpoints

Method Endpoint Description
GET / Root welcome message
GET /api/health Health check
POST /api/chatbot/message AI-Finance Assist (multi-agent)
POST /api/trade-ai/query Trade regulation Q&A (RAG)
POST /api/trade-ai/generate-document Compliance document generation
POST /api/trade-ai/tariff-lookup Tariff rate lookup
POST /api/credit/score Alternative credit scoring
POST /api/supply-chain/recommend-suppliers Supplier recommendations
GET /api/market/analysis Market analytics
POST /api/document-ai/process Document AI processing
POST /api/translation/translate Multi-language translation
GET /api/dashboard/summary Dashboard data
GET /api/mcp/ MCP Server (SSE)

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 16.1, React 19, TypeScript, Tailwind CSS v4
UI Components Lucide React, Recharts, react-simple-maps, react-markdown, remark-gfm
Backend FastAPI, Python 3.11+, Pydantic v2
AI/LLM Google Gemini (gemini-2.5-flash), LangChain, LangGraph
Agent Tools Tavily (search), Alpha Vantage (stocks), NewsAPI (news), QuickChart (graphs), Pollinations (images), ExchangeRate API (forex)
Database Supabase (PostgreSQL + pgvector)
Memory Mem0 (conversational memory)
Protocol Model Context Protocol (MCP) via FastMCP

πŸŽ₯ Demo Video Link

https://drive.google.com/file/d/1lJO3Bpwct4cWzprqfkGMhjadmW7-dFuZ/view?usp=sharing


πŸ“„ License

This project is for hackathon demonstration purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors