# rewiringamerica/incentives-visualizer architecture

> Architecture diagram of the GitHub repository rewiringamerica/incentives-visualizer, 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/rewiringamerica/incentives-visualizer
- Repository: https://github.com/rewiringamerica/incentives-visualizer

## Overview

##### Project Type & Purpose
- This is a web-based full-stack application (with a focus on the frontend) that visualizes electrification incentives on a map.
- It uses a range of React components to render the UI, along with integrated mapping (via MapTiler API) and geojson data, to estimate and display incentives based on the user’s location.

##### Breaking Down the File Structure
- Frontend Components:
- The “src” directory is the heart of the project. Within it:
- “components/”: Contains React components such as Map.tsx, App.tsx, Navbar.tsx, Sidebar.tsx, and others. These represent the core UI elements.
- “styles/”: Includes Tailwind CSS configurations and custom styles.
- “index.html”: The main entry point for the application.
- “data/”: Provides geojson files and other related data sources (e.g., state abbreviations, counties, etc.) that the application uses to build the visualizations.
- “lib/”: Contains utility files like “api.ts,” which likely abstracts API interactions – possibly with external mapping or incentive data services.
- “types/”: Includes TypeScript definitions, including generated API types.

- Testing & CI/CD:
- The “test” directory and associated configurations (Playwright, Vitest, etc., in the workflows) show that the project emphasizes end-to-end and unit testing.
- Configurations in the “.github” directory point to CI/CD setups, ensuring code quality.

- Build & Configuration Files:
- Files like “package.json”, “tsconfig.json”, and CI workflows set up the overall project dependencies and build/test procedures.
- Linters and formatters (.eslintrc, .prettierrc, etc.) ensure code standards.

##### Elements
- Clear Labels: Use labels like “React UI Components,” “Data Layer,” “API Integration,” “Testing Suite,” etc.

- User interactions flowing to UI components.
- API module communicating with external services (MapTiler and possibly state incentive data sources).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User Interactions"):::external
    Entry("Entry Point (index.html)"):::config
    ReactApp("Client Application"):::frontend

    subgraph "React UI Components"
        App("App"):::frontend
        Navbar("Navbar"):::frontend
        Sidebar("Sidebar"):::frontend
        Map("Map"):::frontend
        Legend("Legend"):::frontend
    end

    Assets("Static Assets"):::assets
    Styles("Styling (Tailwind CSS)"):::config

    subgraph "Data Layer"
        Geojson("GeoJSON Files"):::data
        Abbrev("Abbrevs To Full"):::data
        States("States Data"):::data
    end

    API("API Integration (api.ts)"):::api
    External("MapTiler API"):::external
    Types("Type Definitions (TypeScript)"):::config
    Testing("Testing Suite"):::testing
    CI("CI/CD Configuration"):::config

    User --> Entry
    Entry --> ReactApp
    ReactApp --> App
    ReactApp --> Navbar
    ReactApp --> Sidebar
    ReactApp --> Map
    ReactApp --> Legend
    Assets --> ReactApp
    Styles --> ReactApp

    Map -->|"consumes"| Geojson
    App -->|"calls"| API
    API -->|"fetches"| External
    API -->|"uses"| Types

    CI -.-> Testing
    Testing -.-> ReactApp

    click App "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/components/App.tsx"
    click Navbar "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/components/Navbar.tsx"
    click Sidebar "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/components/Sidebar.tsx"
    click Map "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/components/Map.tsx"
    click Legend "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/components/Legend.tsx"
    click Assets "https://github.com/rewiringamerica/incentives-visualizer/tree/main/src/assets"
    click Styles "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/styles/index.css"
    click Geojson "https://github.com/rewiringamerica/incentives-visualizer/tree/main/src/data/geojson"
    click Abbrev "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/data/abbrevsToFull.tsx"
    click States "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/data/states.ts"
    click API "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/lib/api.ts"
    click Entry "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/index.html"
    click Types "https://github.com/rewiringamerica/incentives-visualizer/blob/main/src/types/api.gen.ts"
    click Testing "https://github.com/rewiringamerica/incentives-visualizer/tree/main/test"
    click CI "https://github.com/rewiringamerica/incentives-visualizer/tree/main/.github/workflows"

    classDef frontend fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef data fill:#ABEBC6,stroke:#27AE60,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef config fill:#F5CBA7,stroke:#E67E22,stroke-width:2px;
    classDef testing fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef assets fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
```
