Skip to content

Backend API Implementation

Shivanarayana Lovdi requested to merge backend-api into main

Backend API Implementation for Nagara AI Smart City Platform

Overview

Implemented the FastAPI backend for the Nagara AI Smart City Platform. This backend provides a scalable and modular API architecture that supports tourism recommendations, traffic monitoring, civic complaint management, emergency services, city health scoring, and analytics dashboard functionality.

The backend is designed to integrate seamlessly with the upcoming Streamlit frontend while maintaining a clean separation of concerns through route, service, and schema layers.

Key Features

  • FastAPI application setup with:
    • API title and versioning
    • Interactive Swagger/OpenAPI documentation
    • CORS configuration for frontend integration
  • SQLite database integration using SQLAlchemy ORM
  • Automatic database table creation on startup
  • Modular route organization for maintainability
  • Service layer implementation for business logic and mock data handling
  • Pydantic schemas for request and response validation
  • Civic complaint reporting and status management APIs
  • Mock APIs for tourism, traffic, emergency services, city health score, and analytics modules

API Endpoints

Tourism

  • POST /api/tourism/generate-itinerary
  • GET /api/tourism/places

Traffic

  • GET /api/traffic/live
  • GET /api/traffic/all

Civic Complaints

  • POST /api/complaints/report
  • GET /api/complaints
  • GET /api/complaints/{complaint_id}
  • PUT /api/complaints/{complaint_id}

Emergency Services

  • GET /api/emergency/services

City Health Score

  • GET /api/health-score

Analytics Dashboard

  • GET /api/analytics/dashboard

Technical Highlights

  • Layered architecture (Routes → Services → Database)
  • SQLAlchemy ORM models for data persistence
  • Pydantic-based validation and serialization
  • Ready for frontend integration and future AI service expansion
  • Extensible structure for production-scale deployment

Testing

  • Verified API startup and route registration
  • Validated request/response schemas
  • Confirmed database initialization and table creation
  • Tested endpoint responses using FastAPI Swagger UI

Next Steps

  • Integrate Streamlit frontend with backend APIs

  • Replace mock responses with real-time data sources

  • Add authentication and authorization

  • Implement AI-powered recommendation and analytics services

    closses #5 (closed)

Edited by Shivanarayana Lovdi

Merge request reports

Loading