# dexxeth/trade-harvest architecture

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

- Interactive diagram: https://gitdiagram.com/dexxeth/trade-harvest
- Repository: https://github.com/dexxeth/trade-harvest

## Overview

##### Project type and purpose
- This is a full-stack web application built with Next.js (App Router) called “trade-harvest,” likely an e-commerce/marketplace site (cart, explore, profile, messaging, upload listings).
- There is also an `android/` folder, implying a native mobile client or build artifacts, but the primary code is a Next.js app under `src/app`.

##### File structure
- Top-level config files: next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json, .eslintrc.json.
- `src/app/`: Next.js App Router routes. Folders like `(auth)`, `(root)`, nested route groups for sign-in, sign-up, home with subpages (cart, explore, profile, messaging, upload).
- `src/components/`: React component library, subdivided into `ui/` for primitives (Button, Card, Input, etc.) and domain components (Navbar, News, Trending, etc.).
- `src/app/data/`: static data modules (carousel.ts, items.ts, news.ts, plus products.json).
- `src/components/ProductsContext.tsx`: React Context for global product state.
- `src/lib/utils.ts`, `src/middleware.ts`: utility functions and Next.js middleware.

##### Key architectural patterns
- File-based routing (Next.js App Router).
- Server and Client Components: pages under `src/app` default to server, some React components (likely marked "use client") for interactivity.
- Component library / design system under `src/components/ui`.
- Global state via React Context (`ProductsContext`).
- Static data for prototyping (JSON and TS modules), potential for Server-Side Rendering (SSR) or Static Site Generation (SSG).
- Build and deployment via Vercel (serverless functions behind each route).

##### Main components
b. Next.js Server (hosted on Vercel or similar)
- App Router (Route Handlers, Server Components)
- Middleware
- API Routes or Data Fetching Layer
c. React Component Library
- UI Primitives (`src/components/ui`)
- Domain Components (`Navbar`, `Cart`, `Messaging`, etc.)
- Context Provider (`ProductsContext`)
d. Static Assets & Data
- Static data modules (`src/app/data`, `products.json`)
e. External Services (if any or future DB/API)
- Potential Python service (`newsSection/main.py` indicates a data-processing microservice)
- External APIs for news or authentication
f. Build/Deploy Config
- Next.js build pipeline (next.config.mjs)
- Tailwind/postCSS, TypeScript config

##### Relationships & data flows
- Browser → HTTP(S) request → Next.js Server
- Next.js Server applies Middleware → resolves Route → invokes Server Component or API route → fetches static data or calls external service
- Server renders static HTML/JSON → sends to Browser → hydrates into Client Components → React Context provides state → UI Components render interactivity
- Android App (if applicable) calls same API endpoints under Next.js or a separate backend.
- Static assets served directly from CDN/public folder.

##### Architectural patterns & design principles
- Separation of concerns: routing vs. UI vs. data vs. config
- Modular, reusable components (UI library)
- File-based routing for clarity and scalability
- SSR/SSG for performance, with client hydration for interactivity
- Context API for global state management

## Diagram (Mermaid)

