# aarush2007-08/sankalp-final architecture

> Architecture diagram of the GitHub repository aarush2007-08/sankalp-final, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aarush2007-08/sankalp-final
- Repository: https://github.com/aarush2007-08/sankalp-final

## Overview

1. **Two main deployable subsystems**
   - The repo is split into a **React/Vite frontend** under `SELLER SIDE BASIC LOGIC/` and an **Express/SQLite backend** under `backend/`.
   - The frontend is the primary seller experience, but it also contains a small **buyer-facing flow** (`Marketplace`, `Cart`, `Checkout`, `MyOrders`) in the same codebase.

2. **Frontend application boundary**
   - `src/main.tsx` bootstraps the app, and `src/app/App.tsx` is the top-level composition point.
   - Routing/pages are organized under `src/app/pages`, with seller pages like `Dashboard`, `Orders`, `Earnings`, `Storefront`, `UploadProduct`, plus buyer pages.
   - The frontend is a single-page app built with **TypeScript + React + Vite** and styled via local CSS/Tailwind/shadcn-style UI assets.

3. **Frontend state and app-wide context**
   - Global state is split into `src/app/contexts/AppContext.tsx` and `src/app/contexts/BuyerContext.tsx`.
   - These contexts likely mediate shared cross-page data such as products, orders, cart/buyer state, and app-level loading/offline conditions.
   - UI behavior is also supported by reusable layout components like `PlatformLayout`, `PageHeader`, `PageLoader`, `EmptyState`, and `StatCard`.

4. **Frontend API boundary**
   - `src/app/api/client.ts` is the frontend’s HTTP abstraction and is the main boundary between UI state and backend data.
   - The readme shows the frontend calling backend endpoints for product publishing, order data, and earnings summaries.
   - This keeps page/components isolated from direct network details and makes the backend appear as a REST service.

5. **Offline-first behavior**
   - The frontend explicitly includes `OfflineBanner` and the readme describes an **offline sync queue**.
   - The architecture therefore supports local capture of actions when connectivity is unavailable, then later syncing those actions through the API client.
   - This is an important boundary: user actions may be accepted locally first, not only through immediate server writes.

6. **AI-assisted product creation flow**
   - The backend exposes an AI route layer in `backend/src/routes/ai.ts`, backed by `backend/src/ai.ts`.
   - The readme indicates a seller can upload an image or voice input, request AI-generated product title/description drafts, then edit and publish.
   - This AI integration is part of the backend rather than embedded in the UI, so the frontend treats it as a service call.

7. **Backend application boundary**
   - `backend/src/index.ts` is the server entry point, with route modules under `backend/src/routes/`.
   - The backend is organized by domain: `products`, `orders`, `earnings`, and `ai`.
   - `backend/src/types.ts` and `backend/src/db/index.ts` suggest a shared typed model layer and a database access layer underneath the route handlers.

8. **Persistence and data model**
   - The backend uses **SQLite** as its persistence store, accessed through `backend/src/db/index.ts`.
   - The architecture is CRUD-oriented: products are created and managed, orders are tracked, and earnings are aggregated from stored transactional data.
   - `backend/src/seed.ts` indicates the repository can populate initial database data for local development or demo setup.

9. **Primary end-to-end data flows**
   - Seller content flow: UI → API client → backend product routes → SQLite, with AI route involvement during draft generation.
   - Metrics flow: dashboard/earnings pages → API client → earnings route → SQLite aggregation → UI cards/charts.
   - Order flow: seller/buyer views → orders routes → SQLite persistence → order status display in dashboard and order pages.
   - The architecture diagram should show the backend as the central system of record, with the frontend consuming it over HTTP.

10. **Reusable UI and design system layer**
   - The frontend includes a large reusable component library under `src/app/components/ui/`, alongside custom components like `FlowerLogo`, `Gauge`, and `DashboardPreview`.
   - This is a presentation-layer subsystem only; it does not own business logic but provides the visual and interaction primitives used across pages.
   - Multiple theme and stylesheet files indicate the app has a strong design-system-oriented UI layer.

