# habib-utsho/leaf-share-ai-project-b14-m-8-client architecture

> Architecture diagram of the GitHub repository habib-utsho/leaf-share-ai-project-b14-m-8-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/habib-utsho/leaf-share-ai-project-b14-m-8-client
- Repository: https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client

## Overview

LeafShare is a community plant-swap board: visitors browse listings, open plant details, and request available units; members can register, publish and manage listings, and track or cancel requests. The Next.js app renders these experiences and sends data operations through its API helpers to a separately hosted Express/MongoDB service. The graph preserves the documented auth, dashboard, listing, and request capabilities. Several routes and components were not sampled, so their internal call links are omitted; external server behavior is represented only where documented.

Main entry points: [`src/app/plants/page.tsx`](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/page.tsx) (Plant search and browse), [`src/lib/api.ts`](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/api.ts) (Authenticated API client), [`src/app/plants/[id]/page.tsx`](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/%5Bid%5D/page.tsx) (Plant details), [`src/components/requests/my-request-list.tsx`](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/requests/my-request-list.tsx) (My requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Plant discovery"]
  node_home["Home and newest plants<br/>[page.tsx]"]
  node_home_slider["Home hero slider<br/>[hero-slider.tsx]"]
  node_browse["Plant search and browse<br/>[page.tsx]"]
  node_plant_detail["Plant details<br/>[page.tsx]"]
  node_plant_card["Plant cards and stock<br/>[plant-card.tsx]"]
  node_plant_filters["Search filters<br/>[plant-filters.tsx]"]
  node_pagination["Browse pagination<br/>[pagination.tsx]"]
end

subgraph group_accounts["Accounts and session"]
  node_auth_pages["Sign-in and registration pages<br/>[page.tsx]"]
  node_auth_forms["Auth forms and shell<br/>[auth-shell.tsx]"]
  node_auth_service["Better Auth configuration<br/>[auth.ts]"]
  node_auth_routes["Auth route handler<br/>[route.ts]"]
  node_token_route["JWT token endpoint<br/>[route.ts]"]
end

subgraph group_member["Member workspace"]
  node_dashboard["Dashboard overview<br/>[overview.tsx]"]
  node_add_listing["Add listing page<br/>[page.tsx]"]
  node_listing_form["Listing editor form<br/>[plant-form.tsx]"]
  node_my_plants["My listings<br/>[my-plant-list.tsx]"]
  node_edit_listing["Edit listing page<br/>[page.tsx]"]
  node_request_button["Request plant action<br/>[request-button.tsx]"]
  node_my_requests["My requests"]
  node_request_status["Request status badge<br/>[status-badge.tsx]"]
end

subgraph group_client["Client data access"]
  node_plant_data["Plant types and URL rules<br/>[plants.ts]"]
  node_request_data["Request types<br/>[requests.ts]"]
  node_server_api["Server-side API access<br/>[server-api.ts]"]
  node_api_client["Authenticated API client<br/>[api.ts]"]
end

node_visitor(("Visitor or member"))
node_express_api[("Express API and MongoDB")]

node_visitor -->|"opens"| node_home
node_home -->|"renders"| node_home_slider
node_home -->|"fetches newest"| node_server_api
node_server_api -.->|"requests plant data"| node_express_api
node_visitor -->|"browses"| node_browse
node_browse -->|"renders"| node_plant_filters
node_browse -->|"renders"| node_pagination
node_browse -->|"builds filter URLs"| node_plant_data
node_browse -->|"fetches listings"| node_server_api
node_browse -->|"renders results"| node_plant_card
node_visitor -->|"opens listing"| node_plant_detail
node_plant_detail -->|"fetches plant"| node_server_api
node_plant_detail -->|"renders action"| node_request_button
node_visitor -->|"signs in or registers"| node_auth_pages
node_auth_pages -->|"renders"| node_auth_forms
node_auth_service -->|"issues JWT"| node_token_route
node_auth_routes -.->|"handles auth requests"| node_auth_service
node_visitor -.->|"opens workspace"| node_dashboard
node_dashboard -->|"links listings"| node_my_plants
node_dashboard -->|"links requests"| node_my_requests
node_visitor -->|"adds plant"| node_add_listing
node_add_listing -->|"renders form"| node_listing_form
node_visitor -.->|"edits plant"| node_edit_listing
node_edit_listing -.->|"renders editor"| node_listing_form
node_listing_form -->|"validates fields"| node_plant_data
node_listing_form -->|"saves listing"| node_api_client
node_plant_detail -->|"offers request"| node_request_button
node_request_button -.->|"submits request"| node_api_client
node_my_requests -->|"cancels request"| node_api_client
node_my_requests -->|"renders status"| node_request_status
node_api_client -->|"renews token"| node_token_route
node_api_client -.->|"calls API routes"| node_express_api
node_my_requests -->|"uses request types"| node_request_data

click node_home "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/page.tsx"
click node_home_slider "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/home/hero-slider.tsx"
click node_browse "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/page.tsx"
click node_plant_detail "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/%5Bid%5D/page.tsx"
click node_plant_card "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-card.tsx"
click node_plant_filters "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-filters.tsx"
click node_pagination "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/pagination.tsx"
click node_auth_pages "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/login/page.tsx"
click node_auth_forms "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/auth/auth-shell.tsx"
click node_auth_service "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/auth.ts"
click node_auth_routes "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/api/auth/%5B...all%5D/route.ts"
click node_token_route "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/api/token/route.ts"
click node_dashboard "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/dashboard/overview.tsx"
click node_add_listing "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/(dashboard)/add-plant/page.tsx"
click node_listing_form "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-form.tsx"
click node_my_plants "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/my-plant-list.tsx"
click node_edit_listing "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/(dashboard)/my-plants/%5Bid%5D/edit/page.tsx"
click node_request_button "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/request-button.tsx"
click node_my_requests "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/requests/my-request-list.tsx"
click node_request_status "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/requests/status-badge.tsx"
click node_plant_data "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/plants.ts"
click node_request_data "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/requests.ts"
click node_server_api "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/server-api.ts"
click node_api_client "https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/api.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_home,node_home_slider,node_browse,node_plant_detail,node_plant_card,node_plant_filters,node_pagination toneBlue
class node_auth_pages,node_auth_forms,node_auth_service,node_auth_routes,node_token_route,node_express_api toneAmber
class node_dashboard,node_add_listing,node_listing_form,node_my_plants,node_edit_listing,node_request_button,node_my_requests,node_request_status toneMint
class node_plant_data,node_request_data,node_server_api,node_api_client toneRose
class node_visitor toneIndigo
```

## Components

### Plant discovery

- [Home and newest plants](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Home hero slider](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/home/hero-slider.tsx): `src/components/home/hero-slider.tsx`
- [Plant search and browse](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/page.tsx): `src/app/plants/page.tsx`
- [Plant details](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/plants/%5Bid%5D/page.tsx): `src/app/plants/[id]/page.tsx`
- [Plant cards and stock](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-card.tsx): `src/components/plants/plant-card.tsx`
- [Search filters](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-filters.tsx): `src/components/plants/plant-filters.tsx`
- [Browse pagination](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/pagination.tsx): `src/components/plants/pagination.tsx`

### Accounts and session

- [Sign-in and registration pages](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Auth forms and shell](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/auth/auth-shell.tsx): `src/components/auth/auth-shell.tsx`
- [Better Auth configuration](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Auth route handler](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/api/auth/%5B...all%5D/route.ts): `src/app/api/auth/[...all]/route.ts`
- [JWT token endpoint](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/api/token/route.ts): `src/app/api/token/route.ts`

### Member workspace

- [Dashboard overview](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/dashboard/overview.tsx): `src/components/dashboard/overview.tsx`
- [Add listing page](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/(dashboard)/add-plant/page.tsx): `src/app/(dashboard)/add-plant/page.tsx`
- [Listing editor form](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/plant-form.tsx): `src/components/plants/plant-form.tsx`
- [My listings](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/my-plant-list.tsx): `src/components/plants/my-plant-list.tsx`
- [Edit listing page](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/app/(dashboard)/my-plants/%5Bid%5D/edit/page.tsx): `src/app/(dashboard)/my-plants/[id]/edit/page.tsx`
- [Request plant action](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/plants/request-button.tsx): `src/components/plants/request-button.tsx`
- [My requests](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/requests/my-request-list.tsx): `src/components/requests/my-request-list.tsx`
- [Request status badge](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/components/requests/status-badge.tsx): `src/components/requests/status-badge.tsx`

### Client data access

- [Plant types and URL rules](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/plants.ts): `src/lib/plants.ts`
- [Request types](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/requests.ts): `src/lib/requests.ts`
- [Server-side API access](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/server-api.ts): `src/lib/server-api.ts`
- [Authenticated API client](https://github.com/habib-utsho/leaf-share-ai-project-b14-m-8-client/blob/main/src/lib/api.ts): `src/lib/api.ts`

### Other components

- **Visitor or member**
- **Express API and MongoDB**

## Connections

- Visitor or member → Home and newest plants: opens (evidence: `src/app/page.tsx`)
- Home and newest plants → Home hero slider: renders (evidence: `src/app/page.tsx`)
- Home and newest plants → Server-side API access: fetches newest (evidence: `src/app/page.tsx`)
- Server-side API access → Express API and MongoDB: requests plant data (evidence: `README.md`)
- Visitor or member → Plant search and browse: browses (evidence: `src/app/plants/page.tsx`)
- Plant search and browse → Search filters: renders (evidence: `src/app/plants/page.tsx`)
- Plant search and browse → Browse pagination: renders (evidence: `src/app/plants/page.tsx`)
- Plant search and browse → Plant types and URL rules: builds filter URLs (evidence: `src/app/plants/page.tsx`)
- Plant search and browse → Server-side API access: fetches listings (evidence: `src/app/plants/page.tsx`)
- Plant search and browse → Plant cards and stock: renders results (evidence: `src/app/plants/page.tsx`)
- Visitor or member → Plant details: opens listing (evidence: `src/app/plants/[id]/page.tsx`)
- Plant details → Server-side API access: fetches plant (evidence: `src/app/plants/[id]/page.tsx`)
- Plant details → Request plant action: renders action (evidence: `src/app/plants/[id]/page.tsx`)
- Visitor or member → Sign-in and registration pages: signs in or registers (evidence: `src/app/login/page.tsx`)
- Sign-in and registration pages → Auth forms and shell: renders (evidence: `src/app/login/page.tsx`)
- Better Auth configuration → JWT token endpoint: issues JWT (evidence: `src/app/api/token/route.ts`)
- Auth route handler → Better Auth configuration: handles auth requests
- Visitor or member → Dashboard overview: opens workspace (evidence: `README.md`)
- Dashboard overview → My listings: links listings (evidence: `src/components/dashboard/overview.tsx`)
- Dashboard overview → My requests: links requests (evidence: `src/components/dashboard/overview.tsx`)
- Visitor or member → Add listing page: adds plant (evidence: `src/app/(dashboard)/add-plant/page.tsx`)
- Add listing page → Listing editor form: renders form (evidence: `src/app/(dashboard)/add-plant/page.tsx`)
- Visitor or member → Edit listing page: edits plant (evidence: `README.md`)
- Edit listing page → Listing editor form: renders editor
- Listing editor form → Plant types and URL rules: validates fields (evidence: `src/components/plants/plant-form.tsx`)
- Listing editor form → Authenticated API client: saves listing (evidence: `src/components/plants/plant-form.tsx`)
- Plant details → Request plant action: offers request (evidence: `src/app/plants/[id]/page.tsx`)
- Request plant action → Authenticated API client: submits request
- My requests → Authenticated API client: cancels request (evidence: `src/components/requests/my-request-list.tsx`)
- My requests → Request status badge: renders status (evidence: `src/components/requests/my-request-list.tsx`)
- Authenticated API client → JWT token endpoint: renews token (evidence: `src/lib/api.ts`)
- Authenticated API client → Express API and MongoDB: calls API routes (evidence: `README.md`)
- My requests → Request types: uses request types (evidence: `src/components/requests/my-request-list.tsx`)