```mermaid
graph TB
  subgraph "Clients" 
    Browser["Browser Client"]:::frontend
    Android["Android App Client"]:::frontend
  end

  subgraph "Next.js Server (Vercel)"
    Middleware["Middleware"]:::server
    AppRouter["App Router"]:::server
    subgraph "Routes"
      subgraph "Auth Routes"
        SignIn["Sign-In Route"]:::server
        SignUp["Sign-Up Route"]:::server
      end
      subgraph "Root Layout & Home"
        RootLayout["Root Layout"]:::server
        subgraph "Home Section"
          HomeLayout["Home Layout"]:::server
          HomePage["Home Page"]:::server
          CartPage["Cart Page"]:::server
          ExplorePage["Explore Page"]:::server
          ProfilePage["Profile Page"]:::server
          MyListingsPage["Profile → My Listings"]:::server
          OrdersPage["Profile → Orders"]:::server
          ShoppingPage["Shopping Page"]:::server
          UploadPage["Upload Listing"]:::server
        end
        subgraph "Messaging"
          MessagingPage["Messaging Page"]:::server
        end
      end
      DynamicPage["Dynamic Item Page"]:::server
    end
  end

  subgraph "React Component Library"
    ProductsContext["ProductsContext Provider"]:::frontend
    subgraph "Domain Components"
      Navbar["Navbar"]:::frontend
      NewsSection["News Section UI"]:::frontend
      Trending["Trending"]:::frontend
      MyListings["My Listings UI"]:::frontend
      Orders["Orders UI"]:::frontend
      Chats["Chats/Messaging UI"]:::frontend
      CustomerSupport["Customer Support UI"]:::frontend
      ChangeLanguage["Change Language UI"]:::frontend
      Settings["Settings UI"]:::frontend
      Graph["Graph/Charts UI"]:::frontend
      Logo["Logo"]:::frontend
      UploadForm["Upload Product Form"]:::frontend
    end
    subgraph "UI Primitives Library"
      Avatar["avatar.tsx"]:::frontend
      Badge["badge.tsx"]:::frontend
      Button["button.tsx"]:::frontend
      Calendar["calendar.tsx"]:::frontend
      Card["card.tsx"]:::frontend
      CarouselUI["carousel.tsx"]:::frontend
      ChartUI["chart.tsx"]:::frontend
      Input["input.tsx"]:::frontend
      Label["label.tsx"]:::frontend
      Popover["popover.tsx"]:::frontend
      Select["select.tsx"]:::frontend
      Separator["separator.tsx"]:::frontend
      Sheet["sheet.tsx"]:::frontend
      Textarea["textarea.tsx"]:::frontend
    end
  end

  subgraph "Data Layer"
    StaticModules["Static Data Modules"]:::data
    ProductsJSON["products.json"]:::data
  end

  subgraph "External/Microservices"
    NewsService["News Section Service"]:::external
  end

  subgraph "Static Assets"
    PublicAssets["public/ (static assets)"]:::data
  end

  subgraph "Config & Build"
    NextConfig["next.config.mjs"]:::config
    TailwindConfig["tailwind.config.ts"]:::config
    PostCSSConfig["postcss.config.mjs"]:::config
    TSConfig["tsconfig.json"]:::config
    ESLintConfig[".eslintrc.json"]:::config
  end

  Browser -->|"HTTP requests"| Middleware
  Android -->|"HTTP requests"| Middleware
  Middleware -->|"forwards to"| AppRouter
  AppRouter -->|"handles"| SignIn
  AppRouter -->|"handles"| SignUp
  AppRouter -->|"handles"| RootLayout
  AppRouter -->|"handles"| DynamicPage
  ExplorePage -->|"loads data from"| StaticModules
  ExplorePage -->|"calls"| NewsService
  HomePage -->|"loads data from"| StaticModules
  HomePage -->|"loads JSON from"| ProductsJSON
  DynamicPage -->|"loads JSON from"| ProductsJSON
  AppRouter -->|"serves"| PublicAssets
  Browser -->|"receives HTML/JSON"| HomePage
  Browser -->|"hydrates to"| ProductsContext
  ProductsContext --> Navbar
  ProductsContext --> NewsSection
  ProductsContext --> Trending
  ProductsContext --> MyListings
  ProductsContext --> Orders
  ProductsContext --> Chats
  ProductsContext --> CustomerSupport
  ProductsContext --> ChangeLanguage
  ProductsContext --> Settings
  ProductsContext --> Graph
  ProductsContext --> Logo
  ProductsContext --> UploadForm
  NextConfig --> AppRouter
  TailwindConfig --> AppRouter
  PostCSSConfig --> AppRouter
  TSConfig --> AppRouter
  ESLintConfig --> AppRouter

  click Android "https://github.com/dexxeth/trade-harvest/tree/main/android/app"
  click AppRouter "https://github.com/dexxeth/trade-harvest/tree/main/src/app"
  click SignIn "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(auth)/sign-in/[[...sign-in]]/page.tsx"
  click SignUp "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(auth)/sign-up/[[...sign-up]]/page.tsx"
  click RootLayout "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/layout.tsx"
  click HomeLayout "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/layout.tsx"
  click HomePage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/page.tsx"
  click CartPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/cart/page.tsx"
  click ExplorePage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/explore/page.tsx"
  click ProfilePage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/profile/page.tsx"
  click MyListingsPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/profile/myListings/page.tsx"
  click OrdersPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/profile/orders/page.tsx"
  click ShoppingPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/shopping/page.tsx"
  click UploadPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/(home)/upload/page.tsx"
  click MessagingPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/(root)/messaging/page.tsx"
  click DynamicPage "https://github.com/dexxeth/trade-harvest/blob/main/src/app/[id]/page.tsx"
  click Middleware "https://github.com/dexxeth/trade-harvest/blob/main/src/middleware.ts"
  click StaticModules "https://github.com/dexxeth/trade-harvest/blob/main/src/app/data/carousel.ts"
  click StaticModules "https://github.com/dexxeth/trade-harvest/blob/main/src/app/data/items.ts"
  click StaticModules "https://github.com/dexxeth/trade-harvest/blob/main/src/app/data/news.ts"
  click ProductsJSON "https://github.com/dexxeth/trade-harvest/blob/main/src/app/data/products.json"
  click ProductsContext "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ProductsContext.tsx"
  click Navbar "https://github.com/dexxeth/trade-harvest/blob/main/src/components/navbar.tsx"
  click NewsSection "https://github.com/dexxeth/trade-harvest/blob/main/src/components/news.tsx"
  click Trending "https://github.com/dexxeth/trade-harvest/blob/main/src/components/trending.tsx"
  click MyListings "https://github.com/dexxeth/trade-harvest/blob/main/src/components/myListings.tsx"
  click Orders "https://github.com/dexxeth/trade-harvest/blob/main/src/components/orders.tsx"
  click Chats "https://github.com/dexxeth/trade-harvest/blob/main/src/components/chats.tsx"
  click CustomerSupport "https://github.com/dexxeth/trade-harvest/blob/main/src/components/customerSupport.tsx"
  click ChangeLanguage "https://github.com/dexxeth/trade-harvest/blob/main/src/components/changeLanguage.tsx"
  click Settings "https://github.com/dexxeth/trade-harvest/blob/main/src/components/settings.tsx"
  click Graph "https://github.com/dexxeth/trade-harvest/blob/main/src/components/graph.tsx"
  click Logo "https://github.com/dexxeth/trade-harvest/blob/main/src/components/logo.tsx"
  click UploadForm "https://github.com/dexxeth/trade-harvest/blob/main/src/components/uploadProduct.tsx"
  click Avatar "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/avatar.tsx"
  click Badge "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/badge.tsx"
  click Button "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/button.tsx"
  click Calendar "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/calendar.tsx"
  click Card "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/card.tsx"
  click CarouselUI "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/carousel.tsx"
  click ChartUI "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/chart.tsx"
  click Input "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/input.tsx"
  click Label "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/label.tsx"
  click Popover "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/popover.tsx"
  click Select "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/select.tsx"
  click Separator "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/separator.tsx"
  click Sheet "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/sheet.tsx"
  click Textarea "https://github.com/dexxeth/trade-harvest/blob/main/src/components/ui/textarea.tsx"

  classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
  classDef server fill:#90EE90,stroke:#333,stroke-width:1px
  classDef data fill:#FFD580,stroke:#333,stroke-width:1px
  classDef external fill:#FFB6C1,stroke:#333,stroke-width:1px
  classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
```
