Backend API Implementation - Nagara AI
Backend API Implementation
Implemented the FastAPI backend for the Nagara AI Smart City Platform.
This backend provides modular API endpoints for tourism, traffic, civic complaints, emergency services, city health score, and analytics dashboard features. It is designed to connect with the Streamlit frontend in the next step.
Key Features
- FastAPI application configured with title, version, Swagger docs, and CORS
- SQLite database integration using SQLAlchemy ORM
- Auto table creation on application startup
- Modular route structure for clean backend organization
- Service layer added for business logic and mock data
- Pydantic schemas added for request and response validation
- Complaint reporting and status update APIs
- Mock APIs for tourism, traffic, emergency services, health score, and analytics
Endpoints Added
POST /api/tourism/generate-itineraryGET /api/tourism/placesGET /api/traffic/liveGET /api/traffic/allPOST /api/complaints/reportGET /api/complaintsGET /api/complaints/{complaint_id}PUT /api/complaints/{complaint_id}GET /api/emergency/servicesGET /api/health-scoreGET /api/analytics/dashboard
Testing
The backend was tested locally using:
uvicorn backend.main:app --reload