11. **Internationalization**
   - `src/i18n/index.ts` and locale files for `en`, `hi`, and `kn` indicate built-in multilingual support.
   - Language switching is handled in the frontend layout layer, so localization is a presentation concern rather than a backend concern.
   - This matters architecturally because user-visible strings are not hardcoded into a single locale.

12. **Operational boundary and local development**
   - The readme describes a combined local dev setup with the frontend on port 5173 and backend on port 3001.
   - There is no evidence of separate cloud services or message brokers in this repo; the architecture is primarily a **frontend + REST API + SQLite + AI service** stack.
   - For a diagram, the key external dependency to show is the AI service behind the backend’s AI module, plus the browser/client environment for the frontend.

Main entry points: [`SELLER SIDE BASIC LOGIC/src/app/App.tsx`](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/App.tsx) (App Shell), [`SELLER SIDE BASIC LOGIC/src/app/api/client.ts`](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/api/client.ts) (API Client), [`backend/src/index.ts`](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/index.ts) (Server), [`backend/src/db/index.ts`](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/db/index.ts) (SQLite DB)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_fe_main["Main<br/>entrypoint<br/>[main.tsx]"]
  node_fe_app["App Shell<br/>spa root<br/>[App.tsx]"]
  node_fe_api["API Client<br/>http client<br/>[client.ts]"]
  node_fe_contexts["App State<br/>react context<br/>[AppContext.tsx]"]
  node_fe_buyer_context["Buyer State<br/>react context<br/>[BuyerContext.tsx]"]
  node_fe_layout["Layout Shell<br/>presentation layer<br/>[PlatformLayout.tsx]"]
  node_fe_ui["UI Kit<br/>design system<br/>[button.tsx]"]
  node_fe_i18n["i18n<br/>localization<br/>[index.ts]"]
  node_fe_seller_pages["Seller Pages<br/>[Dashboard.tsx]"]
  node_fe_buyer_pages["Buyer Pages<br/>[Marketplace.tsx]"]
  node_fe_storefront["Storefront<br/>seller page<br/>[Storefront.tsx]"]
  node_fe_offline["Offline Banner<br/>offline UX<br/>[OfflineBanner.tsx]"]
end

subgraph group_backend["Backend"]
  node_be_entry["Server<br/>entrypoint<br/>[index.ts]"]
  node_be_routes_products["Products<br/>route module<br/>[products.ts]"]
  node_be_routes_orders["Orders<br/>route module<br/>[orders.ts]"]
  node_be_routes_earnings["Earnings<br/>route module<br/>[earnings.ts]"]
  node_be_routes_ai["AI Route<br/>route module<br/>[ai.ts]"]
  node_be_ai["AI Service<br/>ai integration<br/>[ai.ts]"]
  node_be_db[("SQLite DB<br/>persistence layer<br/>[index.ts]")]
  node_be_types["Types<br/>shared models<br/>[types.ts]"]
  node_be_seed["Seed Data<br/>bootstrap data<br/>[seed.ts]"]
end

node_fe_main -->|"bootstraps"| node_fe_app
node_fe_app -->|"provides state"| node_fe_contexts
node_fe_app -->|"provides buyer state"| node_fe_buyer_context
node_fe_app -->|"composes"| node_fe_layout
node_fe_app -->|"routes to"| node_fe_seller_pages
node_fe_app -->|"routes to"| node_fe_buyer_pages
node_fe_app -->|"routes to"| node_fe_storefront
node_fe_app -->|"shows"| node_fe_offline
node_fe_app -->|"localizes"| node_fe_i18n
node_fe_seller_pages -->|"fetches data"| node_fe_api
node_fe_buyer_pages -->|"fetches data"| node_fe_api
node_fe_storefront -->|"publishes"| node_fe_api
node_fe_contexts -->|"syncs"| node_fe_api
node_fe_buyer_context -->|"syncs"| node_fe_api
node_be_entry -->|"mounts"| node_be_routes_products
node_be_entry -->|"mounts"| node_be_routes_orders
node_be_entry -->|"mounts"| node_be_routes_earnings
node_be_entry -->|"mounts"| node_be_routes_ai
node_be_routes_products -->|"reads/writes"| node_be_db
node_be_routes_orders -->|"reads/writes"| node_be_db
node_be_routes_earnings -->|"aggregates"| node_be_db
node_be_routes_ai -->|"delegates"| node_be_ai
node_be_ai -->|"uses data"| node_be_db
node_be_seed -->|"initializes"| node_be_db
node_be_routes_products -->|"shares models"| node_be_types
node_be_routes_orders -->|"shares models"| node_be_types
node_be_routes_earnings -->|"shares models"| node_be_types
node_be_routes_ai -->|"shares models"| node_be_types
node_fe_api -->|"HTTP"| node_be_entry

