# libardolopezdev/ruta-pro-drive architecture

> Architecture diagram of the GitHub repository libardolopezdev/ruta-pro-drive, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/libardolopezdev/ruta-pro-drive
- Repository: https://github.com/libardolopezdev/ruta-pro-drive

## Overview

##### Project type and purpose
- Ruta Pro Drive is a full-stack web application for taxi/ride-share drivers to track services, calculate income/expenses, generate statistics, and manage preferences.
- Frontend: React + TypeScript (Vite, Tailwind CSS, shadcn-ui)
- Backend: Node.js REST API (connects to PostgreSQL)
- Database: PostgreSQL

##### File structure
- Top-level assets:
- public/ (static HTML, robots.txt)
- index.html, vite.config.ts, tailwind.config.ts
- Frontend app under src/:
- src/pages/ – route-level components (Index, NotFound)
- src/components/ – UI broken into Layout, Dashboard, Onboarding, Settings, Statistics, Tracking, Testing, plus shadcn-ui component library in ui/
- src/context/ – React Context for global state
- src/hooks/ – custom hooks (use-mobile, use-toast)
- src/lib/ & src/utils/ – reusable utilities and test data generators
- src/types/ – TypeScript type definitions
- main.tsx/App.tsx – app entry, routing, context provider
- Missing in file tree: backend folder (assume a Node.js/Express project lives parallel to src/, connects to .env, defines REST endpoints)

##### Key README insights
- Client-server architecture over RESTful APIs
- Use of agile Kanban, automated builds (npm run build → dist/)
- Deployment on Vercel/Netlify/GitHub Pages or Railway

a. Main components to include
- Web Browser / Client
– React App (AppLayout, Navbar)
– Modules: OnboardingFlow, Dashboard, Tracking (DayStart, DayEnd, IncomeEntry, ExpenseEntry), Statistics, Settings, Testing
– UI library (shadcn-ui primitives under src/components/ui)
– Context & Hooks (state management)
- API Layer
– HTTP/HTTPS endpoints served by Node.js backend
– Authentication middleware (if any)
- Business Logic
– Services for route registration, peaje deduction, report generation
- Data Layer
– PostgreSQL database (tables for services, drivers, platforms, reports, preferences)
- External services
– Payment gateways or mapping/geolocation APIs (if applicable)
– CDN or object storage (if static assets served externally)

b. Relationships & interactions
1. User interacts via browser → React UI events → React Router/Context triggers
2. React issues HTTP requests to backend endpoints (e.g., /api/services, /api/reports, /api/settings)
3. Backend controllers process requests, call service layer, interact with PostgreSQL via ORM/Query Builder
4. Database returns records → business logic applies peaje deductions and statistics calculations → response returned
5. React updates Context state & re-renders UI components

c. Architectural patterns & design principles
- Component-based UI (separation of concerns into Layout, feature modules, UI primitives)
- Single Page Application (SPA) with React Router for page navigation
- Context API + custom hooks for global & cross-cutting concerns (mobile detection, toasts)
- Layered architecture on backend (routers → controllers → services → data access)
- RESTful communication between client and server
- Configuration via environment variables (.env)

d. Key technologies/frameworks
- Frontend: React, TypeScript, Vite, Tailwind CSS, shadcn-ui
- Backend: Node.js, Express (or similar), npm scripts
- Database: PostgreSQL
- DevOps: Vercel / Netlify / Railway, GitHub Actions for CI/CD

