# mendsalbert/zero-to-hero architecture

> Architecture diagram of the GitHub repository mendsalbert/zero-to-hero, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mendsalbert/zero-to-hero
- Repository: https://github.com/mendsalbert/zero-to-hero

## Overview

##### Main System Components

a) Frontend Layer
- Next.js Application (App Router structure)
- UI Components
- Client-side Features

b) Backend Layer
- API Routes (implied by Next.js structure)
- Database Integration (indicated by drizzle.config.js)
- Blockchain Integration

c) External Services
- DIMO Integration
- Smart Contract Interactions
- Services

##### Component Organization

A. Client-Side Components:
- Core Components
- Header
- Sidebar
- UserDashboard
- Feature Components
- DimoEcoScore
- DimoVehicleData
- ContractInteraction
- Map
- UI Components (Shadcn/UI based)

B. Page Routes:
- Main Routes
- Collect
- Leaderboard
- Messages
- Report
- Rewards
- Settings
- Verify

Use these visual elements:

- Rectangles: Core components
- Rounded rectangles: Pages/Routes
- Hexagons: External services
- Clouds: Blockchain/Web3 elements

- Blue: Frontend components
- Green: Backend services
- Purple: Database
- Orange: Blockchain/Smart Contracts
- Yellow: External APIs

##### Frontend to Backend
**User Interface ←→ Next.js API Routes ←→ Database**

##### Blockchain Integration
**ContractInteraction Component ←→ Smart Contracts ←→ Blockchain Network**

##### DIMO Integration
**DimoVehicleData/DimoEcoScore ←→ DIMO API ←→ Vehicle Data**

##### Technical Stack Elements

- Next.js 13+ (App Router)
- Drizzle ORM
- Tailwind CSS
- Shadcn/UI
- Web3 Integration
- Services
- DIMO SDK/API

**[User Interface Layer]**
- ↓
**[Application Logic Layer]**
- ↓
**[Data Access Layer]**
- ↓
**[External Services Layer]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        direction TB
        CoreUI["Core UI Components"]
        FeatureUI["Feature Components"]
        UILib["UI Component Library"]
        
        subgraph "Core Components"
            Header["Header"]:::component
            Sidebar["Sidebar"]:::component
            UserDash["UserDashboard"]:::component
        end
        
        subgraph "Feature Components"
            DimoEco["DimoEcoScore"]:::component
            DimoVehicle["DimoVehicleData"]:::component
            Contract["ContractInteraction"]:::component
            MapComp["Map Component"]:::component
        end
        
        subgraph "UI Library"
            Button["Button"]:::component
            Input["Input"]:::component
            Select["Select"]:::component
            Dropdown["Dropdown"]:::component
        end
    end
    
    subgraph "Application Layer"
        direction TB
        subgraph "Main Routes"
            Collect["Collect"]:::route
            Leaderboard["Leaderboard"]:::route
            Messages["Messages"]:::route
            Report["Report"]:::route
            Rewards["Rewards"]:::route
            Settings["Settings"]:::route
            Verify["Verify"]:::route
        end
    end
    
    subgraph "Data Layer"
        direction TB
        DB[(Database)]:::database
        DBConfig["Database Config"]:::config
        Schema["Schema"]:::config
        DBActions["DB Actions"]:::config
    end
    
    subgraph "External Services"
        direction TB
        DimoAPI["DIMO API"]:::external
        Blockchain["Blockchain Network"]:::external
        MapService["Map Services"]:::external
    end
    
    %% Connections
    CoreUI --> Header & Sidebar & UserDash
    FeatureUI --> DimoEco & DimoVehicle & Contract & MapComp
    UILib --> Button & Input & Select & Dropdown
    
    DimoEco -.-> DimoAPI
    DimoVehicle -.-> DimoAPI
    Contract -.-> Blockchain
    MapComp -.-> MapService
    
    DBConfig --> DB
    Schema --> DB
    DBActions --> DB
    
    %% Click Events
    click Header "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/Header.tsx"
    click Sidebar "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/Sidebar.tsx"
    click UserDash "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/UserDashboard.tsx"
    click DimoEco "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/DimoEcoScore.tsx"
    click DimoVehicle "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/DimoVehicleData.tsx"
    click Contract "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/ContractInteraction.tsx"
    click MapComp "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/Map.tsx"
    click Button "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/ui/button.tsx"
    click Input "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/ui/input.tsx"
    click Select "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/ui/select.tsx"
    click Dropdown "https://github.com/mendsalbert/zero-to-hero/blob/main/src/components/ui/dropdown-menu.tsx"
    click Collect "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/collect/page.tsx"
    click Leaderboard "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/leaderboard/page.tsx"
    click Messages "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/messages/page.tsx"
    click Report "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/report/page.tsx"
    click Rewards "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/rewards/page.tsx"
    click Settings "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/settings/page.tsx"
    click Verify "https://github.com/mendsalbert/zero-to-hero/blob/main/src/app/verify/page.tsx"
    click DBConfig "https://github.com/mendsalbert/zero-to-hero/blob/main/src/utils/db/dbConfig.jsx"
    click Schema "https://github.com/mendsalbert/zero-to-hero/blob/main/src/utils/db/schema.ts"
    click DBActions "https://github.com/mendsalbert/zero-to-hero/blob/main/src/utils/db/actions.ts"
    
    %% Styles
    classDef component fill:#a8dadc,stroke:#457b9d
    classDef route fill:#e63946,stroke:#1d3557,color:#f1faee
    classDef database fill:#457b9d,stroke:#1d3557
    classDef config fill:#f1faee,stroke:#1d3557
    classDef external fill:#fca311,stroke:#14213d
    
    %% Legend
    subgraph Legend
        direction TB
        L1["Component"]:::component
        L2["Route"]:::route
        L3[(Database)]:::database
        L4["Configuration"]:::config
        L5["External Service"]:::external
    end
```
