A real-time disaster response system using FastAPI, MongoDB Atlas, and Google AI.
- Real-time earthquake data from USGS
- Emergency shelter information from OpenStreetMap
- Vector search for relevant shelters
- Natural language Q&A with Gemini AI
- Interactive web interface with live map
- Time series data storage for disasters
- Python 3.10+
- MongoDB Atlas account
- Google Cloud Project with Vertex AI enabled
- Gemini API key
# Clone the repository
git clone <your-repo-url>
cd disaster-bot
# Create virtual environment
python -m venv venv
# On Mac:
source venv/bin/activate
# On Windows:
. venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Create .env with your credentials
MONGODB_URL=mongodb+srv://<username>:<password>@cluster.mongodb.net
GEMINI_API_KEY=your-gemini-api-key
GOOGLE_CLOUD_PROJECT=your-project-id
MONGODB_DATABASE="disaster_bot"- Create a MongoDB Atlas cluster
- Create a database called "disaster_bot"
- Set up collections using the setup script:
python setup_mongodb_atlas.py- Create a vector search index in Atlas UI:
- Go to Atlas → Search → Create Vector Search Index
- Choose JSON Editor
- Fill out the configuration:
{
"fields": [
{
"type": "vector",
"path": "embedding",
"numDimensions": 768,
"similarity": "cosine"
}
]
}- Pre-process shelters data into MongoDB:
python fetch_shelters_to_db.py- Create a Google Cloud Project
- Enable Vertex AI API
- Create a service account and download JSON key
- Set Google credentials in .env
# Development
uvicorn main:app --reload
The application will be available at http://localhost:8000
-
Click Create Service
-
Select:
-
Source: "Deploy from source"
-
Repository: Connect your GitHub repo (authorize if needed)
-
Branch: main
-
Build config: Dockerfile
-
-
Set the region (e.g., us-central1)
-
Allow unauthenticated access (so the public can access your API/UI)
-
Click Deploy
NOTE: If you're getting an SSL handshake error, you should check Network Access in Atlas. Go to MongoDB Atlas > Network Access > IP Access List, modify the IP address to 0.0.0.0/0