# sriya-singh/fixmycity architecture

> Architecture diagram of the GitHub repository sriya-singh/fixmycity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sriya-singh/fixmycity
- Repository: https://github.com/sriya-singh/fixmycity

## Overview

##### Main Components
- Frontend:
- Built with React and Material-UI, organized into UserPages and AuthorityPages.
- Handles functionalities such as location-based reporting (with Google Maps/Places APIs), authentication (using Firebase), and UI for reporting and dashboards.
- Backend API / Web Server:
- Contains services built in Python (Flask, FastAPI) which serve as the main API endpoints.
- Likely acting as an API gateway to route various requests from the frontend.
- AI/ML Microservices:
- Comment Summarization Service (located in the "comment_summary" folder), which uses Flask.
- Sentiment Analysis Service (in the "sentiment_analysis" folder), which incorporates Botpress elements and deep learning components.
- Similarity Model Service (in the "similarity_model" folder), which uses SentenceTransformers and related NLP libraries to avoid duplicate reports.
- Gemini Chatbot Service (in the "gemini_chatbot" folder) for conversational AI, using Gradio for interactivity.
- Data Storage & External Services:
- Firebase Firestore stores issues, user details, and other data.
- Firebase Storage is used for media file uploads.
- Firebase Authentication manages user sessions and security.
- External APIs like Google Maps, Geocoding, and SuperBase for additional functionalities.
- Deployment and containerization (Docker, Render, etc.) are also part of the ecosystem.

##### Relationships and Interactions
- The Frontend interacts via HTTP requests (using Axios/Fetch) with the Backend API.
- The API backend then routes requests to the various microservices (comment summarization, sentiment analysis, similarity checks, chatbot responses) depending on the request type.
- Data flows from the frontend to authentication servers (Firebase Auth) ensuring secure access.
- Media uploads and other files are sent to Firebase Storage.
- AI/ML services may exchange data (for instance, sentiment analysis results or similarity score outputs) with the backend or directly signal the frontend’s dashboard.

##### Architectural Patterns and Design Principles
- Modular Microservices: Each AI/ML component is implemented in its own directory with a self-contained setup, making it easier to scale or update independently.
- API Gateway Pattern: Although multiple backend services exist, they likely integrate under a combined API layer for the frontend.
- Distributed Architecture: Given the use of separate deployments (e.g., Render, Docker), illustrate boundaries between deployment containers and external service integrations.

##### Incorporate Relevant Technologies
- Frontend: React.js, Material-UI, Firebase Authentication, Google Maps/Places/Geocoding APIs.
- Backend: Flask, FastAPI, Gunicorn, Uvicorn, flask-cors.
- AI/ML: SentenceTransformers, Transformers, PyTorch, Botpress, Gradio, TextBlob, Gemini API.
- Data & Deployment: Firebase Firestore, Firebase Storage, Docker, Render, .env configuration for secrets.

- Lay out the system on a high-level canvas:
- Various microservices and backend subcomponents around the central API.
- On the right or at the bottom, include data storage, authentication, and external services.
- Keep the design flexible enough that as the project evolves (with more microservices or technology updates), additional services can be easily added.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Side
    subgraph "Client Side"
        User["User"]:::client
        Frontend["Frontend (React, Material-UI)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        APIGateway["API Gateway (Flask/FastAPI)"]:::backend
        subgraph "AI/ML Microservices"
            CS["Comment Summarization Service"]:::microservice
            SA["Sentiment Analysis Service"]:::microservice
            BP["Botpress Integration"]:::microservice
            SD["Similarity Detection Service"]:::microservice
            GC["Gemini Chatbot Service"]:::microservice
        end
    end

    %% External and Data Services
    subgraph "External Services"
        Firebase["Firebase (Auth, Firestore, Storage)"]:::external
        Maps["Google Maps/Geocoding API"]:::external
    end

    %% Connections from Client to Backend
    User -->|"HTTP_Request"| Frontend
    Frontend -->|"API_Request"| APIGateway

    %% Connections from API Gateway to Microservices
    APIGateway -->|"Process:Comment"| CS
    APIGateway -->|"Process:Sentiment"| SA
    APIGateway -->|"Process:Botpress"| BP
    APIGateway -->|"Process:Similarity"| SD
    APIGateway -->|"Process:Chatbot"| GC

    %% Responses from Microservices back to API Gateway
    CS -->|"Response"| APIGateway
    SA -->|"Response"| APIGateway
    BP -->|"Response"| APIGateway
    SD -->|"Response"| APIGateway
    GC -->|"Response"| APIGateway

    %% API Gateway exchanges with External Services
    APIGateway -->|"Data:Store"| Firebase
    Frontend -->|"LocationData"| Maps
    APIGateway -->|"API_Response"| Frontend

    %% Click Events
    click Frontend "https://github.com/sriya-singh/fixmycity/tree/main/frontend/"
    click CS "https://github.com/sriya-singh/fixmycity/blob/main/comment_summary/app.py"
    click SA "https://github.com/sriya-singh/fixmycity/blob/main/sentiment_analysis/app.py"
    click BP "https://github.com/sriya-singh/fixmycity/tree/main/sentiment_analysis/botpress/"
    click SD "https://github.com/sriya-singh/fixmycity/blob/main/similarity_model/app.py"
    click GC "https://github.com/sriya-singh/fixmycity/blob/main/gemini_chatbot/run.py"
    click GC "https://github.com/sriya-singh/fixmycity/blob/main/gemini_chatbot/gradio_ui.py"
    click Firebase "https://github.com/sriya-singh/fixmycity/tree/main/frontend/firebase/"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#1D8348,stroke-width:2px;
    classDef microservice fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef client fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
```