##### Essential details
- Major UI modules and their dependencies on Context/hooks
- API endpoints corresponding to each feature (e.g., /services, /reports)
- Data models (ServiceRecord, DriverProfile, ReportSummary) if space permits
- Document any asynchronous flows (e.g., long-running report generation)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client / Browser Zone
    subgraph "Client / Browser"
        direction TB
        User["User"]:::external
        ReactApp["React App"]:::frontend
        User --> ReactApp

        subgraph "UI Layout"
            direction TB
            AppLayout["AppLayout"]:::frontend
            Navbar["Navbar"]:::frontend
        end

        subgraph "React Features"
            direction TB
            subgraph Onboarding
                OnboardingFlow["OnboardingFlow"]:::frontend
                DriverTypeSelection["DriverTypeSelection"]:::frontend
                PlatformSelection["PlatformSelection"]:::frontend
            end
            Dashboard["Dashboard"]:::frontend
            subgraph Tracking
                DayStart["DayStart"]:::frontend
                DayEnd["DayEnd"]:::frontend
                IncomeEntry["IncomeEntry"]:::frontend
                ExpenseEntry["ExpenseEntry"]:::frontend
                PauseButton["PauseButton"]:::frontend
            end
            StatsSummary["StatsSummary"]:::frontend
            Settings["Settings"]:::frontend
            TestDataGenerator["TestDataGenerator"]:::frontend
        end

        UILib["UI Library"]:::frontend
        subgraph "Routing Pages"
            IndexPage["Index Page"]:::frontend
            NotFoundPage["NotFound Page"]:::frontend
        end

        AppContext["AppContext"]:::frontend
        subgraph "Custom Hooks"
            UseMobile["use-mobile"]:::frontend
            UseToast["use-toast"]:::frontend
        end

        subgraph "Utilities & Helpers"
            UtilsLib["utils.ts"]:::frontend
            FormatUtil["format.ts"]:::frontend
            StorageUtil["storage.ts"]:::frontend
            TestDataUtil["testData.ts"]:::frontend
        end

        Types["types/index.ts"]:::frontend

        ReactApp --> AppLayout
        ReactApp --> Navbar
        ReactApp --> OnboardingFlow
        ReactApp --> Dashboard
        ReactApp --> DayStart
        ReactApp --> StatsSummary
        ReactApp --> Settings
        ReactApp --> TestDataGenerator
        ReactApp --> UILib
        ReactApp --> IndexPage
        ReactApp --> NotFoundPage
        ReactApp --> AppContext
        ReactApp --> UseMobile
        ReactApp --> UseToast
        ReactApp --> UtilsLib
        ReactApp --> Types

        AppLayout --> UILib
        OnboardingFlow --> DriverTypeSelection
        OnboardingFlow --> PlatformSelection
        Dashboard --> StatsSummary
        DayEnd --> PauseButton
    end

    %% Server / Database Zone
    subgraph "Server"
        direction TB
        APINode["Node.js REST API"]:::backend
        BusinessLogic["Business Logic"]:::backend
        PostgreSQL["PostgreSQL"]:::database

        APINode --> BusinessLogic
        BusinessLogic --> PostgreSQL
    end

    ReactApp -->|"HTTP/HTTPS"| APINode

    %% Click Events
    click ReactApp "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/main.tsx"
    click ReactApp "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/App.tsx"
    click AppLayout "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/Layout/AppLayout.tsx"
    click Navbar "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/Layout/Navbar.tsx"
    click OnboardingFlow "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/onboarding/OnboardingFlow.tsx"
    click DriverTypeSelection "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/onboarding/DriverTypeSelection.tsx"
    click PlatformSelection "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/onboarding/PlatformSelection.tsx"
    click Dashboard "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/dashboard/Dashboard.tsx"
    click DayStart "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/tracking/DayStart.tsx"
    click DayEnd "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/tracking/DayEnd.tsx"
    click IncomeEntry "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/tracking/IncomeEntry.tsx"
    click ExpenseEntry "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/tracking/ExpenseEntry.tsx"
    click PauseButton "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/tracking/PauseButton.tsx"
    click StatsSummary "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/statistics/StatsSummary.tsx"
    click Settings "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/settings/Settings.tsx"
    click TestDataGenerator "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/components/testing/TestDataGenerator.tsx"
    click UILib "https://github.com/libardolopezdev/ruta-pro-drive/tree/main/src/components/ui/"
    click IndexPage "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/pages/Index.tsx"
    click NotFoundPage "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/pages/NotFound.tsx"
    click AppContext "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/context/AppContext.tsx"
    click UseMobile "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/hooks/use-mobile.tsx"
    click UseToast "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/hooks/use-toast.tsx"
    click UtilsLib "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/lib/utils.ts"
    click FormatUtil "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/utils/format.ts"
    click StorageUtil "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/utils/storage.ts"
    click TestDataUtil "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/utils/testData.ts"
    click Types "https://github.com/libardolopezdev/ruta-pro-drive/blob/main/src/types/index.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D0FFD0,stroke:#028a0f,stroke-width:1px
    classDef database fill:#FFE0A0,stroke:#c98300,stroke-width:1px
    classDef external fill:#F0F0F0,stroke:#888888,stroke-width:1px
```
