This guide details the steps to deploy the UIDAI Anomaly & Risk Intelligence System in a production environment using best practices. The backend API server and frontend dashboard are split to enable independent scaling and isolation.
The backend is packaged inside a multi-stage Docker container running FastAPI with Uvicorn.
- Push the repository to GitHub.
- Sign in to Render.
- Click New + and select Web Service.
- Connect your GitHub repository.
- In the settings, configure:
- Runtime:
Docker - Dockerfile Path:
Dockerfile(automatically uses backend-only multi-stage build) - Instance Type: Free/Paid (as appropriate)
- Runtime:
- Render will automatically build the Docker image and pass a dynamic
PORTenvironment variable to the container. - Set up the Health Check Path in the Advanced Settings:
- Path:
/healthor/api/health - Interval: 10-30 seconds
- Path:
- Verify Deployed URL: The service will expose an endpoint like:
https://uidai-risk-api.onrender.com
The interactive dashboard runs on Streamlit Community Cloud and communicates with the backend API over HTTP.
- Log in to Streamlit Share.
- Click New App.
- Choose your GitHub repository, branch (
main), and set the main file path to:app.py - Expand the Advanced Settings before deploying.
- Under Secrets, define the environment variable to point to your backend API hosted on Render:
API_URL = "https://uidai-risk-api.onrender.com"
- Click Deploy.
- Verify Deployed URL: The service will expose an app like:
https://uidai-risk-dashboard.streamlit.app
| Variable Name | Required By | Description | Example Value |
|---|---|---|---|
PORT |
FastAPI (Render) | Port for the backend API container (Render injects this dynamically). | 8000 |
API_URL |
Streamlit Cloud | URL of the running FastAPI server. Streamlit uses this to fetch data. If empty, falls back to local CSV. | https://uidai-risk-api.onrender.com |
For local development, you can spin up the backend API using Docker Compose:
docker-compose up --buildThis builds and launches the API container on http://localhost:8000. You can run the Streamlit dashboard locally pointing to it:
$env:API_URL="http://localhost:8000"
streamlit run app.pyOr simply run both locally using the orchestrator script:
python start_services.py