# thuanbui2611/motormate-fe architecture

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

- Interactive diagram: https://gitdiagram.com/thuanbui2611/motormate-fe
- Repository: https://github.com/thuanbui2611/motormate-fe

## Overview

##### Main Components
- Client Web Application (React + TypeScript + Redux Toolkit)
- Admin-Panel Web Application (React + TypeScript + Redux Toolkit)
- Backend API (.NET Core 6.0 RESTful API, SignalR Hub)
- Database (PostgreSQL via Entity Framework Core)
- External Services:
– Cloudinary (image storage & CDN)
– Stripe (payment processing)
– Google Maps API (maps & geolocation)
– GeoLocation API (visitor location lookup)
- DevOps and Infrastructure:
– Azure Pipelines (CI/CD via azure-build-deploy.yml)
– Terraform scripts (infrastructure as code—Azure resources)
– GitHub (source repo, version control)
– Azure App Service or Azure Static Web Apps (hosting front-ends)
– Azure Container Registry / App Service (hosting backend)

##### Relationships & Data-Flows
– User’s browser ↔ HTTPS ↔ Client Web App & Admin Web App
– Web Apps ↔ HTTPS (REST calls) ↔ .NET Core API
– Web Apps ↔ WebSocket ↔ SignalR Hub (for real-time chat)
– API ↔ PostgreSQL (SQL queries via EF Core)
– API ↔ Cloudinary (upload/download images)
– API ↔ Stripe (payment intents, confirmations)
– Client Web App ↔ Google Maps API & GeoLocation API (direct calls from browser)
– DevOps pipelines ↔ GitHub (trigger on push) ↔ Azure infra (build → test → deploy)

##### Architectural Patterns & Principles
– Front-end: Single-Page Applications (SPA) with Redux for state management
– Back-end: Layered architecture (Controllers → Services → Repositories)
– Real-time: SignalR Hub follows pub/sub pattern for chat
– Infrastructure as Code: Terraform ensures idempotent resource provisioning
– CI/CD: Azure Pipelines for continuous integration and zero-downtime deployments

##### Diagramming Conventions
– Components: use rectangles with clear labels (e.g., “Client Web App”, “.NET Core API”)
- Blue for front-end components
- Green for back-end components
- Orange for external services
- Grey for DevOps/infrastructure

##### Essential Details to Capture
– Both front-ends share the same API agent.ts and models for consistency.
– The API uses EF Core migrations for DB schema.
– The real-time chat functionality is powered by SignalR—treat it as a separate sub-component.
– Payment integration includes both client-side (Stripe Elements) and server-side webhooks.
– DevOps: show the azure-build-deploy.yml file triggering builds on push and deploying via Terraform.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Frontend Layer"
        direction TB
        BrowserC["Browser"]:::frontend
        BrowserA["Browser"]:::frontend
        BrowserC -->|HTTPS| ClientApp
        BrowserA -->|HTTPS| AdminApp

        subgraph "Client Web App"
            direction TB
            ClientApp["Client Web App\nReact + TypeScript + Redux Toolkit + TailwindCSS"]:::frontend
            AgentC["API Agent (agent.ts)"]:::frontend
            ModelsC["Models Directory"]:::frontend
            StoreC["Redux Store (ConfigureStore)"]:::frontend
            UtilsC["Cloudinary Utils"]:::frontend
            RouterC["Routing Setup"]:::frontend
            TailwindC["Tailwind Config"]:::frontend
            ChatSlice["Chat Slice (SignalR)"]:::frontend
            ClientApp --> AgentC
            ClientApp --> ModelsC
            ClientApp --> StoreC
            ClientApp --> UtilsC
            ClientApp --> RouterC
            ClientApp --> TailwindC
            ClientApp --> ChatSlice
        end

        subgraph "Admin Web App"
            direction TB
            AdminApp["Admin-Panel Web App\nReact + TypeScript + Redux Toolkit + TailwindCSS"]:::frontend
            AgentA["API Agent (agent.ts)"]:::frontend
            ModelsA["Models Directory"]:::frontend
            StoreA["Redux Store (ConfigureStore)"]:::frontend
            UtilsA["Cloudinary Utils"]:::frontend
            RouterA["Routing Setup"]:::frontend
            TailwindA["Tailwind Config"]:::frontend
            ChatCard["Chat Card Component"]:::frontend
            AdminApp --> AgentA
            AdminApp --> ModelsA
            AdminApp --> StoreA
            AdminApp --> UtilsA
            AdminApp --> RouterA
            AdminApp --> TailwindA
            AdminApp --> ChatCard
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        API[".NET Core API\nRESTful API ( .NET 6.0 )"]:::backend
        SignalR["SignalR Hub"]:::backend
        API --> SignalR
    end

    %% Data & Storage Layer
    subgraph "Data & Storage Layer"
        direction TB
        DB["PostgreSQL\n(Entity Framework Core)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary"]:::external
        Stripe["Stripe"]:::external
        GoogleMaps["Google Maps API"]:::external
        GeoLocation["GeoLocation API"]:::external
    end

    %% DevOps & Infrastructure
    subgraph "DevOps & Infrastructure"
        direction TB
        GitHub["GitHub (Repo)"]:::infra
        Pipelines["Azure Pipelines\n(azure-build-deploy.yml)"]:::infra
        Terraform["Terraform Scripts"]:::infra
        HostingFront["Azure Static Web Apps / App Service"]:::infra
        HostingBack["Azure Container Registry / App Service"]:::infra
        GitHub --> Pipelines --> Terraform
        Terraform --> HostingFront
        Terraform --> HostingBack
    end

    %% Connections
    ClientApp -->|REST API calls| API
    AdminApp -->|REST API calls| API
    ClientApp -->|WebSocket| SignalR
    AdminApp -->|WebSocket| SignalR
    API -->|SQL Queries| DB
    API -->|Image upload/download| Cloudinary
    API -->|Payment intents & webhooks| Stripe
    BrowserC -->|Maps API calls| GoogleMaps
    BrowserC -->|GeoLocation API calls| GeoLocation

    %% Click Events
    click AgentC "https://github.com/thuanbui2611/motormate-fe/blob/main/client/src/app/api/agent.ts"
    click AgentA "https://github.com/thuanbui2611/motormate-fe/blob/main/admin-panel/src/app/api/agent.ts"
    click ModelsC "https://github.com/thuanbui2611/motormate-fe/tree/main/client/src/app/models/"
    click ModelsA "https://github.com/thuanbui2611/motormate-fe/tree/main/admin-panel/src/app/models/"
    click StoreC "https://github.com/thuanbui2611/motormate-fe/blob/main/client/src/app/store/ConfigureStore.tsx"
    click StoreA "https://github.com/thuanbui2611/motormate-fe/blob/main/admin-panel/src/app/store/ConfigureStore.tsx"
    click UtilsC "https://github.com/thuanbui2611/motormate-fe/blob/main/client/src/app/utils/Cloudinary.ts"
    click UtilsA "https://github.com/thuanbui2611/motormate-fe/blob/main/admin-panel/src/app/utils/Cloudinary.ts"
    click TailwindC "https://github.com/thuanbui2611/motormate-fe/blob/main/client/tailwind.config.js"
    click TailwindA "https://github.com/thuanbui2611/motormate-fe/blob/main/admin-panel/tailwind.config.js"
    click Pipelines "https://github.com/thuanbui2611/motormate-fe/blob/main/pipelines/azure-build-deploy.yml"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef external fill:#FFF3E0,stroke:#E65100,color:#E65100
    classDef infra fill:#ECEFF1,stroke:#37474F,color:#37474F
```
