# kwxky9p5cy-alt/campus_market architecture

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

- Interactive diagram: https://gitdiagram.com/kwxky9p5cy-alt/campus_market
- Repository: https://github.com/kwxky9p5cy-alt/campus_market

## Overview

Campus Market is a student-to-student used-goods marketplace. Users browse or search listings, inspect details, then authenticate to publish, favorite, request trades, message, or manage their profile. The frontend calls a marketplace service backed by Supabase or browser-local demo mode; AI search and listing autofill use a separate Edge Function with rule-based fallback. README documents database-backed trade-state transitions, image storage, and message Realtime. Some page-to-service wiring is inferred from documented capabilities; unsampled implementation details are not expanded.

Main entry points: [`src/App.tsx`](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/App.tsx) (App routing), [`src/services/marketplace.ts`](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/marketplace.ts) (Marketplace service), [`src/pages/SearchPage.tsx`](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/SearchPage.tsx) (Search and filters), [`src/features/products/ProductForm.tsx`](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/products/ProductForm.tsx) (Listing editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_shell["App shell<br/>[AppShell.tsx]"]
  node_auth["Auth provider<br/>[AuthProvider.tsx]"]
end

subgraph group_marketplace["Listings and discovery"]
  node_home["Home browsing<br/>[HomePage.tsx]"]
  node_search["Search and filters<br/>[SearchPage.tsx]"]
  node_detail["Product details"]
  node_listing["Listing editor<br/>[ProductForm.tsx]"]
  node_favorites["Favorites"]
end

subgraph group_community["Transactions and people"]
  node_trades["Trade requests<br/>[TradesPage.tsx]"]
  node_messages["Conversations<br/>[MessagesPage.tsx]"]
  node_conversation["Chat"]
  node_profile["Profile management<br/>[ProfilePage.tsx]"]
end

subgraph group_platform["Services and integrations"]
  node_marketplace_api["Marketplace service<br/>[marketplace.ts]"]
  node_supabase_impl["Supabase adapter"]
  node_demo_impl["Demo data store<br/>[demo-store.ts]"]
  node_search_parser["Search parser<br/>[searchParser.ts]"]
  node_autofill["Listing autofill<br/>[autofill.ts]"]
  node_edge_ai["AI assistant<br/>[index.ts]"]
end

node_student(("Student"))
node_supabase[("Supabase")]
node_storage[("Image storage")]
node_ai_provider["AI provider"]

node_student -->|"uses"| node_app
node_app -->|"routes through"| node_shell
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_search
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_listing
node_app -->|"routes to"| node_favorites
node_app -->|"routes to"| node_trades
node_app -->|"routes to"| node_messages
node_app -->|"routes to"| node_conversation
node_app -->|"routes to"| node_profile
node_auth -->|"authenticates via"| node_marketplace_api
node_home -->|"loads listings"| node_marketplace_api
node_search -->|"filters listings"| node_marketplace_api
node_search -->|"parses query"| node_search_parser
node_detail -->|"loads product"| node_marketplace_api
node_listing -->|"saves listing"| node_marketplace_api
node_listing -->|"requests draft"| node_autofill
node_favorites -->|"manages favorites"| node_marketplace_api
node_trades -->|"manages requests"| node_marketplace_api
node_messages -->|"loads conversations"| node_marketplace_api
node_conversation -->|"sends messages"| node_marketplace_api
node_profile -->|"manages profile"| node_marketplace_api
node_marketplace_api -->|"uses backend"| node_supabase_impl
node_marketplace_api -.->|"uses demo mode"| node_demo_impl
node_supabase_impl -->|"reads and writes"| node_supabase
node_supabase_impl -->|"uploads images"| node_storage
node_search_parser -.->|"requests parsing"| node_edge_ai
node_search_parser -->|"returns fallback"| node_search
node_autofill -.->|"requests completion"| node_edge_ai
node_edge_ai -->|"sends prompt"| node_ai_provider

click node_app "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/App.tsx"
click node_shell "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/layouts/AppShell.tsx"
click node_auth "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/auth/AuthProvider.tsx"
click node_home "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/HomePage.tsx"
click node_search "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/SearchPage.tsx"
click node_detail "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ProductDetailPage.tsx"
click node_listing "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/products/ProductForm.tsx"
click node_favorites "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/favorites/FavoritesProvider.tsx"
click node_trades "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/TradesPage.tsx"
click node_messages "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/MessagesPage.tsx"
click node_conversation "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ConversationPage.tsx"
click node_profile "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ProfilePage.tsx"
click node_marketplace_api "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/marketplace.ts"
click node_supabase_impl "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/supabase-service.ts"
click node_demo_impl "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/demo-store.ts"
click node_search_parser "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/ai/searchParser.ts"
click node_autofill "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/ai/autofill.ts"
click node_edge_ai "https://github.com/kwxky9p5cy-alt/campus_market/blob/main/supabase/functions/ai-assistant/index.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_app,node_shell,node_auth toneBlue
class node_home,node_search,node_detail,node_listing,node_favorites,node_supabase,node_storage toneAmber
class node_trades,node_messages,node_conversation,node_profile toneMint
class node_marketplace_api,node_supabase_impl,node_demo_impl,node_search_parser,node_autofill,node_edge_ai toneRose
class node_student,node_ai_provider toneIndigo
```

## Components

### Web experience

- [App routing](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/App.tsx): `src/App.tsx`
- [App shell](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/layouts/AppShell.tsx): `src/layouts/AppShell.tsx`
- [Auth provider](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/auth/AuthProvider.tsx): `src/features/auth/AuthProvider.tsx`

### Listings and discovery

- [Home browsing](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/HomePage.tsx): `src/pages/HomePage.tsx`
- [Search and filters](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/SearchPage.tsx): `src/pages/SearchPage.tsx`
- [Product details](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ProductDetailPage.tsx): `src/pages/ProductDetailPage.tsx`
- [Listing editor](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/products/ProductForm.tsx): `src/features/products/ProductForm.tsx`
- [Favorites](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/features/favorites/FavoritesProvider.tsx): `src/features/favorites/FavoritesProvider.tsx`

### Transactions and people

- [Trade requests](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/TradesPage.tsx): `src/pages/TradesPage.tsx`
- [Conversations](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/MessagesPage.tsx): `src/pages/MessagesPage.tsx`
- [Chat](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ConversationPage.tsx): `src/pages/ConversationPage.tsx`
- [Profile management](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/pages/ProfilePage.tsx): `src/pages/ProfilePage.tsx`

### Services and integrations

- [Marketplace service](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/marketplace.ts): `src/services/marketplace.ts`
- [Supabase adapter](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/supabase-service.ts): `src/services/supabase-service.ts`
- [Demo data store](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/demo-store.ts): `src/services/demo-store.ts`
- [Search parser](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/ai/searchParser.ts): `src/services/ai/searchParser.ts`
- [Listing autofill](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/src/services/ai/autofill.ts): `src/services/ai/autofill.ts`
- [AI assistant](https://github.com/kwxky9p5cy-alt/campus_market/blob/main/supabase/functions/ai-assistant/index.ts): `supabase/functions/ai-assistant/index.ts`

### Other components

- **Student**
- **Supabase**
- **Image storage**
- **AI provider**

## Connections

- Student → App routing: uses
- App routing → App shell: routes through
- App routing → Home browsing: routes to
- App routing → Search and filters: routes to
- App routing → Product details: routes to
- App routing → Listing editor: routes to
- App routing → Favorites: routes to
- App routing → Trade requests: routes to
- App routing → Conversations: routes to
- App routing → Chat: routes to
- App routing → Profile management: routes to
- Auth provider → Marketplace service: authenticates via
- Home browsing → Marketplace service: loads listings
- Search and filters → Marketplace service: filters listings
- Search and filters → Search parser: parses query
- Product details → Marketplace service: loads product
- Listing editor → Marketplace service: saves listing
- Listing editor → Listing autofill: requests draft
- Favorites → Marketplace service: manages favorites
- Trade requests → Marketplace service: manages requests
- Conversations → Marketplace service: loads conversations
- Chat → Marketplace service: sends messages
- Profile management → Marketplace service: manages profile
- Marketplace service → Supabase adapter: uses backend
- Marketplace service → Demo data store: uses demo mode
- Supabase adapter → Supabase: reads and writes
- Supabase adapter → Image storage: uploads images
- Search parser → AI assistant: requests parsing
- Search parser → Search and filters: returns fallback
- Listing autofill → AI assistant: requests completion
- AI assistant → AI provider: sends prompt
