# smit-sms/sustainable-city-management architecture

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

- Interactive diagram: https://gitdiagram.com/smit-sms/sustainable-city-management
- Repository: https://github.com/smit-sms/sustainable-city-management

## Overview

##### Main Components and Their Purpose
- SCM (Sustainable City Management) – This appears to be the core full-stack module:
○ Backend: Built with Django (look for files like manage.py, settings.py, and various apps such as authentication, cityservices, sensors, tsa). It interacts with a PostgreSQL database.
○ Frontend: A React-based single-page application (files in SCM/Frontend with npm, Tailwind, and component structure). It communicates with the backend via RESTful APIs.
- ETLPipelinePy3.11Mod – A Python ETL pipeline module. It features ETL scripts (etl_task.py, etl_db_manager.py, utility.py) along with its own tests and requirements, showing it is likely used for data ingestion and processing.
- ThinSlice – Another full-stack module with its separate Backend and Frontend components structured similarly to SCM; this likely handles a specialty microservice or data slice (perhaps real-time or specific data views) within the sustainable management domain.
- TimeSeriesAnalysis – This module appears to focus on analyzing and visualizing time series data:
○ Backend: Again, a Django project with an app (tsa) managing time series data.

##### Relationships and Data Flow
- The Central SCM module acts as the core orchestrator – the frontend (React) communicates with the Django backend.
- The Django backend itself is split into several apps (authentication, cityservices, sensors, tsa) that likely interact with a central PostgreSQL database.
- The ETL pipeline processes data (possibly external or raw city data) and populates databases used by the SCM backend.
- ThinSlice and TimeSeriesAnalysis could be micro-services/subsystems that either offer complementary functionality or focused views of the data. Their backends interact with separate (or shared) databases and expose API endpoints that the respective frontends consume.
- The overall system design likely has external integration points – e.g., a PostgreSQL database cluster and possibly third-party services (e.g., for model files or CSV datasets as seen in the file tree).

##### Architectural Patterns and Technologies
- Separation of concerns: The clear distinction between Frontend and Backend is maintained in SCM, with additional modules isolated (ETL, ThinSlice, and TimeSeriesAnalysis).
- Microservices-like modularity: Even though SCM is the main app, additional modules exist independently. Each has its own service boundaries (e.g., independent Dockerfiles and setup instructions).
- Use of containerization: Presence of Dockerfiles and a .dockerignore in several directories imply that containerization is part of the deployment strategy.
- External Database Integration: PostgreSQL setup with pgAdmin instructions is critical to the backend data management.
- Tech stack highlights:
– Backend: Django, Python 3.11, and associated pip requirements
– Frontend: React, TailwindCSS, Node.js (v20.9.0 via nvm), and supporting libraries
– ETL: Custom Python pipelines for data extraction, transformation, and loading.

- Clear labels for every component and module.
- Annotations with technology names (e.g., Django, React, PostgreSQL, Docker).
- A segmentation that makes it clear which modules are part of the SCM core and which are additional specialized functionalities (ThinSlice and TimeSeriesAnalysis).
- Optionally, you might include a notation of the deployment environment (AWS for the deployed SCM and containerization aspects).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "SCM Module"
        scm_fe["SCM Frontend (React/Node)"]:::frontend
        scm_be["SCM Backend (Django/Python, apps: auth,cityservices,sensors,tsa)"]:::backend
    end

    subgraph "ThinSlice Module"
        thin_fe["ThinSlice Frontend (React/Node)"]:::frontend
        thin_be["ThinSlice Backend (Django/Python)"]:::backend
    end

    subgraph "TimeSeriesAnalysis Module"
        tsadash["TSADashboard Frontend (React/Node)"]:::frontend
        tsa_be["TimeSeriesAnalysis Backend (Django/tsa)"]:::backend
    end

    etl["ETL Pipeline Module (Python)"]:::etl
    db["PostgreSQL Database"]:::database
    ext["External Data Sources (CSV,sensordata,models)"]:::external

    %% Connections for SCM Module
    scm_fe -->|"REST_API"| scm_be
    scm_be -->|"DB_queries"| db

    %% Connections for ThinSlice Module
    thin_fe -->|"REST_API"| thin_be

    %% Connections for TimeSeriesAnalysis Module
    tsadash -->|"API_call"| tsa_be
    tsa_be -->|"DB_queries"| db

    %% ETL Pipeline and External Data Flow
    etl -->|"Data_ingestion"| db
    ext -->|"Feeds_Data"| etl

    %% Click Events
    click scm_be "https://github.com/smit-sms/sustainable-city-management/tree/main/SCM/Backend"
    click scm_fe "https://github.com/smit-sms/sustainable-city-management/tree/main/SCM/Frontend"
    click etl "https://github.com/smit-sms/sustainable-city-management/blob/main/ETLPipelinePy3.11Mod"
    click thin_be "https://github.com/smit-sms/sustainable-city-management/tree/main/ThinSlice/Backend"
    click thin_fe "https://github.com/smit-sms/sustainable-city-management/tree/main/ThinSlice/frontend"
    click tsa_be "https://github.com/smit-sms/sustainable-city-management/tree/main/TimeSeriesAnalysis/Backend/tsa"
    click tsadash "https://github.com/smit-sms/sustainable-city-management/tree/main/TimeSeriesAnalysis/TSADashboard"

    %% Styles
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px,color:#000;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,color:#000;
    classDef database fill:#FFECB3,stroke:#FF6F00,stroke-width:2px,color:#000;
    classDef etl fill:#F8BBD0,stroke:#AD1457,stroke-width:2px,color:#000;
    classDef external fill:#D1C4E9,stroke:#512DA8,stroke-width:2px,color:#000;
```
