# gartgetget/5a-inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/gartgetget/5a-inventory-system
- Repository: https://github.com/gartgetget/5a-inventory-system

## Overview

Stockly is a role-based inventory and warehouse management platform for admins, suppliers, and clients. The main flow is a user entering a role-specific experience, using catalog and order capabilities, and managing the resulting invoices, payments, and fulfillment; operational records are persisted through Prisma and MongoDB. The README documents these product capabilities and optional integrations. Sampled routes confirm authentication, order persistence, and product management behavior; most other route-to-service links are not shown in the excerpts, so those connections are not asserted.

Main entry points: [`app/admin/page.tsx`](https://github.com/gartgetget/5a-inventory-system/blob/main/app/admin/page.tsx) (Admin workspace), [`app/api/orders/route.ts`](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/orders/route.ts) (Orders), [`components/Pages/ClientPortalPage.tsx`](https://github.com/gartgetget/5a-inventory-system/blob/main/components/Pages/ClientPortalPage.tsx) (Client portal), [`app/api/products/route.ts`](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/products/route.ts) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Role Experiences"]
  node_adminui["Admin workspace<br/>[page.tsx]"]
  node_supplierui["Supplier portal<br/>[page.tsx]"]
  node_clientui["Client portal"]
end

subgraph group_commerce["Inventory &amp; Commerce"]
  node_products["Product catalog<br/>[route.ts]"]
  node_categories["Categories<br/>[route.ts]"]
  node_suppliers["Supplier records<br/>[route.ts]"]
  node_warehouses["Warehouses<br/>[route.ts]"]
  node_orders["Orders<br/>[route.ts]"]
  node_invoices["Invoices<br/>[route.ts]"]
end

subgraph group_operations["Fulfillment &amp; Service"]
  node_payments["Payments<br/>[route.ts]"]
  node_shipping["Shipping<br/>[route.ts]"]
  node_support["Support tickets<br/>[route.ts]"]
  node_reviews["Product reviews<br/>[route.ts]"]
end

subgraph group_insights["Insights &amp; Governance"]
  node_analytics["Analytics &amp; forecasting<br/>[page.tsx]"]
  node_audit["Activity history<br/>[audit-log.ts]"]
  node_ai["AI insights<br/>[openrouter.ts]"]
end

subgraph group_platform["Application Services"]
  node_auth["Session auth<br/>[auth.ts]"]
  node_database[("MongoDB via Prisma<br/>[client.ts]")]
  node_email["Email notifications<br/>[notifications.ts]"]
end

node_admin(("Admin"))
node_supplier(("Supplier"))
node_client(("Client"))
node_stripe{{"Stripe"}}
node_shippo{{"Shippo"}}
node_brevo{{"Brevo"}}
node_openrouter{{"OpenRouter"}}

node_admin -->|"manages operations"| node_adminui
node_supplier -->|"manages own data"| node_supplierui
node_client -->|"browses and orders"| node_clientui
node_adminui -.->|"manages catalog"| node_products
node_adminui -.->|"manages categories"| node_categories
node_adminui -.->|"manages suppliers"| node_suppliers
node_adminui -.->|"manages warehouses"| node_warehouses
node_clientui -->|"browses catalog"| node_products
node_clientui -->|"places orders"| node_orders
node_clientui -->|"views invoices"| node_invoices
node_supplierui -->|"views own products"| node_products
node_supplierui -->|"views own orders"| node_orders
node_adminui -->|"views insights"| node_analytics
node_adminui -->|"reviews activity"| node_audit
node_clientui -->|"opens tickets"| node_support
node_clientui -->|"submits reviews"| node_reviews
node_orders -->|"resolves session"| node_auth
node_orders -->|"persists orders"| node_database
node_products -->|"resolves session"| node_auth
node_products -->|"stores products"| node_database
node_invoices -->|"reads and writes"| node_database
node_support -->|"stores tickets"| node_database
node_orders -->|"records activity"| node_audit
node_products -->|"records activity"| node_audit
node_orders -.->|"bills orders"| node_invoices
node_invoices -->|"accepts payment"| node_payments
node_payments -->|"uses checkout"| node_stripe
node_orders -->|"fulfills orders"| node_shipping
node_shipping -->|"uses shipping API"| node_shippo
node_invoices -->|"sends invoices"| node_email
node_email -->|"delivers email"| node_brevo
node_analytics -.->|"requests AI insights"| node_ai
node_ai -->|"uses model service"| node_openrouter

click node_adminui "https://github.com/gartgetget/5a-inventory-system/blob/main/app/admin/page.tsx"
click node_supplierui "https://github.com/gartgetget/5a-inventory-system/blob/main/app/supplier/page.tsx"
click node_clientui "https://github.com/gartgetget/5a-inventory-system/blob/main/components/Pages/ClientPortalPage.tsx"
click node_auth "https://github.com/gartgetget/5a-inventory-system/blob/main/utils/auth.ts"
click node_products "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/products/route.ts"
click node_categories "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/categories/route.ts"
click node_suppliers "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/suppliers/route.ts"
click node_warehouses "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/warehouses/route.ts"
click node_orders "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/orders/route.ts"
click node_invoices "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/invoices/route.ts"
click node_payments "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/payments/checkout/route.ts"
click node_shipping "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/shipping/labels/route.ts"
click node_support "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/support-tickets/route.ts"
click node_reviews "https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/product-reviews/route.ts"
click node_analytics "https://github.com/gartgetget/5a-inventory-system/blob/main/app/business-insights/page.tsx"
click node_audit "https://github.com/gartgetget/5a-inventory-system/blob/main/prisma/audit-log.ts"
click node_database "https://github.com/gartgetget/5a-inventory-system/blob/main/prisma/client.ts"
click node_email "https://github.com/gartgetget/5a-inventory-system/blob/main/lib/email/notifications.ts"
click node_ai "https://github.com/gartgetget/5a-inventory-system/blob/main/lib/ai/openrouter.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_adminui,node_supplierui,node_clientui,node_client toneBlue
class node_products,node_categories,node_suppliers,node_warehouses,node_orders,node_invoices toneAmber
class node_payments,node_shipping,node_support,node_reviews,node_openrouter toneMint
class node_analytics,node_audit,node_ai toneRose
class node_auth,node_database,node_email,node_admin,node_supplier,node_stripe,node_shippo,node_brevo toneIndigo
```

## Components

### Role Experiences

- [Admin workspace](https://github.com/gartgetget/5a-inventory-system/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Supplier portal](https://github.com/gartgetget/5a-inventory-system/blob/main/app/supplier/page.tsx): `app/supplier/page.tsx`
- [Client portal](https://github.com/gartgetget/5a-inventory-system/blob/main/components/Pages/ClientPortalPage.tsx): `components/Pages/ClientPortalPage.tsx`

### Inventory & Commerce

- [Product catalog](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/products/route.ts): `app/api/products/route.ts`
- [Categories](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/categories/route.ts): `app/api/categories/route.ts`
- [Supplier records](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/suppliers/route.ts): `app/api/suppliers/route.ts`
- [Warehouses](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/warehouses/route.ts): `app/api/warehouses/route.ts`
- [Orders](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/orders/route.ts): `app/api/orders/route.ts`
- [Invoices](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/invoices/route.ts): `app/api/invoices/route.ts`

### Fulfillment & Service

- [Payments](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/payments/checkout/route.ts): `app/api/payments/checkout/route.ts`
- [Shipping](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/shipping/labels/route.ts): `app/api/shipping/labels/route.ts`
- [Support tickets](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/support-tickets/route.ts): `app/api/support-tickets/route.ts`
- [Product reviews](https://github.com/gartgetget/5a-inventory-system/blob/main/app/api/product-reviews/route.ts): `app/api/product-reviews/route.ts`

### Insights & Governance

- [Analytics & forecasting](https://github.com/gartgetget/5a-inventory-system/blob/main/app/business-insights/page.tsx): `app/business-insights/page.tsx`
- [Activity history](https://github.com/gartgetget/5a-inventory-system/blob/main/prisma/audit-log.ts): `prisma/audit-log.ts`
- [AI insights](https://github.com/gartgetget/5a-inventory-system/blob/main/lib/ai/openrouter.ts): `lib/ai/openrouter.ts`

### Application Services

- [Session auth](https://github.com/gartgetget/5a-inventory-system/blob/main/utils/auth.ts): `utils/auth.ts`
- [MongoDB via Prisma](https://github.com/gartgetget/5a-inventory-system/blob/main/prisma/client.ts): `prisma/client.ts`
- [Email notifications](https://github.com/gartgetget/5a-inventory-system/blob/main/lib/email/notifications.ts): `lib/email/notifications.ts`

### Other components

- **Admin**
- **Supplier**
- **Client**
- **Stripe**
- **Shippo**
- **Brevo**
- **OpenRouter**

## Connections

- Admin → Admin workspace: manages operations (evidence: `README.md`)
- Supplier → Supplier portal: manages own data (evidence: `README.md`)
- Client → Client portal: browses and orders (evidence: `README.md`)
- Admin workspace → Product catalog: manages catalog
- Admin workspace → Categories: manages categories
- Admin workspace → Supplier records: manages suppliers
- Admin workspace → Warehouses: manages warehouses
- Client portal → Product catalog: browses catalog (evidence: `README.md`)
- Client portal → Orders: places orders (evidence: `README.md`)
- Client portal → Invoices: views invoices (evidence: `README.md`)
- Supplier portal → Product catalog: views own products (evidence: `README.md`)
- Supplier portal → Orders: views own orders (evidence: `README.md`)
- Admin workspace → Analytics & forecasting: views insights (evidence: `README.md`)
- Admin workspace → Activity history: reviews activity (evidence: `README.md`)
- Client portal → Support tickets: opens tickets (evidence: `README.md`)
- Client portal → Product reviews: submits reviews (evidence: `README.md`)
- Orders → Session auth: resolves session (evidence: `app/api/orders/route.ts`)
- Orders → MongoDB via Prisma: persists orders (evidence: `app/api/orders/route.ts`)
- Product catalog → Session auth: resolves session (evidence: `app/api/products/route.ts`)
- Product catalog → MongoDB via Prisma: stores products (evidence: `app/api/products/route.ts`)
- Invoices → MongoDB via Prisma: reads and writes (evidence: `app/api/invoices/route.ts`)
- Support tickets → MongoDB via Prisma: stores tickets (evidence: `app/api/support-tickets/route.ts`)
- Orders → Activity history: records activity (evidence: `app/api/orders/route.ts`)
- Product catalog → Activity history: records activity (evidence: `app/api/products/route.ts`)
- Orders → Invoices: bills orders
- Invoices → Payments: accepts payment (evidence: `README.md`)
- Payments → Stripe: uses checkout (evidence: `README.md`)
- Orders → Shipping: fulfills orders (evidence: `README.md`)
- Shipping → Shippo: uses shipping API (evidence: `README.md`)
- Invoices → Email notifications: sends invoices (evidence: `README.md`)
- Email notifications → Brevo: delivers email (evidence: `README.md`)
- Analytics & forecasting → AI insights: requests AI insights
- AI insights → OpenRouter: uses model service (evidence: `README.md`)
