# shashankhmg/citybikes-nypd-streamlitapp architecture

> Architecture diagram of the GitHub repository shashankhmg/citybikes-nypd-streamlitapp, 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/shashankhmg/citybikes-nypd-streamlitapp
- Repository: https://github.com/shashankhmg/citybikes-nypd-streamlitapp

## Overview

##### Project’s Main Components
- Streamlit Frontend: The entry point is main.py along with a structured “pages” directory (risk_prediction.py, demand_prediction.py, and overview.py) and a sidebar component. These handle UI routing, user interactions, and page layout.
- Data Assets: The “data” directory holds data files (pre-processed JSON of station data and an optimized heatmap HTML file) used for rendering visual insights.
- Machine Learning Models: Inside the “models” directory, you have a saved model file (e.g., DT.joblib) used for predictions in at least one module. Additionally, the README explains that the demand prediction model is hosted externally on Hugging Face and served via a FastAPI endpoint on Railway.
- External Services / Backend API: The demand prediction module relies on an external model API (FastAPI service deployed on Railway) and model storage on Hugging Face Hub.

##### Component Roles and Interactions
- User Interactions: The user accesses the Streamlit app (deployed on Streamlit Cloud) to explore visualizations, perform risk prediction and demand prediction.
- Internal Data Flow:
- The Streamlit frontend retrieves station data from local JSON files (in the “data” folder).
- For EDA and visualization, it may use pre-processed HTML or use dynamic Pandas/NumPy operations.
- The sidebar and pages coordinate to offer navigation between introduction, data analysis, risk prediction, and demand prediction pages.
- ML Model Integration:
- Locally stored models (in “models”) are used for some calculations.
- Configuration & Deployment:
- The .devcontainer and .streamlit folders indicate a consistent development and deployment environment. Label these as “Development Environment” components ensuring developers have containerized and configuration-driven workspaces.

##### Final Recommendations
- Clear, concise labels for each component.
· For UI components (e.g., blue for Streamlit interface items).
· For data storage and processing layers (e.g., green for data directories and local models).
· For external services (e.g., red or orange for external API endpoints).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User"):::user

    subgraph "Streamlit Frontend"
        UI_Main["main.py"]:::frontend
        UI_Pages_Risk["Risk Prediction (risk_prediction.py)"]:::frontend
        UI_Pages_Demand["Demand Prediction (demand_prediction.py)"]:::frontend
        UI_Pages_Overview["Overview (overview.py)"]:::frontend
        UI_Sidebar["Sidebar (sidebar.py)"]:::frontend
        UI_Config["Config (.streamlit/config.toml)"]:::frontend
    end

    DataSource["Local Data Source (data)"]:::data
    LocalModel["Local ML Model (DT.joblib)"]:::data
    ExternalAPI["External ML Model API (FastAPI on Railway)"]:::external
    DevEnv["Development & Deployment Env"]:::dev
    StreamlitCloud["Streamlit Cloud (Deployment)"]:::dev
    Railway["Railway (Deployment)"]:::external

    %% User Interaction and Routing
    User -->|"uses"| UI_Main
    UI_Main -->|"navigates_to"| UI_Pages_Risk
    UI_Main -->|"navigates_to"| UI_Pages_Demand
    UI_Main -->|"navigates_to"| UI_Pages_Overview
    UI_Main -->|"includes"| UI_Sidebar

    %% Data and Model Integration
    UI_Main -->|"loads"| DataSource
    UI_Pages_Risk -->|"loads"| DataSource
    UI_Pages_Demand -->|"loads"| DataSource
    UI_Pages_Overview -->|"loads"| DataSource

    UI_Main -->|"calls"| LocalModel
    UI_Pages_Demand -->|"requests_prediction"| ExternalAPI
    ExternalAPI -->|"returns_prediction"| UI_Pages_Demand

    %% Development and Deployment
    DevEnv -->|"configures"| UI_Main
    UI_Main -->|"deployed_on"| StreamlitCloud
    ExternalAPI -->|"hosted_on"| Railway

    %% Click Events
    click UI_Main "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/main.py"
    click UI_Pages_Risk "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/pages/risk_prediction.py"
    click UI_Pages_Demand "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/pages/demand_prediction.py"
    click UI_Pages_Overview "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/pages/overview.py"
    click UI_Sidebar "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/sidebar.py"
    click UI_Config "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/.streamlit/config.toml"
    click DataSource "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/tree/main/data/"
    click LocalModel "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/models/DT.joblib"
    click DevEnv "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/blob/main/.devcontainer/devcontainer.json"
    click DevEnv "https://github.com/shashankhmg/citybikes-nypd-streamlitapp/tree/main/.streamlit/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef data fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef dev fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef user fill:#FFD700,stroke:#000,stroke-width:1px;
```