click node_fe_main "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/main.tsx"
click node_fe_app "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/App.tsx"
click node_fe_api "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/api/client.ts"
click node_fe_contexts "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/contexts/AppContext.tsx"
click node_fe_buyer_context "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/contexts/BuyerContext.tsx"
click node_fe_layout "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/components/layout/PlatformLayout.tsx"
click node_fe_ui "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/components/ui/button.tsx"
click node_fe_i18n "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/i18n/index.ts"
click node_fe_seller_pages "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/pages/Dashboard.tsx"
click node_fe_buyer_pages "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/pages/buyer/Marketplace.tsx"
click node_fe_storefront "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/pages/Storefront.tsx"
click node_fe_offline "https://github.com/aarush2007-08/sankalp-final/blob/main/SELLER SIDE BASIC LOGIC/src/app/components/OfflineBanner.tsx"
click node_be_entry "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/index.ts"
click node_be_routes_products "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/products.ts"
click node_be_routes_orders "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/orders.ts"
click node_be_routes_earnings "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/earnings.ts"
click node_be_routes_ai "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/ai.ts"
click node_be_ai "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/ai.ts"
click node_be_db "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/db/index.ts"
click node_be_types "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/types.ts"
click node_be_seed "https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/seed.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_fe_main,node_fe_app,node_fe_api,node_fe_contexts,node_fe_buyer_context,node_fe_layout,node_fe_ui,node_fe_i18n,node_fe_seller_pages,node_fe_buyer_pages,node_fe_storefront,node_fe_offline toneBlue
class node_be_entry,node_be_routes_products,node_be_routes_orders,node_be_routes_earnings,node_be_routes_ai,node_be_ai,node_be_db,node_be_types,node_be_seed toneAmber
```

## Components

### Frontend

React/Vite seller app with buyer flow, shared state, UI system, and localization.

- [Main](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/main.tsx): entrypoint · Bootstraps the frontend application. · `SELLER SIDE BASIC LOGIC/src/main.tsx`
- [App Shell](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/App.tsx): spa root · Top-level composition and routing boundary for the frontend. · `SELLER SIDE BASIC LOGIC/src/app/App.tsx`
- [API Client](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/api/client.ts): http client · Front-end HTTP abstraction used by pages and state flows. · `SELLER SIDE BASIC LOGIC/src/app/api/client.ts`
- [App State](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/contexts/AppContext.tsx): react context · Shared seller-facing app state and loading/offline coordination. · `SELLER SIDE BASIC LOGIC/src/app/contexts/AppContext.tsx`
- [Buyer State](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/contexts/BuyerContext.tsx): react context · Buyer-specific cart and checkout state. · `SELLER SIDE BASIC LOGIC/src/app/contexts/BuyerContext.tsx`
- [Layout Shell](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/components/layout/PlatformLayout.tsx): presentation layer · Reusable page chrome, headers, loaders, and empty states. · `SELLER SIDE BASIC LOGIC/src/app/components/layout/PlatformLayout.tsx`
- [UI Kit](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/components/ui/button.tsx): design system · Reusable component library for the visual layer. · `SELLER SIDE BASIC LOGIC/src/app/components/ui/button.tsx`
- [i18n](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/i18n/index.ts): localization · Multilingual frontend strings and language switching support. · `SELLER SIDE BASIC LOGIC/src/i18n/index.ts`
- [Seller Pages](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/pages/Dashboard.tsx): pages · Core seller experiences for dashboarding, catalog, orders, and earnings. · `SELLER SIDE BASIC LOGIC/src/app/pages/Dashboard.tsx`
- [Buyer Pages](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/pages/buyer/Marketplace.tsx): pages · Buyer-facing marketplace, cart, checkout, and order history flows. · `SELLER SIDE BASIC LOGIC/src/app/pages/buyer/Marketplace.tsx`
- [Storefront](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/pages/Storefront.tsx): seller page · Public-facing seller storefront view. · `SELLER SIDE BASIC LOGIC/src/app/pages/Storefront.tsx`
- [Offline Banner](https://github.com/aarush2007-08/sankalp-final/blob/HEAD/SELLER%20SIDE%20BASIC%20LOGIC/src/app/components/OfflineBanner.tsx): offline UX · Signals offline status and supports queued local actions. · `SELLER SIDE BASIC LOGIC/src/app/components/OfflineBanner.tsx`

### Backend

Express API with domain routes, SQLite persistence, and AI-assisted drafting.

- [Server](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/index.ts): entrypoint · Starts the backend API server. · `backend/src/index.ts`
- [Products](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/products.ts): route module · Product publishing and catalog management endpoints. · `backend/src/routes/products.ts`
- [Orders](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/orders.ts): route module · Order creation, tracking, and status endpoints. · `backend/src/routes/orders.ts`
- [Earnings](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/earnings.ts): route module · Earnings aggregation and summary endpoints. · `backend/src/routes/earnings.ts`
- [AI Route](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/routes/ai.ts): route module · AI-assisted drafting endpoints exposed to the frontend. · `backend/src/routes/ai.ts`
- [AI Service](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/ai.ts): ai integration · Backend AI helper used to generate product draft content. · `backend/src/ai.ts`
- [SQLite DB](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/db/index.ts): persistence layer · Database access and storage boundary for the backend. · `backend/src/db/index.ts`
- [Types](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/types.ts): shared models · Shared backend type definitions for data shape consistency. · `backend/src/types.ts`
- [Seed Data](https://github.com/aarush2007-08/sankalp-final/blob/main/backend/src/seed.ts): bootstrap data · Initial data population for local development or demo setup. · `backend/src/seed.ts`

## Connections

- Main → App Shell: bootstraps · Frontend entry mounts the application shell.
- App Shell → App State: provides state · App shell wires global seller state.
- App Shell → Buyer State: provides buyer state · App shell wires buyer-specific state.
- App Shell → Layout Shell: composes · App shell uses reusable layout chrome.
- App Shell → Seller Pages: routes to · Seller-facing screens are composed under the app shell.
- App Shell → Buyer Pages: routes to · Buyer-facing screens live in the same SPA.
- App Shell → Storefront: routes to · Storefront is a separate seller-facing view.
- App Shell → Offline Banner: shows · Offline status is surfaced in the frontend shell.
- App Shell → i18n: localizes · Language selection and translated strings are applied at the app layer.
- Seller Pages → API Client: fetches data · Seller pages call the backend through the API client.
- Buyer Pages → API Client: fetches data · Buyer flows use the same HTTP boundary.
- Storefront → API Client: publishes · Storefront data is retrieved and updated via the API client.
- App State → API Client: syncs · Shared state coordinates reads, writes, and offline reconciliation through the API boundary.
- Buyer State → API Client: syncs · Buyer cart and order actions are synchronized through the API client.
- Server → Products: mounts · Server registers product routes.
- Server → Orders: mounts · Server registers order routes.
- Server → Earnings: mounts · Server registers earnings routes.
- Server → AI Route: mounts · Server registers AI routes.
- Products → SQLite DB: reads/writes · Product operations persist to SQLite.
- Orders → SQLite DB: reads/writes · Order operations persist to SQLite.
- Earnings → SQLite DB: aggregates · Earnings summaries are derived from stored data.
- AI Route → AI Service: delegates · AI route forwards drafting work to the AI helper.
- AI Service → SQLite DB: uses data · AI-assisted workflows can use stored domain data.
- Seed Data → SQLite DB: initializes · Seed script populates the SQLite database.
- Products → Types: shares models · Route handlers use shared backend types.
- Orders → Types: shares models · Route handlers use shared backend types.
- Earnings → Types: shares models · Route handlers use shared backend types.
- AI Route → Types: shares models · AI route uses shared request/response types.
- API Client → Server: HTTP · Frontend consumes the backend as a REST API.
