A full-stack web application featuring a chatbot with a FastAPI backend and a modern JavaScript frontend.
backend/— FastAPI backend (Python)frontend/— Frontend (JavaScript, Vite, React)env/— Python virtual environment
-
Install dependencies
In the
backenddirectory, install required Python packages:pip install -r requirements.txt
-
Start the backend server
cd "C:\Users\user\Desktop\Chatbot Web\backend" & "..\\.venv\Scripts\python.exe" -m uvicorn main:app --host 127.0.0.1 --port 8000 cd "C:\Users\user\Desktop\Chatbot Web" .venv\Scripts\Activate.ps1 cd backend uvicorn main:app --host 127.0.0.1 --port 8000
The backend will be available at http://127.0.0.1:8000 by default.
- Install dependencies
In the frontend directory:
npm install-
Start the frontend development server
npm run dev
The frontend will be available at the address shown in the terminal (usually
http://localhost:5173).
The chatbot now supports voice input with Malay (Bahasa Melayu) and English languages!
-
For best Malay support (Recommended):
- Add OpenAI API key to
.env:OPENAI_API_KEY=sk-your-api-key-here
- Restart backend server
- Add OpenAI API key to
-
Free alternative (Local):
- Already configured! Uses local Whisper model
- No API key needed, but slower and less accurate for Malay
- Click microphone icon 🎤 to record voice
- Go to Settings → Interaction to select language:
- Auto-detect (recommended)
- Bahasa Melayu (Malay only)
- English (English only)
📖 Full documentation: See VOICE_CHAT_GUIDE.md
- Open the frontend in your browser.
- Interact with the chatbot UI. Messages are sent to the FastAPI backend for processing.
The application includes a Map Data API that provides ArcGIS Feature Server endpoints for disaster management mapping.
- GET /map/endpoints — Get all available map data endpoints
- GET /map/endpoints/{type} — Get a specific endpoint by type (landslide, flood, poi, population)
- GET /map/types — Get all available map data types
The API provides access to these geospatial datasets:
- Land Slide Risk Area — Areas prone to landslides and slope failures
- Flood Prone Area — Areas at risk of flooding during monsoon seasons
- Place of Interest — Points of interest including emergency services
- Population — Population density data for evacuation planning
For detailed API documentation, see backend/routes/MAP_API.md or visit http://localhost:8000/docs when the backend is running.
// Fetch map endpoints
const response = await fetch("http://localhost:8000/map/endpoints");
const data = await response.json();
// Use with ArcGIS to create layers
import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
data.endpoints.forEach((endpoint) => {
const layer = new FeatureLayer({
url: endpoint.url,
title: endpoint.name,
});
map.add(layer);
});See frontend/src/examples/MapDataAPIExample.jsx for complete usage examples.
- Ensure the backend is running before using the frontend.
- Update API endpoints in the frontend if the backend address/port changes.
The backend endpoint POST /forgot-password can send a real password reset email when SMTP is configured.
Set these environment variables before starting the backend:
FRONTEND_BASE_URL(example:http://localhost:4028or your deployed site)SMTP_HOST(required to send email)SMTP_PORT(default:587)SMTP_USER(optional; if set, login is attempted)SMTP_PASSWORD(required ifSMTP_USERis set)SMTP_FROM(optional; defaults toSMTP_USER)SMTP_TLS(default:true) – use STARTTLS on port 587SMTP_SSL(default:false) – set totruefor implicit TLS (commonly port 465)SMTP_TIMEOUT(default:20seconds)
If SMTP_HOST is not set, the backend logs the reset link in the console (dev mode).
-
In Brevo: create an SMTP key (SMTP credentials) and verify your sender email/domain.
-
Set env vars (PowerShell):
$env:FRONTEND_BASE_URL = "http://localhost:4028" $env:SMTP_HOST = "smtp-relay.brevo.com" $env:SMTP_PORT = "587" $env:SMTP_TLS = "true" $env:SMTP_SSL = "false" $env:SMTP_USER = "YOUR_BREVO_SMTP_LOGIN" $env:SMTP_PASSWORD = "YOUR_BREVO_SMTP_KEY" $env:SMTP_FROM = "[email protected]" -
Restart the backend and use “Forgot password?” again.
This project is for educational purposes.