From 17e57d5facf6e02c7e624af7bc9ebd78968dca5c Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 22:32:31 +0530 Subject: [PATCH 1/8] fix: production-friendly error screen with retry button Removes "port 8000" dev-only hint. Shows a proper error card with a reload button since Render free tier has cold-start delays. --- frontend/src/App.jsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index caf7c7c..0ad9b03 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -22,10 +22,18 @@ export default function App() { if (!businesses) { return ( -
-
-

Could not connect to backend

-

Start the API on port 8000, then refresh.

+
+
+
+ + + +
+

Service unavailable

+

The backend is starting up โ€” this can take up to 60 seconds on first load.

+
) From f22cb07db5a9cc45f0dbd217402c7432c54ebaca Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:04:19 +0530 Subject: [PATCH 2/8] docs: add styled README and Netlify deployment config --- README.md | 439 +++++++++++++++++++++++++++++++++++++++++++++++++++ netlify.toml | 20 +++ 2 files changed, 459 insertions(+) create mode 100644 README.md create mode 100644 netlify.toml diff --git a/README.md b/README.md new file mode 100644 index 0000000..bb57436 --- /dev/null +++ b/README.md @@ -0,0 +1,439 @@ +
+ +
+ +
+ +[![NatWest Hackathon](https://img.shields.io/badge/NatWest-Code%20for%20Purpose%20India%20Hackathon-purple?style=for-the-badge)](https://github.com/anshul23102/cashclock) +[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue?style=for-the-badge)](LICENSE) +[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org) +[![React](https://img.shields.io/badge/React-18-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev) +[![FastAPI](https://img.shields.io/badge/FastAPI-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) + +
+ +--- + +## ๐Ÿ™‹โ€โ™‚๏ธ Overview + +**CashClock** is a full-stack web application that gives Indian small and medium enterprises (SMEs) real-time visibility into their cash position โ€” and early warning of when they might run out of money. It uses statistical forecasting and AI-generated insights to predict cash flow 30 days ahead, detect anomalies in transactions, and surface pre-approved loan offers to businesses at risk of a cash crisis. + +The platform serves two types of users: **business owners**, who see a personalised dashboard of their cash health, forecast, and loan options; and **bank managers**, who see a portfolio-wide view of all SME clients with risk classification, lending pipeline, and approval tools. + +--- + +## โœ… Features + +### ๐Ÿ“Š Business Owner Dashboard + +| Feature | Description | +|---|---| +| ๐Ÿ“ˆ **30-day cash forecast** | Three confidence paths โ€” likely / optimistic / pessimistic | +| ๐Ÿšซ **No-Cash Zone detection** | Identifies future dates when balance falls below โ‚น15,000 | +| ๐Ÿ’ฐ **Balance tracker** | Week-over-week trend and percentage change | +| ๐Ÿ“‰ **Forecast minimum** | Shows lowest projected balance and when it occurs | +| ๐Ÿ“… **Daily cash calendar** | Colour-coded calendar showing each day's cash health | +| โš ๏ธ **Anomaly feed** | Unusual transactions with severity, cause, and action | +| ๐Ÿ”ง **What-if scenarios** | Model revenue changes (ยฑ50%) or one-off injections | +| ๐Ÿค– **AI Ask Box** | Free-text Q&A powered by Claude AI | +| ๐Ÿ“„ **PDF report** | Multi-page formal business report with forecast charts | +| ๐Ÿฆ **Loan application** | In-app loan application for at-risk businesses | + +### ๐Ÿฆ Bank Manager Dashboard + +| Feature | Description | +|---|---| +| ๐Ÿ—‚๏ธ **Portfolio overview** | Total clients, at-risk count, pre-approved count, accepted rate | +| ๐Ÿ“Š **Risk distribution** | Healthy / watch / urgent / declining breakdown with counts | +| ๐Ÿฅง **Industry pie chart** | Distribution across all SME clients | +| ๐Ÿ“‰ **Health score histogram** | Distribution of runway scores across portfolio | +| ๐Ÿ”„ **Loan pipeline funnel** | Tracks offer sent โ†’ applied โ†’ approved โ†’ accepted | +| ๐Ÿ“† **Forecasted dip timeline** | Which businesses will hit a cash crisis and when | +| ๐Ÿ” **Business list** | Search + filter by industry and risk level | +| ๐Ÿ“จ **Bulk loan offers** | Send pre-approved offers to all at-risk businesses | + +### ๐Ÿค– AI & Analytics Engine + +| Feature | Description | +|---|---| +| ๐Ÿ“ **Holt-Winters ETS** | Exponential smoothing with weekly aggregation โ†’ daily distribution | +| ๐Ÿ“ **Rolling z-score detection** | Anomaly severity classification โ€” warning / high / critical | +| ๐Ÿƒ **Runway score (0โ€“100)** | Combines balance coverage, trend, volatility, and dip severity | +| ๐ŸŽฏ **Dynamic thresholds** | Per-business calibration from each business's own history | +| ๐Ÿ’ฌ **Claude AI integration** | Plain-English summaries with rule-based fallback | +| ๐Ÿ’ณ **Loan risk scoring** | Three risk tiers (low / medium / high) affecting interest rate | + +--- + +## ๐Ÿ› ๏ธ Tech Stack + +**Backend** + +[![My Skills](https://skillicons.dev/icons?i=python,fastapi)](https://skillicons.dev) + +| Category | Technology | +|---|---| +| **Language** | Python 3.10+ | +| **Web Framework** | FastAPI + Uvicorn | +| **Forecasting** | statsmodels (Holt-Winters Exponential Smoothing) | +| **Data Processing** | pandas, numpy | +| **AI / LLM** | Anthropic Claude API (`claude-haiku-4-5`) | +| **PDF Generation** | ReportLab | +| **Database** | SQLite (via Python `sqlite3`) | +| **Config** | python-dotenv | + +**Frontend** + +[![My Skills](https://skillicons.dev/icons?i=react,vite,tailwind,js)](https://skillicons.dev) + +| Category | Technology | +|---|---| +| **Language** | JavaScript (ES2022) | +| **Framework** | React 18 | +| **Build Tool** | Vite 5 | +| **Styling** | Tailwind CSS 3 | +| **Charts** | Recharts 2 | +| **HTTP Client** | Axios | +| **Icons** | Lucide React | + +**Infrastructure** + +[![My Skills](https://skillicons.dev/icons?i=sqlite,vercel,git)](https://skillicons.dev) + +| Category | Detail | +|---|---| +| **Database** | SQLite file (local, no external DB required) | +| **AI API** | Anthropic Claude API (optional โ€” rule-based fallback included) | +| **Deployment** | Render (backend) + Netlify (frontend) | + +--- + +## ๐Ÿ—‚๏ธ Folder Structure + +``` +cashclock/ +โ”œโ”€โ”€ backend/ # FastAPI Python server +โ”‚ โ”œโ”€โ”€ main.py # API routes and server entry point +โ”‚ โ”œโ”€โ”€ forecaster.py # Holt-Winters 30-day cash flow forecast +โ”‚ โ”œโ”€โ”€ anomaly.py # Rolling z-score anomaly detection +โ”‚ โ”œโ”€โ”€ health_insights.py # Runway score and health classification +โ”‚ โ”œโ”€โ”€ ai_coach.py # Claude AI summaries and Q&A +โ”‚ โ”œโ”€โ”€ loan.py # Loan sizing, risk scoring, repayment +โ”‚ โ”œโ”€โ”€ pdf_report.py # ReportLab PDF report generation +โ”‚ โ”œโ”€โ”€ database.py # SQLite schema and queries +โ”‚ โ”œโ”€โ”€ data_generator.py # Realistic SME data generation +โ”‚ โ”œโ”€โ”€ generate_sample.py # Script to seed the database +โ”‚ โ”œโ”€โ”€ requirements.txt # Python dependencies +โ”‚ โ”œโ”€โ”€ .env.example # Environment variable template +โ”‚ โ””โ”€โ”€ seed_data.sql # Pre-generated SQL seed data +โ”‚ +โ”œโ”€โ”€ frontend/ # React + Vite web application +โ”‚ โ”œโ”€โ”€ src/ +โ”‚ โ”‚ โ”œโ”€โ”€ App.jsx # Root component and routing +โ”‚ โ”‚ โ”œโ”€โ”€ main.jsx # Entry point +โ”‚ โ”‚ โ”œโ”€โ”€ index.css # Global styles (Tailwind) +โ”‚ โ”‚ โ””โ”€โ”€ components/ +โ”‚ โ”‚ โ”œโ”€โ”€ Landing.jsx # Role selection screen +โ”‚ โ”‚ โ”œโ”€โ”€ Dashboard.jsx # Manager portfolio dashboard +โ”‚ โ”‚ โ”œโ”€โ”€ CustomerDashboard.jsx # Business owner dashboard +โ”‚ โ”‚ โ”œโ”€โ”€ CustomerView.jsx # Business list selector +โ”‚ โ”‚ โ”œโ”€โ”€ ManagerBusinessPage.jsx # Per-business detail (manager) +โ”‚ โ”‚ โ”œโ”€โ”€ LoanOfferPage.jsx # Loan offer detail and application +โ”‚ โ”‚ โ”œโ”€โ”€ LoanOfferCard.jsx # Loan offer summary card +โ”‚ โ”‚ โ”œโ”€โ”€ CashBalanceForecastChart.jsx # 30-day forecast line chart +โ”‚ โ”‚ โ”œโ”€โ”€ CashFlowBreakdownChart.jsx # Monthly inflow/outflow bars +โ”‚ โ”‚ โ”œโ”€โ”€ CashCalendar.jsx # Daily colour-coded calendar +โ”‚ โ”‚ โ”œโ”€โ”€ PatternDrivers.jsx # Trend sparkline + seasonality +โ”‚ โ”‚ โ”œโ”€โ”€ AnomalyBandMini.jsx # Mini anomaly indicator +โ”‚ โ”‚ โ”œโ”€โ”€ WhatIfPanel.jsx # Scenario builder UI +โ”‚ โ”‚ โ”œโ”€โ”€ TrainingProgress.jsx # Loading animation screen +โ”‚ โ”‚ โ”œโ”€โ”€ LoginPage.jsx # Login screen +โ”‚ โ”‚ โ””โ”€โ”€ ChartLegendBaseline.jsx # Chart legend component +โ”‚ โ”œโ”€โ”€ package.json +โ”‚ โ”œโ”€โ”€ vite.config.js # Vite config with API proxy to :8000 +โ”‚ โ”œโ”€โ”€ tailwind.config.js +โ”‚ โ””โ”€โ”€ postcss.config.js +โ”‚ +โ”œโ”€โ”€ datasets/ # Raw SME dataset files +โ”œโ”€โ”€ netlify.toml # Netlify deployment config +โ”œโ”€โ”€ render.yaml # Render backend deployment config +โ””โ”€โ”€ README.md +``` + +--- + +## โš™๏ธ Installation & Setup + +### Prerequisites + +- Python **3.10 or higher** โ€” [python.org](https://python.org) +- Node.js **18 or higher** โ€” [nodejs.org](https://nodejs.org) +- `npm` (bundled with Node.js) +- _(Optional)_ An Anthropic API key for AI-powered summaries + +--- + +### 1. Clone the repository + +```bash +git clone https://github.com/anshul23102/cashclock.git +cd cashclock +``` + +--- + +### 2. Set up the backend + +```bash +cd backend +``` + +**Create and activate a virtual environment:** + +```bash +# macOS / Linux +python3 -m venv venv +source venv/bin/activate + +# Windows +python -m venv venv +venv\Scripts\activate +``` + +**Install Python dependencies:** + +```bash +pip install -r requirements.txt +``` + +**Configure environment variables:** + +```bash +cp .env.example .env +``` + +Open `.env` and add your Anthropic API key _(optional โ€” the app works without it using rule-based fallbacks)_: + +```env +ANTHROPIC_API_KEY=your_api_key_here +``` + +**Start the backend server:** + +```bash +uvicorn main:app --reload --port 8000 +``` + +The API will be available at `http://localhost:8000`. + +--- + +### 3. Set up the frontend + +Open a **new terminal** and from the project root: + +```bash +cd frontend +npm install +npm run dev +``` + +The frontend will be available at `http://localhost:5173`. + +> The Vite dev server automatically proxies all `/api/*` requests to the backend on port 8000 โ€” no manual CORS configuration needed. + +--- + +### 4. Open the app + +Navigate to `http://localhost:5173`. You will see the landing page with two options: + +- **I'm a Bank Manager** โ€” portfolio view of all SME clients +- **I'm a Business Owner** โ€” select your business to see your personal dashboard + +--- + +## ๐Ÿš€ Usage Examples + +### Viewing a business dashboard + +1. Click **"I'm a Business Owner"** on the landing page +2. Select a business from the list (e.g. _Ravi Electronics_) +3. The dashboard loads with current balance, 30-day forecast, no-cash zone warnings, and anomalies + +### Running a what-if scenario + +1. Open a business dashboard and scroll to **"What-If Scenario"** +2. Drag the **Revenue Change** slider (e.g. to โˆ’30%) +3. Optionally add a one-off income injection (e.g. โ‚น50,000) +4. Click **"Run Scenario"** โ€” the chart updates to show projected impact vs baseline + +### Asking the AI coach + +In the **"Ask Your Business Coach"** panel, type a plain-English question: + +``` +"Why did my cash drop in February?" +"When is my next predicted cash shortage?" +"What's driving my expenses up?" +``` + +### Manager: sending loan offers + +1. Log in as **Bank Manager** +2. Click **"Send Offers to All At-Risk"** for bulk pre-approved offers +3. Or expand any individual business and click **"Approve Loan"** to manually approve + +--- + +## ๐Ÿ“ก API Reference + +| Method | Endpoint | Description | +|---|---|---| +| `GET` | `/api/health` | Server health check | +| `GET` | `/api/businesses` | List all businesses with summary stats | +| `GET` | `/api/businesses/{id}` | Full business data + 365 days of transactions | +| `GET` | `/api/businesses/{id}/forecast` | 30-day forecast, health score, anomaly summary | +| `GET` | `/api/businesses/{id}/anomalies` | Detailed anomaly report with z-scores | +| `GET` | `/api/businesses/{id}/breakdown` | Monthly cash flow + expense composition | +| `POST` | `/api/businesses/{id}/scenario` | What-if scenario analysis | +| `POST` | `/api/businesses/{id}/ask` | AI-powered Q&A | +| `GET` | `/api/businesses/{id}/report/pdf` | Download PDF report | +| `POST` | `/api/businesses/{id}/apply-loan` | Business submits loan application | +| `POST` | `/api/businesses/{id}/approve-loan` | Manager approves loan | +| `GET` | `/api/businesses/{id}/loan-status` | Check loan application status | +| `GET` | `/api/portfolio/manager` | Full manager portfolio with KPIs | +| `POST` | `/api/portfolio/send-offers` | Bulk send pre-approved loan offers | +| `POST` | `/api/offer/accept` | Customer accepts a loan offer | + +**Example โ€” get forecast:** + +```bash +curl http://localhost:8000/api/businesses/1/forecast +``` + +```json +{ + "runway_score": 67, + "classification": "temporary_dip", + "loan_eligible": true, + "no_cash_zones": [ + { "date": "2025-05-03", "projected_balance": 8200, "severity": "critical" } + ], + "forecast": [ + { "date": "2025-04-13", "likely": 142500, "low": 118000, "high": 167000 } + ] +} +``` + +--- + +## ๐Ÿง  Technical Depth + +### Why Holt-Winters Exponential Smoothing? + +Indian SME cash flows are strongly seasonal โ€” festivals, monsoon slowdowns, and quarterly tax cycles create recurring patterns. Holt-Winters (ETS) was chosen because it explicitly models **trend** and **seasonality** as first-class components. The model is trained on each business's own 365-day history, producing personalised forecasts rather than industry averages. + +**Key detail:** Raw daily data is aggregated to weekly before fitting, reducing noise from zero-revenue weekends. The weekly forecast is redistributed back to daily using each business's observed day-of-week pattern. + +### Why rolling z-score anomaly detection? + +A fixed threshold fails for SMEs with vastly different scales. Rolling z-scores normalise against each business's own recent history โ€” a spike that is 2.5ฯƒ above *that business's* baseline is flagged regardless of absolute rupee value. + +### System Architecture + +``` +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Browser (React) โ”‚ +โ”‚ Landing โ†’ Manager Dashboard / Business Owner Dashboard โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ HTTP / REST (via Vite proxy) + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ FastAPI Backend (:8000) โ”‚ +โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ forecaster โ”‚ โ”‚ anomaly โ”‚ โ”‚health_insightsโ”‚ โ”‚ +โ”‚ โ”‚(Holt-Wintersโ”‚ โ”‚(z-score det.)โ”‚ โ”‚(runway score) โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ ai_coach โ”‚ โ”‚ loan โ”‚ โ”‚ pdf_report โ”‚ โ”‚ +โ”‚ โ”‚(Claude API) โ”‚ โ”‚(risk scoring)โ”‚ โ”‚ (ReportLab) โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ SQLite DB โ”‚ โ”‚ Anthropic API โ”‚ + โ”‚ (businesses + โ”‚ โ”‚ (Claude Haiku) โ”‚ + โ”‚ daily_data) โ”‚ โ”‚ [optional] โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +--- + +## โš ๏ธ Limitations + +| Limitation | Detail | +|---|---| +| ๐Ÿงช **Simulated data** | 10 SME businesses generated from realistic statistical templates โ€” not real bank data | +| ๐Ÿ” **No authentication** | Simple role-selection screen without passwords or session management | +| ๐Ÿ—ƒ๏ธ **SQLite only** | Not suitable for multi-user production; PostgreSQL needed for scale | +| ๐Ÿ‡ฎ๐Ÿ‡ณ **India-only patterns** | All businesses modelled with INR, Indian seasonal events, Indian tax cycles | +| ๐Ÿ”Œ **No live bank feed** | Cash flow data is pre-loaded, not connected to live transaction APIs | + +--- + +## ๐Ÿ”ฎ Future Improvements + +- ๐Ÿฆ **Open Banking integration** โ€” connect to RBI account aggregator APIs for live data +- ๐Ÿ” **User authentication** โ€” secure login with role-based access control +- ๐Ÿ—„๏ธ **PostgreSQL migration** โ€” replace SQLite with a production-grade database +- ๐Ÿ“ฑ **Mobile app** โ€” React Native client for on-the-go cash health monitoring +- ๐Ÿ”” **Push notifications** โ€” alert business owners via SMS/email for no-cash zone predictions +- ๐Ÿ“† **Longer forecast horizon** โ€” extend from 30 to 90-day forecasts + +--- + +## ๐Ÿ“ Configuration + +| Variable | Required | Description | +|---|---|---| +| `ANTHROPIC_API_KEY` | Optional | Claude API key for AI summaries. If omitted, rule-based fallbacks are used. | + +```bash +cp backend/.env.example backend/.env +``` + +> **Security note:** Never commit your `.env` file. It is listed in `.gitignore`. + +--- + +## ๐Ÿ† Highlights + +| | | +|---|---| +| ๐Ÿฅ‡ NatWest Code for Purpose โ€“ India Hackathon | Submitted project | +| ๐Ÿค– Claude AI Integration | Free-text Q&A + narrative summaries | +| ๐Ÿ“ Holt-Winters Forecasting | 30-day personalised cash flow prediction | +| ๐Ÿ‡ฎ๐Ÿ‡ณ India-focused | INR, Indian seasonal patterns, Indian SME data | + +--- + +## ๐Ÿ“„ License + +This project is submitted under the **Apache License 2.0**, in compliance with NatWest Group Code for Purpose โ€“ India Hackathon requirements. + +All commits are DCO-compliant. Third-party libraries are used under their respective open-source licences (MIT, Apache 2.0, BSD). + +--- + +
+ +Built with โค๏ธ for the **NatWest Group Code for Purpose โ€“ India Hackathon** + +*Helping Indian SMEs see their financial future clearly.* + + + +
diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..f8f306d --- /dev/null +++ b/netlify.toml @@ -0,0 +1,20 @@ +[build] + base = "frontend" + command = "npm run build" + publish = "dist" + +[build.environment] + NODE_VERSION = "20" + +# Proxy all /api/* requests to the Render backend +[[redirects]] + from = "/api/*" + to = "https://cashclock-api.onrender.com/api/:splat" + status = 200 + force = true + +# SPA fallback โ€” send all other routes to index.html +[[redirects]] + from = "/*" + to = "/index.html" + status = 200 From f57919ae237dd4054147dd8fe5b33d1030e2fe87 Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:12:19 +0530 Subject: [PATCH 3/8] chore: remove deployment configs (Netlify, Render, Vercel) --- .claude/settings.local.json | 134 +++++++++++++++++++++++++----------- README.md | 4 +- frontend/vercel.json | 6 -- netlify.toml | 20 ------ render.yaml | 10 --- 5 files changed, 95 insertions(+), 79 deletions(-) delete mode 100644 frontend/vercel.json delete mode 100644 netlify.toml delete mode 100644 render.yaml diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 4c2bd4a..0ee94b4 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,40 +1,94 @@ -{ - "permissions": { - "allow": [ - "Bash(pip3 install:*)", - "Bash(python3 -m venv .venv)", - "Bash(.venv/bin/pip install:*)", - "Bash(.venv/bin/python -c \"import fastapi, uvicorn, pandas, statsmodels; print\\('All imports OK'\\)\")", - "mcp__Claude_Preview__preview_start", - "Bash(npx vite:*)", - "Bash(echo \"PID: $!\")", - "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", - "Bash(echo \"Backend PID: $!\")", - "Bash(curl -s http://localhost:8000/api/businesses)", - "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\(f'{len\\(d\\)} businesses loaded'\\); [print\\(f' {b[\\\\\"name\\\\\"]:30s} | {b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]:6s} | trend: {b[\\\\\"stats\\\\\"][\\\\\"trend_pct\\\\\"]:+.1f}%'\\) for b in d]\")", - "Bash(wc -l \"/Users/aj.ts1758/Downloads/untitled folder/datasets/\"*.csv)", - "Bash(curl -s http://localhost:8000/api/health)", - "Bash(.venv/bin/python -c \"from main import app; print\\('Backend imports OK'\\)\")", - "Bash(kill 16491 23882)", - "Bash(xargs kill:*)", - "Bash(npm install:*)", - "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000)", - "Bash(python3 -c \"import sys,json; data=json.load\\(sys.stdin\\); [print\\(f'{b[\\\\\"name\\\\\"]}: balance ยฃ{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}, risk={b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]}'\\) for b in data]\")", - "Bash(curl -s http://localhost:8000/api/businesses/sunrise-bakery/forecast)", - "Bash(python3 -c ':*)", - "Bash(curl -s http://localhost:8000/api/businesses/__TRACKED_VAR__/forecast)", - "Bash(git checkout:*)", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \".schema\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT id, name, industry, postcode_prefix FROM businesses ORDER BY name;\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT COUNT\\(*\\) as total_days, business_id FROM daily_data GROUP BY business_id;\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT day, date, revenue, expenses, net, balance, is_anomaly FROM daily_data WHERE business_id = 'sunrise-bakery' ORDER BY day LIMIT 10;\")", - "Bash(git add:*)", - "Bash(kill 72541 73730)", - "Bash(kill 72565)", - "Bash(git commit -m ':*)", - "Bash(git push:*)", - "Bash(gh pr create --title 'feat: 32-business dataset, 12-column cash flow model, and analytics dashboard' --body ':*)", - "Bash(brew list:*)" - ] - } -} +{ + "permissions": { + "allow": [ + "Bash(pip3 install:*)", + "Bash(python3 -m venv .venv)", + "Bash(.venv/bin/pip install:*)", + "Bash(.venv/bin/python -c \"import fastapi, uvicorn, pandas, statsmodels; print\\('All imports OK'\\)\")", + "mcp__Claude_Preview__preview_start", + "Bash(npx vite:*)", + "Bash(echo \"PID: $!\")", + "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", + "Bash(echo \"Backend PID: $!\")", + "Bash(curl -s http://localhost:8000/api/businesses)", + "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\(f'{len\\(d\\)} businesses loaded'\\); [print\\(f' {b[\\\\\"name\\\\\"]:30s} | {b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]:6s} | trend: {b[\\\\\"stats\\\\\"][\\\\\"trend_pct\\\\\"]:+.1f}%'\\) for b in d]\")", + "Bash(wc -l \"/Users/aj.ts1758/Downloads/untitled folder/datasets/\"*.csv)", + "Bash(curl -s http://localhost:8000/api/health)", + "Bash(.venv/bin/python -c \"from main import app; print\\('Backend imports OK'\\)\")", + "Bash(kill 16491 23882)", + "Bash(xargs kill:*)", + "Bash(npm install:*)", + "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000)", + "Bash(python3 -c \"import sys,json; data=json.load\\(sys.stdin\\); [print\\(f'{b[\\\\\"name\\\\\"]}: balance ยฃ{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}, risk={b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]}'\\) for b in data]\")", + "Bash(curl -s http://localhost:8000/api/businesses/sunrise-bakery/forecast)", + "Bash(python3 -c ':*)", + "Bash(curl -s http://localhost:8000/api/businesses/__TRACKED_VAR__/forecast)", + "Bash(git checkout:*)", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \".schema\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT id, name, industry, postcode_prefix FROM businesses ORDER BY name;\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT COUNT\\(*\\) as total_days, business_id FROM daily_data GROUP BY business_id;\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT day, date, revenue, expenses, net, balance, is_anomaly FROM daily_data WHERE business_id = 'sunrise-bakery' ORDER BY day LIMIT 10;\")", + "Bash(git add:*)", + "Bash(kill 72541 73730)", + "Bash(kill 72565)", + "Bash(git commit -m ':*)", + "Bash(git push:*)", + "Bash(gh pr create --title 'feat: 32-business dataset, 12-column cash flow model, and analytics dashboard' --body ':*)", + "Bash(brew list:*)", + "Bash(venv/bin/pip install:*)", + "Bash(python3 -m venv venv --clear)", + "Bash(npm run:*)", + "Bash(echo \"Frontend PID: $!\")", + "Bash(gh pr create --title 'feat: localize currency from ยฃ to โ‚น' --body ':*)", + "Bash(gh auth:*)", + "Bash(curl -s http://localhost:8000/api/portfolio/manager)", + "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); b=[x for x in d['businesses'] if x.get\\('no_cash_zones'\\)][0]; print\\(json.dumps\\(b['no_cash_zones'][0], indent=2\\)\\)\")", + "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\('OK, businesses:', len\\(d['businesses']\\)\\)\")", + "Bash(python3 -m pip install reportlab --break-system-packages -q)", + "Bash(ls *.sh)", + "Bash(ls ../*.sh)", + "Bash(ls *.json)", + "Bash(/Users/aj.ts1758/cashclock/.venv/bin/pip install:*)", + "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c \"import reportlab; print\\('reportlab', reportlab.Version\\)\")", + "Bash(ls /Users/aj.ts1758/cashclock/backend/*.db)", + "Bash(kill -HUP 30766)", + "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\(f'Loaded {len\\(d\\)} businesses'\\); [print\\(f' - {b[\\\\\"name\\\\\"]}: balance โ‚น{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for b in d[:5]]\")", + "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\(f'Loaded {len\\(d\\)} businesses'\\); [print\\(f' - {b[\\\\\"name\\\\\"]}: balance={b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for b in d]\")", + "Bash(curl -sv http://localhost:8000/api/health)", + "Bash(xargs -I{} kill -TERM {})", + "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c \"from data_generator import generate_all_businesses; b = generate_all_businesses\\(\\); print\\(f'{len\\(b\\)} businesses generated'\\); [print\\(f' {x[\\\\\"name\\\\\"]}: โ‚น{x[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for x in b]\")", + "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c ':*)", + "Bash(nohup /Users/aj.ts1758/cashclock/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", + "Bash(echo \"Started PID: $!\")", + "Bash(curl -s -o /tmp/test_report.pdf -w \"%{http_code} %{content_type}\" http://localhost:8000/api/businesses/aman-auto/report/pdf)", + "Read(//private/tmp/**)", + "Bash(curl -s http://localhost:8000/api/businesses/aman-auto/forecast)", + "Bash(curl -s http://localhost:8000/api/businesses/aman-auto/breakdown)", + "Bash(kill -HUP 38751)", + "Bash(gh pr create --title 'feat: Indian SME data realism, PDF reports, and UI fixes' --body ':*)", + "Bash(curl -s -o /tmp/test_report.pdf -w \"%{http_code}\" http://localhost:8000/api/businesses/wellness-pharmacy/report/pdf)", + "Bash(git merge:*)", + "Bash(git pull:*)", + "Bash(git stash:*)", + "Bash(pip install:*)", + "Bash(python3 -m pip install -r /Users/aj.ts1758/cashclock/backend/requirements.txt -q)", + "Read(//tmp/**)", + "Bash(grep -E \"\\\\.py$\")", + "Bash(wc -l /Users/aj.ts1758/cashclock/frontend/src/components/*.jsx)", + "Bash(git reset:*)", + "Bash(rm /Users/aj.ts1758/cashclock/.git/index.lock)", + "Bash(ls /Users/aj.ts1758/cashclock/.git/*.lock)", + "Bash(gh pr create --title 'docs: Add comprehensive README.md for NatWest hackathon submission' --body ':*)", + "Bash(git cherry-pick:*)", + "Bash(gh pr create --base main --head feature/polish-and-loan-fixes --title 'fix: UI polish, loan flow gating, and text contrast improvements' --body ':*)", + "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\('at_risk_count:', d['kpis']['at_risk_count']\\); print\\('risk_dist:', d['analytics']['risk_distribution']\\)\")", + "Bash(cat /Users/aj.ts1758/cashclock/frontend/vite.config.*)", + "Bash(netlify --version)", + "Bash(cat /Users/aj.ts1758/cashclock/frontend/.env*)", + "Bash(netlify login:*)", + "Bash(/usr/local/bin/netlify login:*)", + "Bash(npx netlify-cli:*)", + "Bash(gh pr create --title 'docs: styled README with visual layout' --body ':*)" + ] + } +} diff --git a/README.md b/README.md index bb57436..98dc9e3 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ The platform serves two types of users: **business owners**, who see a personali |---|---| | **Database** | SQLite file (local, no external DB required) | | **AI API** | Anthropic Claude API (optional โ€” rule-based fallback included) | -| **Deployment** | Render (backend) + Netlify (frontend) | +| **Deployment** | Local dev server (backend :8000, frontend :5173) | --- @@ -155,8 +155,6 @@ cashclock/ โ”‚ โ””โ”€โ”€ postcss.config.js โ”‚ โ”œโ”€โ”€ datasets/ # Raw SME dataset files -โ”œโ”€โ”€ netlify.toml # Netlify deployment config -โ”œโ”€โ”€ render.yaml # Render backend deployment config โ””โ”€โ”€ README.md ``` diff --git a/frontend/vercel.json b/frontend/vercel.json deleted file mode 100644 index cd36910..0000000 --- a/frontend/vercel.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "framework": "vite", - "buildCommand": "npm run build", - "outputDirectory": "dist", - "installCommand": "npm install" -} diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index f8f306d..0000000 --- a/netlify.toml +++ /dev/null @@ -1,20 +0,0 @@ -[build] - base = "frontend" - command = "npm run build" - publish = "dist" - -[build.environment] - NODE_VERSION = "20" - -# Proxy all /api/* requests to the Render backend -[[redirects]] - from = "/api/*" - to = "https://cashclock-api.onrender.com/api/:splat" - status = 200 - force = true - -# SPA fallback โ€” send all other routes to index.html -[[redirects]] - from = "/*" - to = "/index.html" - status = 200 diff --git a/render.yaml b/render.yaml deleted file mode 100644 index c432751..0000000 --- a/render.yaml +++ /dev/null @@ -1,10 +0,0 @@ -services: - - type: web - name: cashclock-api - env: python - rootDir: backend - buildCommand: pip install -r requirements.txt - startCommand: uvicorn main:app --host 0.0.0.0 --port $PORT - envVars: - - key: ANTHROPIC_API_KEY - sync: false # set manually in Render dashboard From d38e29b6c07c7c6b31eae6e548d93eb237e90a84 Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:14:40 +0530 Subject: [PATCH 4/8] docs: restore README to styled version without deployment edits --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 98dc9e3..bb57436 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ The platform serves two types of users: **business owners**, who see a personali |---|---| | **Database** | SQLite file (local, no external DB required) | | **AI API** | Anthropic Claude API (optional โ€” rule-based fallback included) | -| **Deployment** | Local dev server (backend :8000, frontend :5173) | +| **Deployment** | Render (backend) + Netlify (frontend) | --- @@ -155,6 +155,8 @@ cashclock/ โ”‚ โ””โ”€โ”€ postcss.config.js โ”‚ โ”œโ”€โ”€ datasets/ # Raw SME dataset files +โ”œโ”€โ”€ netlify.toml # Netlify deployment config +โ”œโ”€โ”€ render.yaml # Render backend deployment config โ””โ”€โ”€ README.md ``` From 7fc426ce459697af925921cac81aea41dc1028ee Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:16:10 +0530 Subject: [PATCH 5/8] chore: revert .claude/settings.local.json (not for PR) --- .claude/settings.local.json | 134 +++++++++++------------------------- 1 file changed, 40 insertions(+), 94 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 0ee94b4..4c2bd4a 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,94 +1,40 @@ -{ - "permissions": { - "allow": [ - "Bash(pip3 install:*)", - "Bash(python3 -m venv .venv)", - "Bash(.venv/bin/pip install:*)", - "Bash(.venv/bin/python -c \"import fastapi, uvicorn, pandas, statsmodels; print\\('All imports OK'\\)\")", - "mcp__Claude_Preview__preview_start", - "Bash(npx vite:*)", - "Bash(echo \"PID: $!\")", - "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", - "Bash(echo \"Backend PID: $!\")", - "Bash(curl -s http://localhost:8000/api/businesses)", - "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\(f'{len\\(d\\)} businesses loaded'\\); [print\\(f' {b[\\\\\"name\\\\\"]:30s} | {b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]:6s} | trend: {b[\\\\\"stats\\\\\"][\\\\\"trend_pct\\\\\"]:+.1f}%'\\) for b in d]\")", - "Bash(wc -l \"/Users/aj.ts1758/Downloads/untitled folder/datasets/\"*.csv)", - "Bash(curl -s http://localhost:8000/api/health)", - "Bash(.venv/bin/python -c \"from main import app; print\\('Backend imports OK'\\)\")", - "Bash(kill 16491 23882)", - "Bash(xargs kill:*)", - "Bash(npm install:*)", - "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000)", - "Bash(python3 -c \"import sys,json; data=json.load\\(sys.stdin\\); [print\\(f'{b[\\\\\"name\\\\\"]}: balance ยฃ{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}, risk={b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]}'\\) for b in data]\")", - "Bash(curl -s http://localhost:8000/api/businesses/sunrise-bakery/forecast)", - "Bash(python3 -c ':*)", - "Bash(curl -s http://localhost:8000/api/businesses/__TRACKED_VAR__/forecast)", - "Bash(git checkout:*)", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \".schema\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT id, name, industry, postcode_prefix FROM businesses ORDER BY name;\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT COUNT\\(*\\) as total_days, business_id FROM daily_data GROUP BY business_id;\")", - "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT day, date, revenue, expenses, net, balance, is_anomaly FROM daily_data WHERE business_id = 'sunrise-bakery' ORDER BY day LIMIT 10;\")", - "Bash(git add:*)", - "Bash(kill 72541 73730)", - "Bash(kill 72565)", - "Bash(git commit -m ':*)", - "Bash(git push:*)", - "Bash(gh pr create --title 'feat: 32-business dataset, 12-column cash flow model, and analytics dashboard' --body ':*)", - "Bash(brew list:*)", - "Bash(venv/bin/pip install:*)", - "Bash(python3 -m venv venv --clear)", - "Bash(npm run:*)", - "Bash(echo \"Frontend PID: $!\")", - "Bash(gh pr create --title 'feat: localize currency from ยฃ to โ‚น' --body ':*)", - "Bash(gh auth:*)", - "Bash(curl -s http://localhost:8000/api/portfolio/manager)", - "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); b=[x for x in d['businesses'] if x.get\\('no_cash_zones'\\)][0]; print\\(json.dumps\\(b['no_cash_zones'][0], indent=2\\)\\)\")", - "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\('OK, businesses:', len\\(d['businesses']\\)\\)\")", - "Bash(python3 -m pip install reportlab --break-system-packages -q)", - "Bash(ls *.sh)", - "Bash(ls ../*.sh)", - "Bash(ls *.json)", - "Bash(/Users/aj.ts1758/cashclock/.venv/bin/pip install:*)", - "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c \"import reportlab; print\\('reportlab', reportlab.Version\\)\")", - "Bash(ls /Users/aj.ts1758/cashclock/backend/*.db)", - "Bash(kill -HUP 30766)", - "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\(f'Loaded {len\\(d\\)} businesses'\\); [print\\(f' - {b[\\\\\"name\\\\\"]}: balance โ‚น{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for b in d[:5]]\")", - "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\(f'Loaded {len\\(d\\)} businesses'\\); [print\\(f' - {b[\\\\\"name\\\\\"]}: balance={b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for b in d]\")", - "Bash(curl -sv http://localhost:8000/api/health)", - "Bash(xargs -I{} kill -TERM {})", - "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c \"from data_generator import generate_all_businesses; b = generate_all_businesses\\(\\); print\\(f'{len\\(b\\)} businesses generated'\\); [print\\(f' {x[\\\\\"name\\\\\"]}: โ‚น{x[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}'\\) for x in b]\")", - "Bash(/Users/aj.ts1758/cashclock/.venv/bin/python -c ':*)", - "Bash(nohup /Users/aj.ts1758/cashclock/.venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", - "Bash(echo \"Started PID: $!\")", - "Bash(curl -s -o /tmp/test_report.pdf -w \"%{http_code} %{content_type}\" http://localhost:8000/api/businesses/aman-auto/report/pdf)", - "Read(//private/tmp/**)", - "Bash(curl -s http://localhost:8000/api/businesses/aman-auto/forecast)", - "Bash(curl -s http://localhost:8000/api/businesses/aman-auto/breakdown)", - "Bash(kill -HUP 38751)", - "Bash(gh pr create --title 'feat: Indian SME data realism, PDF reports, and UI fixes' --body ':*)", - "Bash(curl -s -o /tmp/test_report.pdf -w \"%{http_code}\" http://localhost:8000/api/businesses/wellness-pharmacy/report/pdf)", - "Bash(git merge:*)", - "Bash(git pull:*)", - "Bash(git stash:*)", - "Bash(pip install:*)", - "Bash(python3 -m pip install -r /Users/aj.ts1758/cashclock/backend/requirements.txt -q)", - "Read(//tmp/**)", - "Bash(grep -E \"\\\\.py$\")", - "Bash(wc -l /Users/aj.ts1758/cashclock/frontend/src/components/*.jsx)", - "Bash(git reset:*)", - "Bash(rm /Users/aj.ts1758/cashclock/.git/index.lock)", - "Bash(ls /Users/aj.ts1758/cashclock/.git/*.lock)", - "Bash(gh pr create --title 'docs: Add comprehensive README.md for NatWest hackathon submission' --body ':*)", - "Bash(git cherry-pick:*)", - "Bash(gh pr create --base main --head feature/polish-and-loan-fixes --title 'fix: UI polish, loan flow gating, and text contrast improvements' --body ':*)", - "Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\('at_risk_count:', d['kpis']['at_risk_count']\\); print\\('risk_dist:', d['analytics']['risk_distribution']\\)\")", - "Bash(cat /Users/aj.ts1758/cashclock/frontend/vite.config.*)", - "Bash(netlify --version)", - "Bash(cat /Users/aj.ts1758/cashclock/frontend/.env*)", - "Bash(netlify login:*)", - "Bash(/usr/local/bin/netlify login:*)", - "Bash(npx netlify-cli:*)", - "Bash(gh pr create --title 'docs: styled README with visual layout' --body ':*)" - ] - } -} +{ + "permissions": { + "allow": [ + "Bash(pip3 install:*)", + "Bash(python3 -m venv .venv)", + "Bash(.venv/bin/pip install:*)", + "Bash(.venv/bin/python -c \"import fastapi, uvicorn, pandas, statsmodels; print\\('All imports OK'\\)\")", + "mcp__Claude_Preview__preview_start", + "Bash(npx vite:*)", + "Bash(echo \"PID: $!\")", + "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload)", + "Bash(echo \"Backend PID: $!\")", + "Bash(curl -s http://localhost:8000/api/businesses)", + "Bash(python3 -c \"import json,sys; d=json.load\\(sys.stdin\\); print\\(f'{len\\(d\\)} businesses loaded'\\); [print\\(f' {b[\\\\\"name\\\\\"]:30s} | {b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]:6s} | trend: {b[\\\\\"stats\\\\\"][\\\\\"trend_pct\\\\\"]:+.1f}%'\\) for b in d]\")", + "Bash(wc -l \"/Users/aj.ts1758/Downloads/untitled folder/datasets/\"*.csv)", + "Bash(curl -s http://localhost:8000/api/health)", + "Bash(.venv/bin/python -c \"from main import app; print\\('Backend imports OK'\\)\")", + "Bash(kill 16491 23882)", + "Bash(xargs kill:*)", + "Bash(npm install:*)", + "Bash(.venv/bin/python -m uvicorn main:app --host 0.0.0.0 --port 8000)", + "Bash(python3 -c \"import sys,json; data=json.load\\(sys.stdin\\); [print\\(f'{b[\\\\\"name\\\\\"]}: balance ยฃ{b[\\\\\"stats\\\\\"][\\\\\"current_balance\\\\\"]:,.0f}, risk={b[\\\\\"stats\\\\\"][\\\\\"risk_level\\\\\"]}'\\) for b in data]\")", + "Bash(curl -s http://localhost:8000/api/businesses/sunrise-bakery/forecast)", + "Bash(python3 -c ':*)", + "Bash(curl -s http://localhost:8000/api/businesses/__TRACKED_VAR__/forecast)", + "Bash(git checkout:*)", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \".schema\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT id, name, industry, postcode_prefix FROM businesses ORDER BY name;\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT COUNT\\(*\\) as total_days, business_id FROM daily_data GROUP BY business_id;\")", + "Bash(sqlite3 /Users/aj.ts1758/cashclock/backend/cashclock.db \"SELECT day, date, revenue, expenses, net, balance, is_anomaly FROM daily_data WHERE business_id = 'sunrise-bakery' ORDER BY day LIMIT 10;\")", + "Bash(git add:*)", + "Bash(kill 72541 73730)", + "Bash(kill 72565)", + "Bash(git commit -m ':*)", + "Bash(git push:*)", + "Bash(gh pr create --title 'feat: 32-business dataset, 12-column cash flow model, and analytics dashboard' --body ':*)", + "Bash(brew list:*)" + ] + } +} From 754fd01630dfb4fe6fc25f718717748e5e6f1132 Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:16:24 +0530 Subject: [PATCH 6/8] chore: add .claude/ to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6afd047..d99bf0f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist/ .DS_Store .venv/ *.log +.claude/ From 3ee36201a7e6b24847611ad2f965f29e568afa3b Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:21:59 +0530 Subject: [PATCH 7/8] docs: remove deployment platform references from README Remove mentions of Netlify, Render, and Vercel from the project structure, tech stack icons, and infrastructure table. Project is intended for local development only. --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index bb57436..15b900c 100644 --- a/README.md +++ b/README.md @@ -98,13 +98,12 @@ The platform serves two types of users: **business owners**, who see a personali **Infrastructure** -[![My Skills](https://skillicons.dev/icons?i=sqlite,vercel,git)](https://skillicons.dev) +[![My Skills](https://skillicons.dev/icons?i=sqlite,git)](https://skillicons.dev) | Category | Detail | |---|---| | **Database** | SQLite file (local, no external DB required) | | **AI API** | Anthropic Claude API (optional โ€” rule-based fallback included) | -| **Deployment** | Render (backend) + Netlify (frontend) | --- @@ -155,8 +154,6 @@ cashclock/ โ”‚ โ””โ”€โ”€ postcss.config.js โ”‚ โ”œโ”€โ”€ datasets/ # Raw SME dataset files -โ”œโ”€โ”€ netlify.toml # Netlify deployment config -โ”œโ”€โ”€ render.yaml # Render backend deployment config โ””โ”€โ”€ README.md ``` From ba89e469f4c9a7e7007fbc296c33926fca6a3b1d Mon Sep 17 00:00:00 2001 From: anshul23102 Date: Sun, 12 Apr 2026 23:28:30 +0530 Subject: [PATCH 8/8] docs: rewrite README to meet NatWest hackathon submission guidelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Full rewrite of README.md with: - Concise overview (what, problem, users) per guideline ยง1.1.i - Features section โ€” only implemented/working features per ยง4 - Explicit local-only setup instructions (Step 1โ€“4) per ยง1.1.iii - Troubleshooting table for common setup issues - Tech stack with skillicons badges and tables per ยง1.1.iv - Usage examples with API call sample per ยง1.1.v - Full API reference table - Architecture section with ASCII diagram and data flow per ยง6 - Technical depth: why Holt-Winters and rolling z-score per ยง6 - Limitations clearly labelled per ยง1.1.vi - Future improvements clearly labelled as not yet implemented per ยง4 - License and DCO compliance section per ยง7 - Styled header/footer matching personal README aesthetic --- README.md | 378 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 226 insertions(+), 152 deletions(-) diff --git a/README.md b/README.md index 15b900c..9d694ce 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@
-[![NatWest Hackathon](https://img.shields.io/badge/NatWest-Code%20for%20Purpose%20India%20Hackathon-purple?style=for-the-badge)](https://github.com/anshul23102/cashclock) +[![NatWest Hackathon](https://img.shields.io/badge/NatWest-Code%20for%20Purpose%20India%20Hackathon-7B2FBE?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PC9zdmc+)](https://github.com/anshul23102/cashclock) [![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue?style=for-the-badge)](LICENSE) [![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org) [![React](https://img.shields.io/badge/React-18-61DAFB?style=for-the-badge&logo=react&logoColor=black)](https://react.dev) [![FastAPI](https://img.shields.io/badge/FastAPI-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) +[![DCO Compliant](https://img.shields.io/badge/DCO-Compliant-green?style=for-the-badge)](https://developercertificate.org)
@@ -16,52 +17,52 @@ ## ๐Ÿ™‹โ€โ™‚๏ธ Overview -**CashClock** is a full-stack web application that gives Indian small and medium enterprises (SMEs) real-time visibility into their cash position โ€” and early warning of when they might run out of money. It uses statistical forecasting and AI-generated insights to predict cash flow 30 days ahead, detect anomalies in transactions, and surface pre-approved loan offers to businesses at risk of a cash crisis. +**CashClock** is a full-stack web application that gives Indian small and medium enterprises (SMEs) real-time visibility into their cash position โ€” and early warning of when they might run out of money. It uses **Holt-Winters statistical forecasting** and **Claude AI** to predict cash flow 30 days ahead, detect anomalies in transactions, and surface pre-approved loan offers to businesses at risk of a cash crisis. -The platform serves two types of users: **business owners**, who see a personalised dashboard of their cash health, forecast, and loan options; and **bank managers**, who see a portfolio-wide view of all SME clients with risk classification, lending pipeline, and approval tools. +The platform serves two types of users: **business owners**, who see a personalised dashboard of their cash health, forecast, anomalies, and loan options; and **bank managers**, who see a portfolio-wide view of all SME clients with risk classification, lending pipeline, and approval tools. The AI component is optional โ€” the app falls back to rule-based summaries if no API key is configured, so it runs fully offline. + +> **Hackathon:** NatWest Group โ€” Code for Purpose India Hackathon +> **Problem it solves:** Most Indian SMEs lack the financial tooling to anticipate cash shortfalls. CashClock gives them the same forecasting capability that large enterprises pay enterprise software for โ€” at zero cost. --- ## โœ… Features +> All features listed below are implemented and functional in the current codebase. + ### ๐Ÿ“Š Business Owner Dashboard -| Feature | Description | -|---|---| -| ๐Ÿ“ˆ **30-day cash forecast** | Three confidence paths โ€” likely / optimistic / pessimistic | -| ๐Ÿšซ **No-Cash Zone detection** | Identifies future dates when balance falls below โ‚น15,000 | -| ๐Ÿ’ฐ **Balance tracker** | Week-over-week trend and percentage change | -| ๐Ÿ“‰ **Forecast minimum** | Shows lowest projected balance and when it occurs | -| ๐Ÿ“… **Daily cash calendar** | Colour-coded calendar showing each day's cash health | -| โš ๏ธ **Anomaly feed** | Unusual transactions with severity, cause, and action | -| ๐Ÿ”ง **What-if scenarios** | Model revenue changes (ยฑ50%) or one-off injections | -| ๐Ÿค– **AI Ask Box** | Free-text Q&A powered by Claude AI | -| ๐Ÿ“„ **PDF report** | Multi-page formal business report with forecast charts | -| ๐Ÿฆ **Loan application** | In-app loan application for at-risk businesses | +- **30-day cash flow forecast** โ€” three confidence paths (likely / optimistic / pessimistic) using Holt-Winters Exponential Smoothing +- **No-Cash Zone detection** โ€” automatically identifies future dates when projected balance drops below โ‚น15,000 +- **Balance tracker** โ€” week-over-week trend with percentage change +- **Forecast minimum** โ€” shows the lowest projected balance and the exact date it occurs +- **Daily cash calendar** โ€” colour-coded calendar (green / yellow / red) showing each day's cash health +- **Anomaly feed** โ€” unusual transactions flagged with severity (warning / high / critical), probable cause, and a suggested action +- **What-if scenario builder** โ€” model a revenue change (ยฑ50%) or a one-off cash injection, with live chart update showing impact vs baseline +- **AI Ask Box** โ€” free-text Q&A answered by Claude AI (falls back to rule-based response if no API key) +- **PDF report download** โ€” multi-page formal business report including forecast chart, anomaly summary, and health score +- **In-app loan application** โ€” business owners can apply for a pre-approved loan directly from the dashboard ### ๐Ÿฆ Bank Manager Dashboard -| Feature | Description | -|---|---| -| ๐Ÿ—‚๏ธ **Portfolio overview** | Total clients, at-risk count, pre-approved count, accepted rate | -| ๐Ÿ“Š **Risk distribution** | Healthy / watch / urgent / declining breakdown with counts | -| ๐Ÿฅง **Industry pie chart** | Distribution across all SME clients | -| ๐Ÿ“‰ **Health score histogram** | Distribution of runway scores across portfolio | -| ๐Ÿ”„ **Loan pipeline funnel** | Tracks offer sent โ†’ applied โ†’ approved โ†’ accepted | -| ๐Ÿ“† **Forecasted dip timeline** | Which businesses will hit a cash crisis and when | -| ๐Ÿ” **Business list** | Search + filter by industry and risk level | -| ๐Ÿ“จ **Bulk loan offers** | Send pre-approved offers to all at-risk businesses | +- **Portfolio overview** โ€” total clients, at-risk count, pre-approved count, and accepted-offer rate as KPI cards +- **Risk distribution panel** โ€” healthy / watch / urgent / declining breakdown with counts and colour coding +- **Industry distribution pie chart** โ€” breakdown of portfolio across SME sectors +- **Health score histogram** โ€” distribution of runway scores (0โ€“100) across all businesses +- **Loan pipeline funnel** โ€” tracks offer sent โ†’ applied โ†’ approved โ†’ accepted +- **Forecasted dip timeline** โ€” which businesses will hit a cash crisis and when +- **Business list with search and filter** โ€” search by name, filter by industry and risk level +- **Bulk loan offer dispatch** โ€” send pre-approved offers to all at-risk businesses with one click +- **Per-business detail view** โ€” manager can drill into any business, see its full forecast, and manually approve a loan ### ๐Ÿค– AI & Analytics Engine -| Feature | Description | -|---|---| -| ๐Ÿ“ **Holt-Winters ETS** | Exponential smoothing with weekly aggregation โ†’ daily distribution | -| ๐Ÿ“ **Rolling z-score detection** | Anomaly severity classification โ€” warning / high / critical | -| ๐Ÿƒ **Runway score (0โ€“100)** | Combines balance coverage, trend, volatility, and dip severity | -| ๐ŸŽฏ **Dynamic thresholds** | Per-business calibration from each business's own history | -| ๐Ÿ’ฌ **Claude AI integration** | Plain-English summaries with rule-based fallback | -| ๐Ÿ’ณ **Loan risk scoring** | Three risk tiers (low / medium / high) affecting interest rate | +- **Holt-Winters ETS forecasting** โ€” triple exponential smoothing with weekly aggregation and day-of-week redistribution +- **Rolling z-score anomaly detection** โ€” severity classification relative to each business's own baseline, not a fixed threshold +- **Runway score (0โ€“100)** โ€” composite score combining balance coverage, trend direction, volatility, and dip severity +- **Dynamic per-business thresholds** โ€” calibrated from each business's own 365-day transaction history +- **Claude AI integration** โ€” plain-English summaries and free-text Q&A via `claude-haiku-4-5` +- **Loan risk scoring** โ€” three tiers (low / medium / high) that determine interest rate and loan size --- @@ -77,9 +78,9 @@ The platform serves two types of users: **business owners**, who see a personali | **Web Framework** | FastAPI + Uvicorn | | **Forecasting** | statsmodels (Holt-Winters Exponential Smoothing) | | **Data Processing** | pandas, numpy | -| **AI / LLM** | Anthropic Claude API (`claude-haiku-4-5`) | +| **AI / LLM** | Anthropic Claude API (`claude-haiku-4-5`) โ€” optional | | **PDF Generation** | ReportLab | -| **Database** | SQLite (via Python `sqlite3`) | +| **Database** | SQLite (Python built-in `sqlite3`) | | **Config** | python-dotenv | **Frontend** @@ -102,8 +103,9 @@ The platform serves two types of users: **business owners**, who see a personali | Category | Detail | |---|---| -| **Database** | SQLite file (local, no external DB required) | +| **Database** | SQLite file โ€” no external database required | | **AI API** | Anthropic Claude API (optional โ€” rule-based fallback included) | +| **Environment** | Runs fully on `localhost` โ€” no cloud account needed | --- @@ -116,21 +118,21 @@ cashclock/ โ”‚ โ”œโ”€โ”€ forecaster.py # Holt-Winters 30-day cash flow forecast โ”‚ โ”œโ”€โ”€ anomaly.py # Rolling z-score anomaly detection โ”‚ โ”œโ”€โ”€ health_insights.py # Runway score and health classification -โ”‚ โ”œโ”€โ”€ ai_coach.py # Claude AI summaries and Q&A -โ”‚ โ”œโ”€โ”€ loan.py # Loan sizing, risk scoring, repayment +โ”‚ โ”œโ”€โ”€ ai_coach.py # Claude AI summaries and free-text Q&A +โ”‚ โ”œโ”€โ”€ loan.py # Loan sizing, risk scoring, repayment schedule โ”‚ โ”œโ”€โ”€ pdf_report.py # ReportLab PDF report generation -โ”‚ โ”œโ”€โ”€ database.py # SQLite schema and queries -โ”‚ โ”œโ”€โ”€ data_generator.py # Realistic SME data generation -โ”‚ โ”œโ”€โ”€ generate_sample.py # Script to seed the database +โ”‚ โ”œโ”€โ”€ database.py # SQLite schema creation and queries +โ”‚ โ”œโ”€โ”€ data_generator.py # Realistic SME transaction data generator +โ”‚ โ”œโ”€โ”€ generate_sample.py # Script to seed the database with sample data +โ”‚ โ”œโ”€โ”€ seed_data.sql # Pre-generated SQL seed data (10 SME businesses) โ”‚ โ”œโ”€โ”€ requirements.txt # Python dependencies -โ”‚ โ”œโ”€โ”€ .env.example # Environment variable template -โ”‚ โ””โ”€โ”€ seed_data.sql # Pre-generated SQL seed data +โ”‚ โ””โ”€โ”€ .env.example # Environment variable template โ”‚ โ”œโ”€โ”€ frontend/ # React + Vite web application โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”œโ”€โ”€ App.jsx # Root component and routing โ”‚ โ”‚ โ”œโ”€โ”€ main.jsx # Entry point -โ”‚ โ”‚ โ”œโ”€โ”€ index.css # Global styles (Tailwind) +โ”‚ โ”‚ โ”œโ”€โ”€ index.css # Global styles (Tailwind directives) โ”‚ โ”‚ โ””โ”€โ”€ components/ โ”‚ โ”‚ โ”œโ”€โ”€ Landing.jsx # Role selection screen โ”‚ โ”‚ โ”œโ”€โ”€ Dashboard.jsx # Manager portfolio dashboard @@ -140,20 +142,20 @@ cashclock/ โ”‚ โ”‚ โ”œโ”€โ”€ LoanOfferPage.jsx # Loan offer detail and application โ”‚ โ”‚ โ”œโ”€โ”€ LoanOfferCard.jsx # Loan offer summary card โ”‚ โ”‚ โ”œโ”€โ”€ CashBalanceForecastChart.jsx # 30-day forecast line chart -โ”‚ โ”‚ โ”œโ”€โ”€ CashFlowBreakdownChart.jsx # Monthly inflow/outflow bars +โ”‚ โ”‚ โ”œโ”€โ”€ CashFlowBreakdownChart.jsx # Monthly inflow/outflow bar chart โ”‚ โ”‚ โ”œโ”€โ”€ CashCalendar.jsx # Daily colour-coded calendar -โ”‚ โ”‚ โ”œโ”€โ”€ PatternDrivers.jsx # Trend sparkline + seasonality +โ”‚ โ”‚ โ”œโ”€โ”€ PatternDrivers.jsx # Trend sparkline + seasonality bars โ”‚ โ”‚ โ”œโ”€โ”€ AnomalyBandMini.jsx # Mini anomaly indicator โ”‚ โ”‚ โ”œโ”€โ”€ WhatIfPanel.jsx # Scenario builder UI โ”‚ โ”‚ โ”œโ”€โ”€ TrainingProgress.jsx # Loading animation screen โ”‚ โ”‚ โ”œโ”€โ”€ LoginPage.jsx # Login screen โ”‚ โ”‚ โ””โ”€โ”€ ChartLegendBaseline.jsx # Chart legend component โ”‚ โ”œโ”€โ”€ package.json -โ”‚ โ”œโ”€โ”€ vite.config.js # Vite config with API proxy to :8000 +โ”‚ โ”œโ”€โ”€ vite.config.js # Vite config โ€” proxies /api/* to backend :8000 โ”‚ โ”œโ”€โ”€ tailwind.config.js โ”‚ โ””โ”€โ”€ postcss.config.js โ”‚ -โ”œโ”€โ”€ datasets/ # Raw SME dataset files +โ”œโ”€โ”€ datasets/ # Raw SME dataset files used for data generation โ””โ”€โ”€ README.md ``` @@ -161,16 +163,24 @@ cashclock/ ## โš™๏ธ Installation & Setup +> These instructions set up the project to run **entirely on your local machine**. No cloud accounts, no deployment needed. + ### Prerequisites -- Python **3.10 or higher** โ€” [python.org](https://python.org) -- Node.js **18 or higher** โ€” [nodejs.org](https://nodejs.org) -- `npm` (bundled with Node.js) -- _(Optional)_ An Anthropic API key for AI-powered summaries +Before you begin, make sure you have the following installed: + +| Tool | Minimum Version | Download | +|---|---|---| +| **Python** | 3.10 | [python.org](https://python.org) | +| **Node.js** | 18 | [nodejs.org](https://nodejs.org) | +| **npm** | bundled with Node.js | โ€” | +| **Git** | any recent version | [git-scm.com](https://git-scm.com) | + +An Anthropic API key is **optional**. The app works fully without it โ€” it will use rule-based text summaries instead of AI-generated ones. --- -### 1. Clone the repository +### Step 1 โ€” Clone the repository ```bash git clone https://github.com/anshul23102/cashclock.git @@ -179,7 +189,7 @@ cd cashclock --- -### 2. Set up the backend +### Step 2 โ€” Set up the backend ```bash cd backend @@ -192,42 +202,54 @@ cd backend python3 -m venv venv source venv/bin/activate -# Windows +# Windows (Command Prompt) python -m venv venv venv\Scripts\activate ``` +You should see `(venv)` appear at the start of your terminal prompt. + **Install Python dependencies:** ```bash pip install -r requirements.txt ``` +This installs FastAPI, statsmodels, pandas, ReportLab, anthropic, and all other dependencies. + **Configure environment variables:** ```bash cp .env.example .env ``` -Open `.env` and add your Anthropic API key _(optional โ€” the app works without it using rule-based fallbacks)_: +Open the `.env` file in any text editor. If you have an Anthropic API key, paste it in: ```env ANTHROPIC_API_KEY=your_api_key_here ``` +If you do not have a key, leave the file as-is โ€” the app will use rule-based fallbacks automatically. + **Start the backend server:** ```bash uvicorn main:app --reload --port 8000 ``` -The API will be available at `http://localhost:8000`. +You should see output like: +``` +INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) +INFO: Started reloader process +``` + +The backend API is now running at `http://localhost:8000`. Keep this terminal open. --- -### 3. Set up the frontend +### Step 3 โ€” Set up the frontend -Open a **new terminal** and from the project root: +Open a **new terminal window** (keep the backend terminal running), then from the project root: ```bash cd frontend @@ -235,18 +257,38 @@ npm install npm run dev ``` -The frontend will be available at `http://localhost:5173`. +You should see: +``` + VITE v5.x.x ready in XXX ms -> The Vite dev server automatically proxies all `/api/*` requests to the backend on port 8000 โ€” no manual CORS configuration needed. + โžœ Local: http://localhost:5173/ +``` + +> The Vite dev server automatically proxies all `/api/*` requests to the backend on port 8000. No CORS configuration or manual URL changes needed. --- -### 4. Open the app +### Step 4 โ€” Open the app + +Navigate to **`http://localhost:5173`** in your browser. + +You will see the CashClock landing page with two role options: + +| Role | What you see | +|---|---| +| **I'm a Bank Manager** | Portfolio view of all 10 SME clients with KPIs, charts, and loan tools | +| **I'm a Business Owner** | Business selector โ†’ personal dashboard with forecast, anomalies, and loan offer | + +--- -Navigate to `http://localhost:5173`. You will see the landing page with two options: +### Troubleshooting -- **I'm a Bank Manager** โ€” portfolio view of all SME clients -- **I'm a Business Owner** โ€” select your business to see your personal dashboard +| Problem | Fix | +|---|---| +| `ModuleNotFoundError` on backend start | Make sure your venv is activated โ€” you should see `(venv)` in your prompt | +| `npm install` fails | Check Node.js version: `node --version` must be 18+ | +| Backend starts but frontend shows blank | Confirm backend is running on port 8000 and frontend on 5173 | +| AI summaries say "rule-based fallback" | Either no API key is set, or the key in `.env` is invalid โ€” this is expected behaviour | --- @@ -256,14 +298,18 @@ Navigate to `http://localhost:5173`. You will see the landing page with two opti 1. Click **"I'm a Business Owner"** on the landing page 2. Select a business from the list (e.g. _Ravi Electronics_) -3. The dashboard loads with current balance, 30-day forecast, no-cash zone warnings, and anomalies +3. The dashboard loads with: + - Current balance and week-over-week change + - 30-day forecast chart with three confidence bands + - No-cash zone warnings (if any) + - Recent anomalies with severity labels ### Running a what-if scenario -1. Open a business dashboard and scroll to **"What-If Scenario"** +1. Open any business dashboard and scroll to **"What-If Scenario"** 2. Drag the **Revenue Change** slider (e.g. to โˆ’30%) -3. Optionally add a one-off income injection (e.g. โ‚น50,000) -4. Click **"Run Scenario"** โ€” the chart updates to show projected impact vs baseline +3. Optionally enter a one-off cash injection (e.g. โ‚น50,000) +4. Click **"Run Scenario"** โ€” the forecast chart updates to show projected vs baseline ### Asking the AI coach @@ -272,38 +318,26 @@ In the **"Ask Your Business Coach"** panel, type a plain-English question: ``` "Why did my cash drop in February?" "When is my next predicted cash shortage?" -"What's driving my expenses up?" +"What's driving my expenses up this month?" ``` -### Manager: sending loan offers +The response is generated by Claude AI if an API key is present, or by the rule-based engine otherwise. -1. Log in as **Bank Manager** -2. Click **"Send Offers to All At-Risk"** for bulk pre-approved offers -3. Or expand any individual business and click **"Approve Loan"** to manually approve +### Downloading a PDF report ---- +On any business dashboard, click **"Download Report"**. A multi-page PDF is generated and downloaded, containing: +- Business summary and current health score +- 30-day forecast chart (image embedded) +- Anomaly table with severity and causes +- Loan eligibility summary -## ๐Ÿ“ก API Reference +### Manager: sending loan offers -| Method | Endpoint | Description | -|---|---|---| -| `GET` | `/api/health` | Server health check | -| `GET` | `/api/businesses` | List all businesses with summary stats | -| `GET` | `/api/businesses/{id}` | Full business data + 365 days of transactions | -| `GET` | `/api/businesses/{id}/forecast` | 30-day forecast, health score, anomaly summary | -| `GET` | `/api/businesses/{id}/anomalies` | Detailed anomaly report with z-scores | -| `GET` | `/api/businesses/{id}/breakdown` | Monthly cash flow + expense composition | -| `POST` | `/api/businesses/{id}/scenario` | What-if scenario analysis | -| `POST` | `/api/businesses/{id}/ask` | AI-powered Q&A | -| `GET` | `/api/businesses/{id}/report/pdf` | Download PDF report | -| `POST` | `/api/businesses/{id}/apply-loan` | Business submits loan application | -| `POST` | `/api/businesses/{id}/approve-loan` | Manager approves loan | -| `GET` | `/api/businesses/{id}/loan-status` | Check loan application status | -| `GET` | `/api/portfolio/manager` | Full manager portfolio with KPIs | -| `POST` | `/api/portfolio/send-offers` | Bulk send pre-approved loan offers | -| `POST` | `/api/offer/accept` | Customer accepts a loan offer | +1. Log in as **Bank Manager** +2. On the dashboard, click **"Send Offers to All At-Risk"** to bulk-send pre-approved offers +3. Or search for a specific business โ†’ expand it โ†’ click **"Approve Loan"** to approve individually -**Example โ€” get forecast:** +### Example API call ```bash curl http://localhost:8000/api/businesses/1/forecast @@ -325,46 +359,86 @@ curl http://localhost:8000/api/businesses/1/forecast --- +## ๐Ÿ“ก API Reference + +| Method | Endpoint | Description | +|---|---|---| +| `GET` | `/api/health` | Server health check | +| `GET` | `/api/businesses` | List all businesses with summary stats | +| `GET` | `/api/businesses/{id}` | Full business data + 365 days of transactions | +| `GET` | `/api/businesses/{id}/forecast` | 30-day forecast, health score, anomaly summary | +| `GET` | `/api/businesses/{id}/anomalies` | Detailed anomaly report with z-scores | +| `GET` | `/api/businesses/{id}/breakdown` | Monthly cash flow + expense composition | +| `POST` | `/api/businesses/{id}/scenario` | What-if scenario analysis | +| `POST` | `/api/businesses/{id}/ask` | AI-powered free-text Q&A | +| `GET` | `/api/businesses/{id}/report/pdf` | Download multi-page PDF report | +| `POST` | `/api/businesses/{id}/apply-loan` | Business owner submits loan application | +| `POST` | `/api/businesses/{id}/approve-loan` | Manager approves a loan | +| `GET` | `/api/businesses/{id}/loan-status` | Poll current loan application status | +| `GET` | `/api/portfolio/manager` | Full manager portfolio with all KPIs | +| `POST` | `/api/portfolio/send-offers` | Bulk send pre-approved loan offers | +| `POST` | `/api/offer/accept` | Business owner accepts a loan offer | + +--- + ## ๐Ÿง  Technical Depth ### Why Holt-Winters Exponential Smoothing? -Indian SME cash flows are strongly seasonal โ€” festivals, monsoon slowdowns, and quarterly tax cycles create recurring patterns. Holt-Winters (ETS) was chosen because it explicitly models **trend** and **seasonality** as first-class components. The model is trained on each business's own 365-day history, producing personalised forecasts rather than industry averages. +Indian SME cash flows are strongly seasonal โ€” festivals (Diwali, Holi), monsoon slowdowns, and quarterly GST cycles create recurring patterns that simpler models miss. **Holt-Winters Triple Exponential Smoothing (ETS)** was chosen because it explicitly models **level**, **trend**, and **seasonality** as separate components, producing personalised forecasts from each business's own 365-day history rather than industry averages. -**Key detail:** Raw daily data is aggregated to weekly before fitting, reducing noise from zero-revenue weekends. The weekly forecast is redistributed back to daily using each business's observed day-of-week pattern. +**Key engineering detail:** Raw daily data is aggregated to weekly before fitting, which removes noise from zero-revenue weekends and public holidays. The fitted weekly forecast is then redistributed back to daily values using each business's observed day-of-week pattern โ€” preserving weekly cycle accuracy while giving granular daily output. -### Why rolling z-score anomaly detection? +### Why rolling z-score for anomaly detection? -A fixed threshold fails for SMEs with vastly different scales. Rolling z-scores normalise against each business's own recent history โ€” a spike that is 2.5ฯƒ above *that business's* baseline is flagged regardless of absolute rupee value. +A fixed rupee threshold fails across SMEs with vastly different transaction scales โ€” โ‚น50,000 is routine for one business and extraordinary for another. Rolling z-scores normalise each transaction against that business's own recent history window. A spike that is 2.5ฯƒ above *this business's* typical pattern is flagged regardless of absolute value, making the detector equally sensitive for a micro-SME and a mid-size manufacturer. ### System Architecture ``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ Browser (React) โ”‚ -โ”‚ Landing โ†’ Manager Dashboard / Business Owner Dashboard โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ - โ”‚ HTTP / REST (via Vite proxy) - โ–ผ -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ FastAPI Backend (:8000) โ”‚ -โ”‚ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ forecaster โ”‚ โ”‚ anomaly โ”‚ โ”‚health_insightsโ”‚ โ”‚ -โ”‚ โ”‚(Holt-Wintersโ”‚ โ”‚(z-score det.)โ”‚ โ”‚(runway score) โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ ai_coach โ”‚ โ”‚ loan โ”‚ โ”‚ pdf_report โ”‚ โ”‚ -โ”‚ โ”‚(Claude API) โ”‚ โ”‚(risk scoring)โ”‚ โ”‚ (ReportLab) โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ - โ”‚ - โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” - โ”‚ SQLite DB โ”‚ โ”‚ Anthropic API โ”‚ - โ”‚ (businesses + โ”‚ โ”‚ (Claude Haiku) โ”‚ - โ”‚ daily_data) โ”‚ โ”‚ [optional] โ”‚ - โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ Browser (React 18) โ”‚ +โ”‚ Landing Page โ†’ Manager Dashboard / Business Dashboard โ”‚ +โ”‚ Recharts ยท Tailwind CSS ยท Lucide Icons ยท Axios โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ HTTP / REST + โ”‚ (Vite proxy: /api/* โ†’ :8000) + โ–ผ +โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +โ”‚ FastAPI Backend (:8000) โ”‚ +โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ forecaster โ”‚ โ”‚ anomaly โ”‚ โ”‚ health_insights โ”‚ โ”‚ +โ”‚ โ”‚Holt-Winters โ”‚ โ”‚ rolling z- โ”‚ โ”‚ runway score 0- โ”‚ โ”‚ +โ”‚ โ”‚ETS, 30-day โ”‚ โ”‚ score detect โ”‚ โ”‚ 100, classif. โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ”‚ โ”‚ +โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +โ”‚ โ”‚ ai_coach โ”‚ โ”‚ loan โ”‚ โ”‚ pdf_report โ”‚ โ”‚ +โ”‚ โ”‚ Claude API โ”‚ โ”‚ risk scoring โ”‚ โ”‚ ReportLab โ”‚ โ”‚ +โ”‚ โ”‚ + fallback โ”‚ โ”‚ + repayment โ”‚ โ”‚ multi-page โ”‚ โ”‚ +โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + โ”‚ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ–ผ โ–ผ + โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” + โ”‚ SQLite DB โ”‚ โ”‚ Anthropic API โ”‚ + โ”‚ businesses table โ”‚ โ”‚ claude-haiku-4-5 โ”‚ + โ”‚ daily_data table โ”‚ โ”‚ [optional] โ”‚ + โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +**Data flow for a forecast request:** +``` +Browser GET /api/businesses/{id}/forecast + โ†’ main.py route handler + โ†’ database.py: fetch 365 days of daily_data + โ†’ forecaster.py: aggregate weekly โ†’ fit ETS โ†’ project 30 days โ†’ redistribute daily + โ†’ anomaly.py: compute rolling z-scores โ†’ classify severity + โ†’ health_insights.py: compute runway score โ†’ classify risk tier + โ†’ ai_coach.py: generate summary (Claude API or rule-based) + โ†’ JSON response โ†’ React renders charts ``` --- @@ -373,64 +447,64 @@ A fixed threshold fails for SMEs with vastly different scales. Rolling z-scores | Limitation | Detail | |---|---| -| ๐Ÿงช **Simulated data** | 10 SME businesses generated from realistic statistical templates โ€” not real bank data | -| ๐Ÿ” **No authentication** | Simple role-selection screen without passwords or session management | -| ๐Ÿ—ƒ๏ธ **SQLite only** | Not suitable for multi-user production; PostgreSQL needed for scale | -| ๐Ÿ‡ฎ๐Ÿ‡ณ **India-only patterns** | All businesses modelled with INR, Indian seasonal events, Indian tax cycles | -| ๐Ÿ”Œ **No live bank feed** | Cash flow data is pre-loaded, not connected to live transaction APIs | +| **Simulated data** | 10 SME businesses are generated from realistic statistical templates โ€” not real bank transaction data | +| **No authentication** | The role selection screen has no passwords or session management; anyone can switch roles | +| **SQLite only** | The database is a local file; it is not designed for concurrent multi-user access | +| **India-only patterns** | All businesses are modelled with INR, Indian seasonal events, and Indian tax cycles | +| **No live bank feed** | Cash flow data is pre-loaded; the app is not connected to any live transaction API or account aggregator | +| **Forecast accuracy** | ETS works well for the patterns in the generated data; accuracy on real-world data would require re-calibration | --- ## ๐Ÿ”ฎ Future Improvements -- ๐Ÿฆ **Open Banking integration** โ€” connect to RBI account aggregator APIs for live data -- ๐Ÿ” **User authentication** โ€” secure login with role-based access control -- ๐Ÿ—„๏ธ **PostgreSQL migration** โ€” replace SQLite with a production-grade database -- ๐Ÿ“ฑ **Mobile app** โ€” React Native client for on-the-go cash health monitoring -- ๐Ÿ”” **Push notifications** โ€” alert business owners via SMS/email for no-cash zone predictions -- ๐Ÿ“† **Longer forecast horizon** โ€” extend from 30 to 90-day forecasts +> These are features that would be built with more time โ€” they are **not** currently implemented. + +- **Open Banking integration** โ€” connect to RBI account aggregator APIs for live transaction data +- **User authentication** โ€” secure login with JWT tokens and role-based access control +- **PostgreSQL migration** โ€” replace SQLite with a production-grade database for multi-user scale +- **Push notifications** โ€” alert business owners via SMS or email when a no-cash zone is predicted +- **90-day forecast horizon** โ€” extend beyond the current 30-day window +- **Mobile app** โ€” React Native client for on-the-go cash health monitoring --- -## ๐Ÿ“ Configuration +## ๐Ÿ“ Configuration Reference | Variable | Required | Description | |---|---|---| -| `ANTHROPIC_API_KEY` | Optional | Claude API key for AI summaries. If omitted, rule-based fallbacks are used. | +| `ANTHROPIC_API_KEY` | Optional | Claude API key for AI summaries and Q&A. Omit for rule-based fallbacks. | ```bash +# Copy the example file and edit it cp backend/.env.example backend/.env ``` -> **Security note:** Never commit your `.env` file. It is listed in `.gitignore`. - ---- - -## ๐Ÿ† Highlights - -| | | -|---|---| -| ๐Ÿฅ‡ NatWest Code for Purpose โ€“ India Hackathon | Submitted project | -| ๐Ÿค– Claude AI Integration | Free-text Q&A + narrative summaries | -| ๐Ÿ“ Holt-Winters Forecasting | 30-day personalised cash flow prediction | -| ๐Ÿ‡ฎ๐Ÿ‡ณ India-focused | INR, Indian seasonal patterns, Indian SME data | +> **Security:** Never commit your `.env` file. It is already in `.gitignore`. Only commit `.env.example` with placeholder values. --- -## ๐Ÿ“„ License +## ๐Ÿ“„ License & Compliance -This project is submitted under the **Apache License 2.0**, in compliance with NatWest Group Code for Purpose โ€“ India Hackathon requirements. +This project is submitted under the **Apache License 2.0**, in compliance with NatWest Group Code for Purpose โ€” India Hackathon requirements. -All commits are DCO-compliant. Third-party libraries are used under their respective open-source licences (MIT, Apache 2.0, BSD). +- All commits are **DCO-compliant** (Developer Certificate of Origin) +- A single email address (`anshul23102@iiitd.ac.in`) is used for all commits and hackathon communication +- All third-party libraries are used under their respective open-source licences (MIT, Apache 2.0, BSD-3) +- No confidential, proprietary, or real customer data is included in this repository +- No API keys, passwords, or secrets are hard-coded anywhere in the codebase ---
-Built with โค๏ธ for the **NatWest Group Code for Purpose โ€“ India Hackathon** +Built with โค๏ธ for the **NatWest Group Code for Purpose โ€” India Hackathon** *Helping Indian SMEs see their financial future clearly.* +[![Portfolio](https://img.shields.io/badge/Author-Anshul%20Jain-7B2FBE?style=for-the-badge&logo=github&logoColor=white)](https://github.com/anshul23102) +[![Email](https://img.shields.io/badge/Email-anshul23102%40iiitd.ac.in-D14836?style=for-the-badge&logo=gmail&logoColor=white)](mailto:anshul23102@iiitd.ac.in) +