Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python FastAPI React XGBoost License Status

A Full-Stack AI Public Health Decision Support System

πŸ“– Docs Β· πŸš€ Quick Start Β· πŸ—οΈ Architecture Β· πŸ€– ML Models Β· 🌐 API Reference


🎯 What is FAST?

FAST (Forecasting Aggregate-level Self-harm Trends) is a production-grade, full-stack web application that uses machine learning to forecast national self-harm trends from social media mental health signals (Fear, Anger, Sadness).

⚠️ Research Use Only β€” Predicts aggregate national trends. NOT for individual clinical risk assessment.

✨ Key Highlights

Feature Description
πŸ€– AutoML Engine Trains & compares 5 models: XGBoost, Random Forest, SVR, Bayesian Ridge, ARIMA
πŸ” JWT Authentication Secure login/register with 24-hour access tokens
πŸ“Š Interactive Charts Plotly.js visualizations β€” forecasts, signals, feature importance
🎯 Policy Simulator What-If analysis by adjusting Fear/Anger/Sadness signals
πŸ” Explainable AI Feature importance to understand prediction drivers
πŸ“„ Report Generator Export full markdown analysis reports
🌐 REST API Full FastAPI backend with Swagger UI at /docs
πŸ’Ύ Persistent Storage SQLite database for users, datasets, and models

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 18, Vite, React Router v6, Plotly.js, Axios
Backend FastAPI, Uvicorn, SQLAlchemy, Pydantic v2
Authentication JWT (python-jose), bcrypt (passlib)
Machine Learning Scikit-learn, XGBoost, Statsmodels, SHAP
Data Pandas, NumPy, GeoPandas
Database SQLite (SQLAlchemy ORM)
Deployment Render.com, Railway (config included)

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+

1. Clone

git clone https://github.com/6673csm/FAST_Dashboard.git
cd FAST_Dashboard

2. Start the Backend (FastAPI)

cd backend
pip install -r requirements.txt
python -m uvicorn main:app --reload --port 8000

3. Start the Frontend (React)

cd frontend
npm install
npm run dev

4. (Optional) Run Original Streamlit App

pip install -r requirements.txt
streamlit run app.py

πŸ—οΈ Architecture

FAST_Dashboard/
β”‚
β”œβ”€β”€ backend/                    ← FastAPI REST API
β”‚   β”œβ”€β”€ main.py                 ← App entry, CORS, routers
β”‚   β”œβ”€β”€ database.py             ← SQLite + SQLAlchemy ORM
β”‚   β”œβ”€β”€ auth.py                 ← JWT authentication
β”‚   β”œβ”€β”€ schemas.py              ← Pydantic request/response models
β”‚   └── routers/
β”‚       β”œβ”€β”€ auth.py             ← POST /api/auth/register, /login
β”‚       β”œβ”€β”€ data.py             ← POST /api/data/upload, GET /list
β”‚       β”œβ”€β”€ models.py           ← POST /api/models/train
β”‚       β”œβ”€β”€ forecast.py         ← POST /api/forecast/run
β”‚       β”œβ”€β”€ simulator.py        ← POST /api/simulator/run
β”‚       └── reports.py          ← GET /api/reports/generate/{id}
β”‚
β”œβ”€β”€ frontend/                   ← React + Vite SPA
β”‚   └── src/
β”‚       β”œβ”€β”€ pages/              ← 10 page components
β”‚       β”œβ”€β”€ components/         ← Sidebar, MetricCard, Spinner
β”‚       β”œβ”€β”€ context/            ← AuthContext (JWT state)
β”‚       └── api/client.js       ← Axios with JWT interceptor
β”‚
β”œβ”€β”€ modules/                    ← Original Streamlit ML modules
β”œβ”€β”€ pages/                      ← Original Streamlit pages
β”œβ”€β”€ app.py                      ← Original Streamlit entry
β”œβ”€β”€ render.yaml                 ← Render.com deployment config
β”œβ”€β”€ Procfile                    ← Railway/Heroku deployment
└── .gitignore

🌐 API Reference

Method Endpoint Auth Description
POST /api/auth/register ❌ Create new user account
POST /api/auth/login ❌ Get JWT access token
GET /api/auth/me βœ… Get current user
POST /api/data/upload βœ… Upload & auto-clean CSV
GET /api/data/list βœ… List user datasets
GET /api/data/{id}/summary βœ… Dataset stats + preview
POST /api/models/train βœ… Train 5 AutoML models
GET /api/models/list/{id} βœ… Model leaderboard
GET /api/models/feature-importance/... βœ… Feature importance
POST /api/forecast/run βœ… Generate future forecast
POST /api/simulator/run βœ… What-If policy scenario
GET /api/reports/generate/{id} βœ… Export analysis report

πŸ“– Full interactive docs at http://localhost:8000/docs (Swagger UI)


πŸ€– ML Models

Model Type Best For
XGBoost Gradient Boosting High accuracy, handles non-linearity
Random Forest Ensemble Robust, handles overfitting
SVR Support Vector Small datasets, kernel tricks
Bayesian Ridge Linear Uncertainty quantification
ARIMA Time Series Pure time-series baseline

Feature Engineering

Automatically creates:

  • Lag features: 1, 7, 14, 30-day lags for each signal
  • Rolling stats: 7-day and 30-day moving averages & std deviations
  • Evaluation metrics: MAE, RMSE, RΒ², MAPE

Sample Results (on sample data)

Model MAE RMSE RΒ² MAPE
XGBoost 2.14 2.67 0.94 5.23%
Random Forest 2.38 2.91 0.92 6.12%
Bayesian Ridge 2.67 3.15 0.89 7.45%
SVR 2.89 3.40 0.87 8.21%
ARIMA 3.12 3.65 0.84 9.34%

🎯 Data Format

date,me-fea,me-ang,me-sad,gh-death,gh-injure
2023-01-01,0.45,0.32,0.56,12.3,145.2
2023-01-02,0.48,0.35,0.58,13.1,148.5
Column Description Range
date Date of observation YYYY-MM-DD
me-fea Fear signal (social media) 0.0 – 1.0
me-ang Anger signal (social media) 0.0 – 1.0
me-sad Sadness signal (social media) 0.0 – 1.0
gh-death Self-harm death rate (per 100k) β‰₯ 0
gh-injure Self-harm injury rate (per 100k) β‰₯ 0

☁️ Deploy to Render (Free)

  1. Push to GitHub (already done!)
  2. Go to render.com β†’ New Blueprint
  3. Connect your 6673csm/FAST_Dashboard repository
  4. Render reads render.yaml β†’ auto-deploys both API and frontend

⚠️ Ethical Considerations

βœ… Intended Use ❌ Not For
National trend forecasting Individual risk assessment
Public health policy planning Clinical diagnosis
Intervention impact testing Targeting individuals
Academic research Medical advice

πŸ“ License

MIT License β€” Free for educational and research use.


πŸ‘¨β€πŸ’» Author

Sujay Β· B.Tech CSE 2026 Β· India

GitHub


Built with passion for Public Health AI 🧠

About

FAST Dashboard - Forecasting Aggregate-level Self-harm Trends. Full-stack app: FastAPI + React + ML

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages