# harshal01123/craftideationtool architecture

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

- Interactive diagram: https://gitdiagram.com/harshal01123/craftideationtool
- Repository: https://github.com/harshal01123/craftideationtool

## Overview

1. **Top-level shape**
   - The repo is split into a **React + TypeScript SPA** in `CraftConnect/` and a small **Supabase backend surface** in `supabase/`.
   - The frontend is the main application; Supabase provides **Auth, Postgres, Realtime, and Storage**. There is no separate custom server.

2. **Primary user domains**
   - The app is organized around three roles: **Artisan**, **Customer**, and **Learner**.
   - Those roles drive the major product areas: **Marketplace**, **Educational courses**, **Chat/negotiation**, **Dashboards**, and **Ratings/notifications**.

3. **Frontend composition**
   - `src/main.tsx` bootstraps the SPA, and `src/App.tsx` is the central routing/container layer.
   - Navigation is likely React Router-based, with a shared `ScrollToTop`, `ProtectedRoute`, and role-aware dashboard layouts.
   - The app is styled with **CSS Modules** plus shared CSS variables in `src/styles/variables.css`.

4. **State and cross-cutting concerns**
   - `src/contexts/ModeContext.tsx` provides app-wide mode state.
   - `src/hooks/` contains domain hooks for **auth**, **chat**, and **wishlist**, indicating that most server-backed state is accessed through hooks rather than a separate state-management library.
   - `src/lib/supabase.ts` is the backend access boundary; it centralizes the Supabase client and is the main conduit for auth/database/realtime/storage interactions.

5. **Authentication and access control**
   - Auth flows are handled by `Login`, `Signup`, and `ResetPassword` pages, backed by Supabase Auth.
   - `ProtectedRoute` suggests route-level enforcement for dashboard and role-specific areas.
   - User profile data is probably loaded from the `profiles` table and then used to determine which dashboard and features are visible.

6. **Marketplace subsystem**
   - Product browsing is implemented through `ProductPortfolio`, `Products`, `MyProducts`, and product cards/modals in `src/components/products/`.
   - The marketplace supports **multi-image listings**, category filtering via `industryOptions`, price filtering, wishlists, and product detail/portfolio views.
   - Customer and artisan boundaries are reflected in separate views for browsing versus managing listings.

7. **Educational subsystem**
   - Courses are modeled separately from products, with pages such as `CoursePortfolio`, `Courses`, `MyCourses`, and learner dashboards.
   - UI components like `CreateCourseModal` and `CertificateModal` show the flow: artisans create masterclasses, learners enroll, progress is tracked, and completion can produce certificates.
   - This subsystem is distinct from the marketplace, but both share the same artisan profile and dashboard infrastructure.

8. **Real-time chat and bargaining**
   - Chat is a major standalone subsystem under `src/components/chat/` and `src/pages/dashboard/Messages.tsx`.
   - It includes conversation lifecycle, message bubbles, sidebar/thread selection, closed-chat banners, contact/new-chat dialogs, product pickers, and offer negotiation UI (`OfferCard`, `PriceSetDialog`, `OfferFlowCoordinator`).
   - The README and file names indicate Supabase **Realtime** is used for instant message delivery and state synchronization.

9. **Notifications and feedback loops**
   - The dashboard includes notifications (`Notifications.tsx`) and message-related alerts.
   - Chat events likely trigger notification updates for new messages, new conversations, and closed threads.
   - Ratings/reviews are a separate feedback loop, with components for `RatingModal`, `ReviewCard`, and `StarRating`, covering both artisan and product reputation.

10. **Dashboard architecture**
    - `src/layouts/DashboardLayout.tsx` is the shared shell for authenticated, role-specific screens.
    - Under `src/pages/dashboard/` there are separate artisan, customer, and learner entry points, plus feature pages for profile editing, products, courses, certificates, artisans, and messages.
    - This indicates the dashboard is a **hub-and-spoke** structure: one layout, many domain pages, all powered by the same Supabase-backed user/session state.

11. **Localization and presentation**
    - The app is bilingual via `src/i18n.ts`, `src/locales/en.json`, and `src/locales/hi.json`.
    - `LanguageSwitcher` in the UI reflects that language is a first-class global setting, not a page-local concern.
    - UI behavior and motion are enhanced with component-level patterns and external animation support noted in the README.

12. **Backend/serverless layer**
    - `supabase/functions/request-reset` and `supabase/functions/send-bug-report` are edge functions, so not all backend logic lives in the browser.
    - These functions likely cover email-related workflows and support/feedback submission, keeping sensitive operations off the client.
    - The backend is otherwise Supabase-native: database tables, auth, and realtime channels do most of the work.

13. **Deployment and ops**
    - The repo includes `vercel.json`, implying the SPA is deployed on **Vercel**.
    - `.github/workflows/supabase-keep-alive.yml` suggests a CI/maintenance job to keep the Supabase project warm or prevent inactivity-related downtime.
    - `build_output.txt` and TypeScript/lint configs indicate the repo is built as a standard frontend bundle with typed checks and linting.

14. **Data flow summary**
    - User enters the SPA → authenticates via Supabase → profile/role determines accessible dashboard and routes.
    - Marketplace, course, wishlist, rating, and chat screens read/write directly to Supabase tables/storage through hooks and the shared client.
    - Chat and notifications are event-driven through Realtime, while special workflows like reset/bog-report use edge functions.

Main entry points: [`CraftConnect/src/App.tsx`](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/App.tsx) (App), [`CraftConnect/src/pages/dashboard/Dashboard.tsx`](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Dashboard.tsx) (Role Areas), [`CraftConnect/src/lib/supabase.ts`](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/lib/supabase.ts) (Supabase Client), [`CraftConnect/src/pages/ProductPortfolio.tsx`](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/ProductPortfolio.tsx) (Marketplace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend SPA"]
  node_main(("Entry<br/>spa bootstrap<br/>[main.tsx]"))
  node_app["App<br/>router shell<br/>[App.tsx]"]
  node_layout["Dashboard Layout<br/>role shell"]
  node_auth["Auth Hooks<br/>session access<br/>[useAuth.ts]"]
  node_chathook["Chat Hooks<br/>realtime access<br/>[useChat.ts]"]
  node_wishhook["Wishlist Hook<br/>saved-items access<br/>[useWishlist.tsx]"]
  node_profiles["Role Areas<br/>role dashboards<br/>[Dashboard.tsx]"]
  node_market["Marketplace<br/>product catalog"]
  node_courses["Courses<br/>learning catalog"]
  node_chat["Messaging<br/>chat + offers<br/>[Messages.tsx]"]
  node_ratings["Ratings<br/>reviews<br/>[RatingModal.tsx]"]
  node_notifications["Notifications<br/>alerts<br/>[Notifications.tsx]"]
  node_i18n["Language<br/>localization<br/>[i18n.ts]"]
  node_mode["Mode Context<br/>ui state<br/>[ModeContext.tsx]"]
end

subgraph group_backend["Supabase Backend"]
  node_supabaseclient[("Supabase Client<br/>data boundary<br/>[supabase.ts]")]
  node_authfn["Reset Email<br/>edge function<br/>[index.ts]"]
  node_bugfn["Bug Report<br/>edge function<br/>[index.ts]"]
end

subgraph group_ops["Deployment & Ops"]
  node_vercel{{"Vercel Deploy<br/>hosting<br/>[vercel.json]"}}
end

node_main -->|"bootstraps"| node_app
node_app -->|"routes to"| node_layout
node_app -->|"exposes"| node_profiles
node_app -->|"routes to"| node_market
node_app -->|"routes to"| node_courses
node_app -->|"routes to"| node_chat
node_auth -->|"auth session"| node_supabaseclient
node_chathook -->|"realtime data"| node_supabaseclient
node_wishhook -->|"wishlist data"| node_supabaseclient
node_market -->|"favorites"| node_wishhook
node_chat -->|"drives"| node_chathook
node_chat -.->|"triggers"| node_notifications
node_courses -.->|"feedback"| node_ratings
node_market -.->|"reviews"| node_ratings
node_profiles -->|"manages"| node_market
node_profiles -->|"manages"| node_courses
node_profiles -->|"coordinates"| node_chat
node_profiles -->|"shows"| node_notifications
node_i18n -->|"global ui"| node_app
node_mode -->|"theme state"| node_layout
node_authfn -->|"uses backend"| node_supabaseclient
node_bugfn -->|"uses backend"| node_supabaseclient
node_vercel -.->|"hosts"| node_app

click node_main "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/main.tsx"
click node_app "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/App.tsx"
click node_layout "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/layouts/DashboardLayout.tsx"
click node_auth "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useAuth.ts"
click node_chathook "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useChat.ts"
click node_wishhook "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useWishlist.tsx"
click node_supabaseclient "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/lib/supabase.ts"
click node_profiles "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Dashboard.tsx"
click node_market "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/ProductPortfolio.tsx"
click node_courses "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/CoursePortfolio.tsx"
click node_chat "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Messages.tsx"
click node_ratings "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/components/ratings/RatingModal.tsx"
click node_notifications "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Notifications.tsx"
click node_i18n "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/i18n.ts"
click node_mode "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/contexts/ModeContext.tsx"
click node_authfn "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/supabase/functions/request-reset/index.ts"
click node_bugfn "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/supabase/functions/send-bug-report/index.ts"
click node_vercel "https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/vercel.json"

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_main,node_app,node_layout,node_auth,node_chathook,node_wishhook,node_profiles,node_market,node_courses,node_chat,node_ratings,node_notifications,node_i18n,node_mode toneBlue
class node_supabaseclient,node_authfn,node_bugfn toneAmber
class node_vercel toneMint
```

## Components

### Frontend SPA

React + TypeScript single-page application and shared UI/state layers.

- [Entry](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/main.tsx): spa bootstrap · Bootstraps the React application and mounts the root UI. · `CraftConnect/src/main.tsx`
- [App](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/App.tsx): router shell · Central routing and top-level application container. · `CraftConnect/src/App.tsx`
- [Dashboard Layout](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/layouts/DashboardLayout.tsx): role shell · Shared authenticated dashboard shell for role-specific screens. · `CraftConnect/src/layouts/DashboardLayout.tsx`
- [Auth Hooks](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useAuth.ts): session access · Client-side auth/session access and user loading. · `CraftConnect/src/hooks/useAuth.ts`
- [Chat Hooks](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useChat.ts): realtime access · Conversation state, message flow, and chat interactions. · `CraftConnect/src/hooks/useChat.ts`
- [Wishlist Hook](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/hooks/useWishlist.tsx): saved-items access · Wishlist state and marketplace favorites handling. · `CraftConnect/src/hooks/useWishlist.tsx`
- [Role Areas](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Dashboard.tsx): role dashboards · Artisan, customer, and learner dashboard entry points and role-specific screens. · `CraftConnect/src/pages/dashboard/Dashboard.tsx`
- [Marketplace](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/ProductPortfolio.tsx): product catalog · Product browsing, listing management, filtering, wishlists, and product details. · `CraftConnect/src/pages/ProductPortfolio.tsx`
- [Courses](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/CoursePortfolio.tsx): learning catalog · Course discovery, creation, enrollment, and certificate workflows. · `CraftConnect/src/pages/dashboard/CoursePortfolio.tsx`
- [Messaging](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Messages.tsx): chat + offers · Threaded chat, product pickers, offers, and negotiation UI. · `CraftConnect/src/pages/dashboard/Messages.tsx`
- [Ratings](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/components/ratings/RatingModal.tsx): reviews · Ratings, reviews, and reputation feedback surfaces. · `CraftConnect/src/components/ratings/RatingModal.tsx`
- [Notifications](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/pages/dashboard/Notifications.tsx): alerts · Dashboard notifications and message-related alerts. · `CraftConnect/src/pages/dashboard/Notifications.tsx`
- [Language](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/i18n.ts): localization · Bilingual localization and language switching. · `CraftConnect/src/i18n.ts`
- [Mode Context](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/contexts/ModeContext.tsx): ui state · App-wide mode and presentation state. · `CraftConnect/src/contexts/ModeContext.tsx`

### Supabase Backend

Supabase auth, database, realtime, storage, and edge functions.

- [Supabase Client](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/src/lib/supabase.ts): data boundary · Central client for auth, database, realtime, and storage access. · `CraftConnect/src/lib/supabase.ts`
- [Reset Email](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/supabase/functions/request-reset/index.ts): edge function · Server-side password reset request workflow. · `supabase/functions/request-reset/index.ts`
- [Bug Report](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/supabase/functions/send-bug-report/index.ts): edge function · Server-side bug report submission workflow. · `supabase/functions/send-bug-report/index.ts`

### Deployment & Ops

Build, hosting, and maintenance workflows.

- [Vercel Deploy](https://github.com/harshal01123/craftideationtool/blob/ui-fix-v2/CraftConnect/vercel.json): hosting · Frontend deployment target for the SPA. · `CraftConnect/vercel.json`

## Connections

- Entry → App: bootstraps · The entry file mounts the application shell.
- App → Dashboard Layout: routes to · Authenticated sections flow into the shared dashboard layout.
- App → Role Areas: exposes · Top-level routing exposes role-specific areas and pages.
- App → Marketplace: routes to · Marketplace views are part of the main SPA.
- App → Courses: routes to · Course views are part of the main SPA.
- App → Messaging: routes to · Messaging and negotiation screens are routed from the app shell.
- Auth Hooks → Supabase Client: auth session · Auth hooks use the shared Supabase client for session and profile access.
- Chat Hooks → Supabase Client: realtime data · Chat hooks read and write conversation state through Supabase.
- Wishlist Hook → Supabase Client: wishlist data · Wishlist state is persisted through the Supabase backend boundary.
- Marketplace → Wishlist Hook: favorites · Marketplace surfaces use wishlist state and interactions.
- Messaging → Chat Hooks: drives · Chat UI is powered by the chat hook layer.
- Messaging → Notifications: triggers · Message events feed notification updates.
- Courses → Ratings: feedback · Course completion and user feedback connect to ratings surfaces.
- Marketplace → Ratings: reviews · Product reputation flows into ratings and review components.
- Role Areas → Marketplace: manages · Role dashboards surface product browsing and listing management.
- Role Areas → Courses: manages · Role dashboards surface course creation and learner progress.
- Role Areas → Messaging: coordinates · Dashboard areas link into messaging and negotiation.
- Role Areas → Notifications: shows · Role dashboards display alerts and inbox status.
- Language → App: global ui · Localization is applied across the application shell.
- Mode Context → Dashboard Layout: theme state · Mode state influences shared dashboard presentation.
- Reset Email → Supabase Client: uses backend · Reset workflow is implemented as a Supabase edge function around backend services.
- Bug Report → Supabase Client: uses backend · Bug reporting is handled server-side through Supabase functions.
- Vercel Deploy → App: hosts · The SPA is deployed through Vercel.
