# hudsonmathew1910/berrys architecture

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

- Interactive diagram: https://gitdiagram.com/hudsonmathew1910/berrys
- Repository: https://github.com/hudsonmathew1910/berrys

## Overview

Berry’s is a children’s-clothing ecommerce store with a customer storefront and a staff dashboard. The principal workflow runs from browsing products and maintaining a bag through checkout, stock reservation, payment confirmation, and customer order history; staff then manage fulfillment and business operations. The graph preserves the documented dashboard capabilities and the central application modules. Several dashboard and domain modules are unsampled, so their documented capabilities are shown without speculative internal call flows.

Main entry points: [`app/[dash]`](https://github.com/hudsonmathew1910/berrys/tree/main/app/%5Bdash%5D) (Dashboard routes), [`app/(shop)`](https://github.com/hudsonmathew1910/berrys/tree/main/app/(shop)) (Storefront pages), [`app/api/checkout/route.ts`](https://github.com/hudsonmathew1910/berrys/blob/main/app/api/checkout/route.ts) (Checkout API), [`db/index.ts`](https://github.com/hudsonmathew1910/berrys/blob/main/db/index.ts) (Postgres database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_storefront["Storefront pages"]
  node_bag["Bag and favourites<br/>[bag.ts]"]
  node_account["Customer account"]
end

subgraph group_commerce["Checkout and commerce"]
  node_catalog["Product catalog<br/>[catalog.ts]"]
  node_storedata["Store data<br/>[store-data.ts]"]
  node_categories["Categories<br/>[categories.ts]"]
  node_checkout["Checkout API<br/>[route.ts]"]
  node_orders["Order lifecycle<br/>[orders.ts]"]
  node_payment["Razorpay integration<br/>[razorpay.ts]"]
  node_webhook["Payment webhook<br/>[route.ts]"]
end

subgraph group_dashboard["Staff workspace"]
  node_admin["Dashboard routes"]
  node_adminactions["Dashboard actions<br/>[actions.ts]"]
  node_admincatalog["Catalog operations<br/>[catalog.ts]"]
  node_adminorders["Order operations<br/>[orders.ts]"]
  node_insights["Sales insights<br/>[insights.ts]"]
  node_team["Staff access<br/>[staff.ts]"]
  node_content["Site content<br/>[content.ts]"]
  node_settings["Store settings<br/>[settings.ts]"]
end

subgraph group_platform["Identity and data"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_session["Sessions<br/>[session.ts]"]
  node_users["User accounts<br/>[users.ts]"]
  node_email["Email service<br/>[email.ts]"]
  node_errors["Error logging<br/>[error-log.ts]"]
  node_database[("Postgres database<br/>[index.ts]")]
end

node_shopper(("Shopper"))
node_google{{"Google identity"}}
node_razorpay{{"Razorpay"}}

node_shopper -->|"browses"| node_storefront
node_storefront -->|"loads products"| node_catalog
node_storefront -->|"loads categories"| node_categories
node_storefront -->|"loads store data"| node_storedata
node_shopper -->|"manages items"| node_bag
node_storefront -->|"opens account"| node_account
node_shopper -->|"submits order"| node_checkout
node_checkout -->|"creates pending order"| node_orders
node_checkout -->|"checks payment settings"| node_settings
node_checkout -->|"creates payment order"| node_razorpay
node_razorpay -->|"sends events"| node_webhook
node_webhook -->|"marks order paid"| node_orders
node_webhook -->|"applies refund events"| node_adminorders
node_shopper -->|"signs in"| node_google
node_google -->|"returns identity"| node_auth
node_auth -->|"logs in user"| node_users
node_auth -->|"creates session"| node_session
node_admin -->|"checks permissions"| node_team
node_admin -->|"loads overview data"| node_admincatalog
node_admin -->|"loads overview data"| node_adminorders
node_admin -->|"loads sales data"| node_insights
node_admin -->|"loads error counts"| node_errors
node_adminactions -->|"changes catalog"| node_admincatalog
node_admin -->|"loads content"| node_content
node_admin -->|"loads settings"| node_settings
node_admin -->|"reads products"| node_database
node_admin -->|"checks email status"| node_email
node_orders -.->|"persists orders"| node_database
node_admincatalog -.->|"manages catalog data"| node_database
node_insights -.->|"aggregates sales data"| node_database

click node_storefront "https://github.com/hudsonmathew1910/berrys/tree/main/app/(shop)"
click node_catalog "https://github.com/hudsonmathew1910/berrys/blob/main/lib/catalog.ts"
click node_storedata "https://github.com/hudsonmathew1910/berrys/blob/main/lib/store-data.ts"
click node_categories "https://github.com/hudsonmathew1910/berrys/blob/main/lib/categories.ts"
click node_bag "https://github.com/hudsonmathew1910/berrys/blob/main/components/store/bag.ts"
click node_account "https://github.com/hudsonmathew1910/berrys/tree/main/app/(shop)/account"
click node_checkout "https://github.com/hudsonmathew1910/berrys/blob/main/app/api/checkout/route.ts"
click node_orders "https://github.com/hudsonmathew1910/berrys/blob/main/lib/orders.ts"
click node_payment "https://github.com/hudsonmathew1910/berrys/blob/main/lib/razorpay.ts"
click node_webhook "https://github.com/hudsonmathew1910/berrys/blob/main/app/api/webhooks/razorpay/route.ts"
click node_admin "https://github.com/hudsonmathew1910/berrys/tree/main/app/%5Bdash%5D"
click node_adminactions "https://github.com/hudsonmathew1910/berrys/blob/main/app/%5Bdash%5D/actions.ts"
click node_admincatalog "https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/catalog.ts"
click node_adminorders "https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/orders.ts"
click node_insights "https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/insights.ts"
click node_team "https://github.com/hudsonmathew1910/berrys/blob/main/lib/staff.ts"
click node_content "https://github.com/hudsonmathew1910/berrys/blob/main/lib/content.ts"
click node_settings "https://github.com/hudsonmathew1910/berrys/blob/main/lib/settings.ts"
click node_auth "https://github.com/hudsonmathew1910/berrys/blob/main/lib/auth.ts"
click node_session "https://github.com/hudsonmathew1910/berrys/blob/main/lib/session.ts"
click node_users "https://github.com/hudsonmathew1910/berrys/blob/main/lib/users.ts"
click node_email "https://github.com/hudsonmathew1910/berrys/blob/main/lib/email.ts"
click node_errors "https://github.com/hudsonmathew1910/berrys/blob/main/lib/error-log.ts"
click node_database "https://github.com/hudsonmathew1910/berrys/blob/main/db/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_storefront,node_bag,node_account toneBlue
class node_catalog,node_storedata,node_categories,node_checkout,node_orders,node_payment,node_webhook toneAmber
class node_admin,node_adminactions,node_admincatalog,node_adminorders,node_insights,node_team,node_content,node_settings toneMint
class node_auth,node_session,node_users,node_email,node_errors,node_database toneRose
class node_shopper,node_google,node_razorpay toneIndigo
```

## Components

### Customer storefront

- [Storefront pages](https://github.com/hudsonmathew1910/berrys/tree/main/app/(shop)): `app/(shop)`
- [Bag and favourites](https://github.com/hudsonmathew1910/berrys/blob/main/components/store/bag.ts): `components/store/bag.ts`
- [Customer account](https://github.com/hudsonmathew1910/berrys/tree/main/app/(shop)/account): `app/(shop)/account`

### Checkout and commerce

- [Product catalog](https://github.com/hudsonmathew1910/berrys/blob/main/lib/catalog.ts): `lib/catalog.ts`
- [Store data](https://github.com/hudsonmathew1910/berrys/blob/main/lib/store-data.ts): `lib/store-data.ts`
- [Categories](https://github.com/hudsonmathew1910/berrys/blob/main/lib/categories.ts): `lib/categories.ts`
- [Checkout API](https://github.com/hudsonmathew1910/berrys/blob/main/app/api/checkout/route.ts): `app/api/checkout/route.ts`
- [Order lifecycle](https://github.com/hudsonmathew1910/berrys/blob/main/lib/orders.ts): `lib/orders.ts`
- [Razorpay integration](https://github.com/hudsonmathew1910/berrys/blob/main/lib/razorpay.ts): `lib/razorpay.ts`
- [Payment webhook](https://github.com/hudsonmathew1910/berrys/blob/main/app/api/webhooks/razorpay/route.ts): `app/api/webhooks/razorpay/route.ts`

### Staff workspace

- [Dashboard routes](https://github.com/hudsonmathew1910/berrys/tree/main/app/%5Bdash%5D): `app/[dash]`
- [Dashboard actions](https://github.com/hudsonmathew1910/berrys/blob/main/app/%5Bdash%5D/actions.ts): `app/[dash]/actions.ts`
- [Catalog operations](https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/catalog.ts): `lib/admin/catalog.ts`
- [Order operations](https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/orders.ts): `lib/admin/orders.ts`
- [Sales insights](https://github.com/hudsonmathew1910/berrys/blob/main/lib/admin/insights.ts): `lib/admin/insights.ts`
- [Staff access](https://github.com/hudsonmathew1910/berrys/blob/main/lib/staff.ts): `lib/staff.ts`
- [Site content](https://github.com/hudsonmathew1910/berrys/blob/main/lib/content.ts): `lib/content.ts`
- [Store settings](https://github.com/hudsonmathew1910/berrys/blob/main/lib/settings.ts): `lib/settings.ts`

### Identity and data

- [Authentication](https://github.com/hudsonmathew1910/berrys/blob/main/lib/auth.ts): `lib/auth.ts`
- [Sessions](https://github.com/hudsonmathew1910/berrys/blob/main/lib/session.ts): `lib/session.ts`
- [User accounts](https://github.com/hudsonmathew1910/berrys/blob/main/lib/users.ts): `lib/users.ts`
- [Email service](https://github.com/hudsonmathew1910/berrys/blob/main/lib/email.ts): `lib/email.ts`
- [Error logging](https://github.com/hudsonmathew1910/berrys/blob/main/lib/error-log.ts): `lib/error-log.ts`
- [Postgres database](https://github.com/hudsonmathew1910/berrys/blob/main/db/index.ts): `db/index.ts`

### Other components

- **Shopper**
- **Google identity**
- **Razorpay**

## Connections

- Shopper → Storefront pages: browses (evidence: `README.md`)
- Storefront pages → Product catalog: loads products (evidence: `app/(shop)/page.tsx`)
- Storefront pages → Categories: loads categories (evidence: `app/(shop)/shop/page.tsx`)
- Storefront pages → Store data: loads store data (evidence: `app/(shop)/page.tsx`)
- Shopper → Bag and favourites: manages items (evidence: `README.md`)
- Storefront pages → Customer account: opens account (evidence: `README.md`)
- Shopper → Checkout API: submits order (evidence: `README.md`)
- Checkout API → Order lifecycle: creates pending order (evidence: `app/api/checkout/route.ts`)
- Checkout API → Store settings: checks payment settings (evidence: `app/api/checkout/route.ts`)
- Checkout API → Razorpay: creates payment order (evidence: `README.md`)
- Razorpay → Payment webhook: sends events (evidence: `README.md`)
- Payment webhook → Order lifecycle: marks order paid (evidence: `app/api/webhooks/razorpay/route.ts`)
- Payment webhook → Order operations: applies refund events (evidence: `app/api/webhooks/razorpay/route.ts`)
- Shopper → Google identity: signs in (evidence: `README.md`)
- Google identity → Authentication: returns identity
- Authentication → User accounts: logs in user (evidence: `app/auth/google/callback/route.ts`)
- Authentication → Sessions: creates session (evidence: `app/auth/google/callback/route.ts`)
- Dashboard routes → Staff access: checks permissions (evidence: `app/[dash]/page.tsx`)
- Dashboard routes → Catalog operations: loads overview data (evidence: `app/[dash]/page.tsx`)
- Dashboard routes → Order operations: loads overview data (evidence: `app/[dash]/page.tsx`)
- Dashboard routes → Sales insights: loads sales data (evidence: `app/[dash]/page.tsx`)
- Dashboard routes → Error logging: loads error counts (evidence: `app/[dash]/page.tsx`)
- Dashboard actions → Catalog operations: changes catalog (evidence: `app/[dash]/content/page.tsx`)
- Dashboard routes → Site content: loads content (evidence: `app/[dash]/content/page.tsx`)
- Dashboard routes → Store settings: loads settings (evidence: `app/[dash]/settings/page.tsx`)
- Dashboard routes → Postgres database: reads products
- Dashboard routes → Email service: checks email status (evidence: `app/[dash]/settings/page.tsx`)
- Order lifecycle → Postgres database: persists orders
- Catalog operations → Postgres database: manages catalog data
- Sales insights → Postgres database: aggregates sales data
