# royclem/taxifarereact architecture

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

- Interactive diagram: https://gitdiagram.com/royclem/taxifarereact
- Repository: https://github.com/royclem/taxifarereact

## Overview

##### Main Components

A. Frontend Layer (React):
- User Interface Components (show individual components like Vendor, NumPassengers, TripDistance, etc.)
- State Management (React's component state)
- Service Workers (as indicated by registerServiceWorker.js)

B. Backend Layer (.NET Core):
- API Controllers (SampleDataController)
- ML.NET Model Integration
- Data Access Layer (for taxi-fare.csv and Model.zip)

C. Machine Learning Component:
- Trained Model (Model.zip)
- Prediction Pipeline
- Model Input/Output (TaxiTrip.cs)

##### Component Relationships

- Frontend → Backend: HTTP/API calls
- Backend → ML Model: Prediction requests
- Data Flow: User Input → API → ML Model → Prediction Result

##### Specific Implementation Details

- Blue rectangles: React components
- Green rectangles: .NET Core components
- Purple hexagon: ML.NET model

**[User Interface Layer (React Components)]**
- ↓
**[React State Management & Services]**
- ↓
**[.NET Core API Layer]**
- ↓
**[ML.NET Model Processing]**
- ↓
**[Data Storage]**

##### Important Elements to Highlight

A. Frontend Components:
- Hierarchy of React components:
- Home component as the main container
- Child components (Vendor, NumPassengers, etc.)
- Result component for displaying predictions

B. Backend Services:
- API endpoints in SampleDataController
- Model integration points
- Data processing pipeline

C. Data Flow:
- User input collection
- API communication
- ML model prediction flow
- Result rendering

##### The component hierarchy in the React frontend

Remember to maintain clarity while showing the essential architectural elements that make this a machine learning-powered web application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI[User Interface Layer]
        Home[Home Component]:::react
        Vendor[Vendor Input]:::react
        TripDist[Trip Distance Input]:::react
        NumPass[Passengers Input]:::react
        Result[Result Display]:::react
        SW[Service Worker]:::react
        State[React State Management]:::react
        
        UI --> Home
        Home --> Vendor
        Home --> TripDist
        Home --> NumPass
        Home --> Result
        Home --> State
        State --> SW
    end

    subgraph Backend
        API[API Controller]:::netcore
        Program[Program Entry]:::netcore
        Startup[Startup Config]:::netcore
        
        API --> Program
        Program --> Startup
    end

    subgraph "ML.NET Layer"
        MLModel[ML.NET Model]:::ml
        Schema[Model Schema]:::ml
        TrainData[(Training Data)]:::data
        ModelFile[(Trained Model)]:::data
        
        Schema --> MLModel
        TrainData --> MLModel
        MLModel --> ModelFile
    end

    State -->|HTTP Requests| API
    API -->|Prediction Requests| MLModel
    MLModel -->|Predictions| API
    API -->|Response| State

    classDef react fill:#61DAFB,stroke:#000000
    classDef netcore fill:#68217A,stroke:#000000,color:#ffffff
    classDef ml fill:#FF6B6B,stroke:#000000
    classDef data fill:#FFD93D,stroke:#000000

    click Home "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/ClientApp/src/components/Home.js"
    click Vendor "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/ClientApp/src/components/Vendor.js"
    click TripDist "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/ClientApp/src/components/TripDistance.js"
    click Result "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/ClientApp/src/components/Result.js"
    click SW "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/ClientApp/src/registerServiceWorker.js"
    click API "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Controllers/SampleDataController.cs"
    click ModelFile "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Data/Model.zip"
    click TrainData "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Data/taxi-fare.csv"
    click Schema "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Models/TaxiTrip.cs"
    click Program "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Program.cs"
    click Startup "https://github.com/RoyClem/TaxiFareReact/blob/master/TaxiFareReact/Startup.cs"

    %% Legend
    subgraph Legend
        L1[React Component]:::react
        L2[.NET Core Component]:::netcore
        L3[ML.NET Component]:::ml
        L4[(Data Storage)]:::data
    end
```
