# sailesh1200/market-direct-connect architecture

> Architecture diagram of the GitHub repository sailesh1200/market-direct-connect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sailesh1200/market-direct-connect
- Repository: https://github.com/sailesh1200/market-direct-connect

## Overview

##### Project type and purpose
- This is a single‑page React application built with Vite and TypeScript. It uses shadcn‑ui (a Tailwind‑based component library) to render a multi‑role marketplace UI for buyers and farmers (plus an admin dashboard). There is no custom backend in this repository—data is fetched by a service layer (DataSyncService) from external APIs.

##### File structure
- Top‑level files & config
- package.json, vite.config.ts, tsconfig.json, tailwind.config.ts, etc. define dev/build settings.
- public/ holds static assets (robots.txt, index.html).
- Source code (src/)
- main.tsx boots the React app & router.
- App.tsx contains global layout (Navbar, footer, routes).
- pages/ holds page‑level components (HomePage, MarketPage, dashboard pages, auth pages, etc.).
- components/ subdivided by feature (auth, buyer, farmer, dashboard, market, home) plus a ui/ folder for generic UI primitives.
- services/DataSyncService.ts is the single point for all API calls.
- contexts/LanguageContext provides i18n context.
- hooks/ and lib/utils.ts provide reusable logic.
- data/mockData.ts contains test/mocks.

##### README for additional insights
- Confirms the stack: Vite, TypeScript, React, shadcn‑ui, Tailwind CSS.
- App is hosted via Lovable (providing dev server, build & publish).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client-side application
    subgraph "Browser (Client-side)" 
        subgraph "React SPA" 
            subgraph "Presentation Layer" 
                Pages["Pages"]:::frontend
                Index["Index.tsx"]:::frontend
                HomePage["HomePage.tsx"]:::frontend
                MarketPage["MarketPage.tsx"]:::frontend
            end
            subgraph "Feature Components" 
                AuthForm["AuthForm.tsx"]:::frontend
                ProductFeed["ProductFeed.tsx"]:::frontend
                AddProductSection["AddProductSection.tsx"]:::frontend
                PriceCard["PriceCard.tsx"]:::frontend
                AdminDataTabs["AdminDataTabs.tsx"]:::frontend
                Hero["Hero.tsx"]:::frontend
            end
            subgraph "UI Primitives" 
                UIP["shadcn‑ui / Tailwind"]:::frontend
            end
            subgraph "State & Context Layer" 
                LanguageContext["LanguageContext.tsx"]:::frontend
                UseMobile["use-mobile.tsx"]:::frontend
                UseToast["use-toast.tsx"]:::frontend
                Utils["utils.ts"]:::frontend
            end
            subgraph "Service Layer" 
                DataSyncService["DataSyncService.ts"]:::service
            end
        end
    end

    %% Build & Dev Pipeline
    subgraph "Build & Dev Pipeline" 
        ViteDev["Vite Dev Server"]:::build
        TailwindCFG["tailwind.config.ts"]:::build
        TSConfig["tsconfig.json"]:::build
    end

    %% Hosting & External
    subgraph "Hosting & CDN" 
        CDN["Lovable CDN"]:::external
        StaticAssets["Static Assets"]:::external
    end

    subgraph "External API Services" 
        API["External REST/GraphQL APIs"]:::external
    end

    %% User interaction & data flow
    User["User"]:::external -->|interacts| Index
    Index -->|"routes to"| Pages
    Pages -->|"renders"| ProductFeed
    ProductFeed -->|fetch via| DataSyncService
    DataSyncService -->|HTTP requests| API
    API -->|responses| DataSyncService
    DataSyncService -->|updates state| LanguageContext

    %% Dev and Prod flows
    ViteDev -->|serves SPA| User
    ViteDev -->|uses| Pages
    TailwindCFG -->|used in| ViteDev
    TSConfig -->|configures| ViteDev
    Pages -->|built by| ViteDev

    DataSyncService -->|bundled into| ViteDev
    UIP -->|styled by| TailwindCFG

    ViteDev -->|build outputs| StaticAssets
    StaticAssets -->|deployed to| CDN
    CDN -->|serves SPA to| User

    %% Click Events
    click ViteDev "https://github.com/sailesh1200/market-direct-connect/blob/main/vite.config.ts"
    click TailwindCFG "https://github.com/sailesh1200/market-direct-connect/blob/main/tailwind.config.ts"
    click TSConfig "https://github.com/sailesh1200/market-direct-connect/blob/main/tsconfig.json"
    click StaticAssets "https://github.com/sailesh1200/market-direct-connect/blob/main/public/index.html"
    click StaticAssets "https://github.com/sailesh1200/market-direct-connect/blob/main/public/robots.txt"
    click Index "https://github.com/sailesh1200/market-direct-connect/blob/main/src/pages/Index.tsx"
    click HomePage "https://github.com/sailesh1200/market-direct-connect/blob/main/src/pages/HomePage.tsx"
    click MarketPage "https://github.com/sailesh1200/market-direct-connect/blob/main/src/pages/MarketPage.tsx"
    click AuthForm "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/auth/AuthForm.tsx"
    click ProductFeed "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/buyer/ProductFeed.tsx"
    click AddProductSection "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/farmer/AddProductSection.tsx"
    click PriceCard "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/market/PriceCard.tsx"
    click AdminDataTabs "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/dashboard/AdminDataTabs.tsx"
    click Hero "https://github.com/sailesh1200/market-direct-connect/blob/main/src/components/home/Hero.tsx"
    click UIP "https://github.com/sailesh1200/market-direct-connect/tree/main/src/components/ui/"
    click LanguageContext "https://github.com/sailesh1200/market-direct-connect/blob/main/src/contexts/LanguageContext.tsx"
    click UseMobile "https://github.com/sailesh1200/market-direct-connect/blob/main/src/hooks/use-mobile.tsx"
    click UseToast "https://github.com/sailesh1200/market-direct-connect/blob/main/src/hooks/use-toast.tsx"
    click Utils "https://github.com/sailesh1200/market-direct-connect/blob/main/src/lib/utils.ts"
    click DataSyncService "https://github.com/sailesh1200/market-direct-connect/blob/main/src/services/DataSyncService.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6;
    classDef service fill:#E6FFFA,stroke:#00875A;
    classDef build fill:#FFE8A1,stroke:#FF8B00;
    classDef external fill:#F2F2F2,stroke:#666666;
```
