# mubesy/turbopark architecture

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

- Interactive diagram: https://gitdiagram.com/mubesy/turbopark
- Repository: https://github.com/mubesy/turbopark

## Overview

##### Project Type and Purpose
- Turbo Park is a full-stack web application with a React/Redux frontend and a Flask/Python backend.
- Its goal is to accept a user address, perform geocoding (using Position Stack’s API), and retrieve parking information from INRIX’s Off Street Parking API.

##### File Structure
- At the project’s root, you see backend files like app.py and resources.py. This indicates that the Flask server handles API requests and response formatting.
- The presence of package.json, package-lock.json, and directories such as public and src (which contain React components, actions, reducers, and services) shows that the frontend is built with React and Redux.
- The src/actions, src/components, src/reducers, and src/services folders indicate a structured separation of concerns adhering to a typical React/Redux architectural pattern.
- Given these directory names, the frontend likely communicates with the backend API endpoints, while the backend performs external calls.
- The additional helper modules (in src/helpers) suggest abstraction for tasks like history or store management.

##### Main Components
- Frontend (React/Redux):
- User Interface: Represented by components in src/components (e.g., Home, Card, Input).
- State Management: Indicated by src/reducers and src/actions.
- Service Layer: Modules in src/services (like ApiService.js and CommonService.js) to handle API requests from the frontend.
- Static Assets: Served from the public folder (HTML, CSS, images).
- Backend (Flask/Python):
- API Server: Highlight app.py which likely defines endpoints to process user requests.
- Utility Modules: Include resources.py that might help with API integration or resource management.
- API Integration: Internally, the backend calls INRIX’s Off Street Parking API and Position Stack’s Geocoding API.
- External Services:
- INRIX Off Street Parking API for retrieving parking structure details.
- Stack’s Geocoding API for translating user addresses to geographical coordinates.

##### Relationship & Data Flow
- The user interacts with the interface in the frontend (React).
- Frontend components dispatch actions (using Redux) that call services (via ApiService.js) to fetch or send data.
- The frontend makes HTTP requests to specific endpoints on the Flask backend (as defined in app.py).
- Upon receiving a request, the backend communicates with external APIs (INRIX and Position Stack) to retrieve and possibly transform/aggregate data.
- The backend then sends a response back to the frontend, where the Redux store is updated and UI is rendered accordingly.

##### Architectural Patterns and Technologies
- Client-Server model: Clearly separating the concerns of client (React) and server (Flask) components.
- The MVC-like approach in the frontend: with actions, reducers, and components handling different aspects of state management and view rendering.
- API Gateway or intermediary pattern in the backend: Aggregating calls to two external services.
- Use of asynchronous operations (e.g., API calls from both the frontend and backend).
- Technologies: React.js, Redux, Flask, Python, HTML/CSS, and supporting libraries for API calls.

## Diagram (Mermaid)

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

    %% Frontend Subgraph
    subgraph "Frontend"
        UI["React UI (Components)"]:::frontend
        ACT["Redux Actions"]:::frontend
        RED["Redux Reducers"]:::frontend
        SRV["Service Layer (API Services)"]:::frontend
        STATIC["Static Assets"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        API["Flask API Server (app.py)"]:::backend
        UTIL["Utility Module (resources.py)"]:::backend
    end

    %% External APIs Subgraph
    subgraph "External APIs"
        INRIX["INRIX Off Street Parking API"]:::external
        POS["Position Stack Geocoding API"]:::external
    end

    %% Data Flow Connections (vertical flow)
    USER -->|"initiates"| UI
    UI -->|"dispatches"| ACT
    UI -->|"dispatches"| RED
    ACT -->|"calls"| SRV
    RED -->|"updates"| UI
    STATIC --- UI
    SRV -->|"sends HTTP request"| API
    API -->|"calls"| INRIX
    API -->|"calls"| POS
    UTIL --- API

    %% Click Events for Component Mapping
    click UI "https://github.com/mubesy/turbopark/tree/main/src/components/"
    click ACT "https://github.com/mubesy/turbopark/tree/main/src/actions/"
    click RED "https://github.com/mubesy/turbopark/tree/main/src/reducers/"
    click SRV "https://github.com/mubesy/turbopark/tree/main/src/services/"
    click STATIC "https://github.com/mubesy/turbopark/tree/main/public/"
    click API "https://github.com/mubesy/turbopark/blob/main/app.py"
    click UTIL "https://github.com/mubesy/turbopark/blob/main/resources.py"

    %% Style Definitions with Colours
    classDef frontend fill:#fef9c3,stroke:#eab308,stroke-width:2px;
    classDef backend fill:#bbf7d0,stroke:#047857,stroke-width:2px;
    classDef external fill:#c7d2fe,stroke:#4338ca,stroke-width:2px;
    classDef user fill:#fecaca,stroke:#b91c1c,stroke-width:2px;

    class USER user;
    class UI,ACT,RED,SRV,STATIC frontend;
    class API,UTIL backend;
    class INRIX,POS external;
```
