# shriyanshcode/cityassist architecture

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

- Interactive diagram: https://gitdiagram.com/shriyanshcode/cityassist
- Repository: https://github.com/shriyanshcode/cityassist

## Overview

##### Main Components
- Frontend (User Interface): Two main Streamlit-driven UIs are implemented:
- updated_househelp_ui.py: For data entry and verification.
- cityassist.py: For executing household help search.
- Backend Microservices:
- aadhaarchecker.py: A Flask server dedicated to Aadhaar card verification (using PaddleOCR).
- nursechecker.py: A Flask server that implements nursing verification (using Selenium for browser automation).
- Data Processing and Loading:
- load.py: Loads the dataset (found under the data folder, e.g., data/data.json) into a MongoDB cluster.
- params.py: Likely contains configuration and parameter settings for various components.
- Database and External Integrations:
- MongoDB: Utilized for advanced vector-based search with Atlas Search (leveraging MongoDB’s knnVector and dynamic mappings).
- Google Embeddings / Gemini API: Used for generating embeddings to power the advanced search.
- Selenium and PaddleOCR: Integrated into the verification processes for identity validation.

##### Relationships and Data Flow
- User Interactions:
- Users interact with the Streamlit UIs to either search for household help or to enter and verify new data.
- Data Operations:
- When a user conducts a search via cityassist.py, the UI sends queries that are processed using MongoDB’s vector search (backed by Google Embeddings).
- For data entry or verification, the updated_househelp_ui.py interacts with backend services to check user credentials or verify identities.
- Microservices Communication:
- The Aadhaar and nurse verification endpoints (exposed by aadhaarchecker.py and nursechecker.py respectively) operate as separate services, likely interfacing with the frontend or other parts of the system via HTTP (or REST API) calls.
- The load.py script is used during setup to import data into the database from data/data.json.
- External Service Integrations:
- MongoDB and its Atlas Search index are crucial for handling queries.
- The system relies on external credentials like MONGO_URI, GOOGLE_API_KEY, and configurations for Chromium driver for Selenium automation.

##### Important Architectural Patterns and Design Choices
- Microservices Architecture: Separation of verification tasks via distinct Flask servers enables independent scaling and maintenance.
- Modular Design: Each functionality (search, data entry/verification, and identity confirmation) is handled by separate scripts.
- Third-Party Integrations: The use of tools like PaddleOCR and Selenium indicates a design that leverages specialized libraries for specific tasks.
- Cloud Integration: The reliance on MongoDB Atlas and Google Embeddings implies that cloud services and API integrations are a foundational part of the architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    user["User"]:::user

    %% Frontend
    subgraph "Frontend"
        ui1["City Assist Search UI (cityassist.py)"]:::frontend
        ui2["Data Entry/Verification UI (updated_househelp_ui.py)"]:::frontend
    end

    %% Backend Microservices
    subgraph "Backend Microservices"
        ms1["Aadhaar Verification Microservice (aadhaarchecker.py)"]:::backend
        ms2["Nurse Verification Microservice (nursechecker.py)"]:::backend
        conf["Configuration (params.py)"]:::config
    end

    %% Data Management
    subgraph "Data Management"
        dataLoad["Data Loading Module (load.py & data/data.json)"]:::loader
        db["MongoDB\n(Vector Search with Atlas & knnVector)"]:::database
    end

    %% External Integrations
    subgraph "External Integrations"
        ext1["Google Embeddings / Gemini API"]:::external
        ext2["PaddleOCR"]:::external
        ext3["Selenium & Chromedriver"]:::external
    end

    %% Connections
    user -->|"uses"| ui1
    user -->|"uses"| ui2

    ui1 -->|"search_query"| db
    ui1 -->|"generate_embedding"| ext1
    db -->|"vector_search"| ext1

    ui2 -->|"verification_request"| ms1
    ui2 -->|"verification_request"| ms2

    ms1 -->|"verify_aadhaar"| ext2
    ms2 -->|"automated_check"| ext3

    ms1 -->|"data_access"| db
    ms2 -->|"data_access"| db

    dataLoad -->|"import_data"| db

    conf -->|"configures"| ms1
    conf -->|"configures"| ms2
    conf -->|"configures"| ui1
    conf -->|"configures"| ui2

    %% Additional Data File Node within Data Loading Module
    dataLoad2["Data File (data/data.json)"]:::loader
    dataLoad -->|"uses"| dataLoad2

    %% Click Events
    click ui1 "https://github.com/shriyanshcode/cityassist/blob/main/cityassist.py"
    click ui2 "https://github.com/shriyanshcode/cityassist/blob/main/updated_househelp_ui.py"
    click ms1 "https://github.com/shriyanshcode/cityassist/blob/main/aadhaarchecker.py"
    click ms2 "https://github.com/shriyanshcode/cityassist/blob/main/nursechecker.py"
    click dataLoad "https://github.com/shriyanshcode/cityassist/blob/main/load.py"
    click dataLoad2 "https://github.com/shriyanshcode/cityassist/blob/main/data/data.json"
    click conf "https://github.com/shriyanshcode/cityassist/blob/main/params.py"

    %% Styling Classes
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef database fill:#FDFD96,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef loader fill:#D8BFD8,stroke:#333,stroke-width:2px;
    classDef config fill:#FFEBCD,stroke:#333,stroke-width:2px;
    classDef user fill:#FFC0CB,stroke:#333,stroke-width:2px;
```
