# shakthi2704/elegant-layers architecture

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

- Interactive diagram: https://gitdiagram.com/shakthi2704/elegant-layers
- Repository: https://github.com/shakthi2704/elegant-layers

## Overview

This is a bakery operations application built with Next.js: staff manage products, recipes, purchasing, inventory, production, point-of-sale, custom cake orders, and financial records, with reports and dashboard views. The main checkout path runs from the POS screen through its terminal and server actions; product administration has a sampled server-action layer backed by Prisma. The README is a generic Next.js starter README, so feature coverage comes from the repository tree and source index. Several domain modules are unsampled; their edges are omitted where the available evidence does not establish calls.

Main entry points: [`app/(dashboard)/pos/[id]/page.tsx`](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/pos/%5Bid%5D/page.tsx) (POS screen), [`lib/require-role.ts`](https://github.com/shakthi2704/elegant-layers/blob/main/lib/require-role.ts) (Role gate), [`lib/prisma.ts`](https://github.com/shakthi2704/elegant-layers/blob/main/lib/prisma.ts) (Prisma client), [`app/(dashboard)/products/actions.ts`](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/products/actions.ts) (Products)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sales["Sales and Orders"]
  node_pos["POS screen<br/>[page.tsx]"]
  node_terminal["POS terminal<br/>[pos-terminal.tsx]"]
  node_sale_actions["Sale actions<br/>[actions.ts]"]
  node_cake_orders["Cake orders<br/>[page.tsx]"]
  node_cake_forms["Cake order forms"]
end

subgraph group_operations["Stock and Production"]
  node_purchases["Purchases"]
  node_inventory["Inventory"]
  node_production["Production"]
end

subgraph group_admin["Catalog and Administration"]
  node_products["Products<br/>[actions.ts]"]
  node_recipes["Recipes"]
  node_ingredients["Ingredients"]
  node_suppliers["Suppliers"]
  node_users_settings["Users and settings"]
end

subgraph group_insights["Finance and Insights"]
  node_expenses_assets["Expenses and assets"]
  node_income["Income<br/>[page.tsx]"]
  node_reports["Reports<br/>[reports.ts]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
end

subgraph group_platform["Application Platform"]
  node_auth_pages["Sign-in<br/>[page.tsx]"]
  node_auth_api["Auth API<br/>[route.ts]"]
  node_role_gate["Role gate<br/>[require-role.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
  node_pagination["Pagination"]
  node_format["Date formatting<br/>[format.ts]"]
end

node_staff(("Staff"))

node_staff -.->|"uses"| node_pos
node_pos -->|"renders"| node_terminal
node_terminal -->|"calls"| node_sale_actions
node_pos -->|"checks access"| node_role_gate
node_cake_orders -->|"checks access"| node_role_gate
node_cake_orders -->|"reads order"| node_prisma
node_cake_forms -->|"references actions"| node_products
node_products -->|"checks access"| node_role_gate
node_products -->|"reads and writes"| node_prisma
node_products -.->|"persists through"| node_database
node_prisma -->|"connects"| node_database
node_auth_api -->|"dispatches to"| node_auth
node_role_gate -->|"checks session"| node_auth
node_auth -->|"uses"| node_prisma
node_auth_pages -.->|"references"| node_role_gate
node_pos -->|"loads sale data"| node_prisma
node_pos -->|"formats values"| node_format
node_cake_orders -->|"formats dates"| node_format
node_reports -->|"uses"| node_format
node_pagination -.->|"supports lists"| node_pos

click node_pos "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/pos/%5Bid%5D/page.tsx"
click node_terminal "https://github.com/shakthi2704/elegant-layers/blob/main/components/pos/pos-terminal.tsx"
click node_sale_actions "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/pos/actions.ts"
click node_cake_orders "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/cake-orders/%5Bid%5D/page.tsx"
click node_cake_forms "https://github.com/shakthi2704/elegant-layers/blob/main/components/cake-orders/cake-order-form.tsx"
click node_purchases "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/purchases"
click node_inventory "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/inventory"
click node_production "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/production"
click node_products "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/products/actions.ts"
click node_recipes "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/recipes"
click node_ingredients "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/ingredients"
click node_suppliers "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/suppliers"
click node_users_settings "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/settings"
click node_expenses_assets "https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/expenses"
click node_income "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/income/page.tsx"
click node_reports "https://github.com/shakthi2704/elegant-layers/blob/main/lib/reports.ts"
click node_dashboard "https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/dashboard/page.tsx"
click node_auth_pages "https://github.com/shakthi2704/elegant-layers/blob/main/app/(auth)/sign-in/page.tsx"
click node_auth_api "https://github.com/shakthi2704/elegant-layers/blob/main/app/api/auth/%5B...all%5D/route.ts"
click node_role_gate "https://github.com/shakthi2704/elegant-layers/blob/main/lib/require-role.ts"
click node_auth "https://github.com/shakthi2704/elegant-layers/blob/main/lib/auth.ts"
click node_prisma "https://github.com/shakthi2704/elegant-layers/blob/main/lib/prisma.ts"
click node_pagination "https://github.com/shakthi2704/elegant-layers/blob/main/components/layout/table-pagination.tsx"
click node_format "https://github.com/shakthi2704/elegant-layers/blob/main/lib/format.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_pos,node_terminal,node_sale_actions,node_cake_orders,node_cake_forms toneBlue
class node_purchases,node_inventory,node_production toneAmber
class node_products,node_recipes,node_ingredients,node_suppliers,node_users_settings toneMint
class node_expenses_assets,node_income,node_reports,node_dashboard toneRose
class node_auth_pages,node_auth_api,node_role_gate,node_auth,node_prisma,node_database,node_pagination,node_format,node_staff toneIndigo
```

## Components

### Sales and Orders

- [POS screen](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/pos/%5Bid%5D/page.tsx): `app/(dashboard)/pos/[id]/page.tsx`
- [POS terminal](https://github.com/shakthi2704/elegant-layers/blob/main/components/pos/pos-terminal.tsx): `components/pos/pos-terminal.tsx`
- [Sale actions](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/pos/actions.ts): `app/(dashboard)/pos/actions.ts`
- [Cake orders](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/cake-orders/%5Bid%5D/page.tsx): `app/(dashboard)/cake-orders/[id]/page.tsx`
- [Cake order forms](https://github.com/shakthi2704/elegant-layers/blob/main/components/cake-orders/cake-order-form.tsx): `components/cake-orders/cake-order-form.tsx`

### Stock and Production

- [Purchases](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/purchases): `app/(dashboard)/purchases`
- [Inventory](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/inventory): `app/(dashboard)/inventory`
- [Production](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/production): `app/(dashboard)/production`

### Catalog and Administration

- [Products](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/products/actions.ts): `app/(dashboard)/products/actions.ts`
- [Recipes](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/recipes): `app/(dashboard)/recipes`
- [Ingredients](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/ingredients): `app/(dashboard)/ingredients`
- [Suppliers](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/suppliers): `app/(dashboard)/suppliers`
- [Users and settings](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/settings): `app/(dashboard)/settings`

### Finance and Insights

- [Expenses and assets](https://github.com/shakthi2704/elegant-layers/tree/main/app/(dashboard)/expenses): `app/(dashboard)/expenses`
- [Income](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/income/page.tsx): `app/(dashboard)/income/page.tsx`
- [Reports](https://github.com/shakthi2704/elegant-layers/blob/main/lib/reports.ts): `lib/reports.ts`
- [Dashboard](https://github.com/shakthi2704/elegant-layers/blob/main/app/(dashboard)/dashboard/page.tsx): `app/(dashboard)/dashboard/page.tsx`

### Application Platform

- [Sign-in](https://github.com/shakthi2704/elegant-layers/blob/main/app/(auth)/sign-in/page.tsx): `app/(auth)/sign-in/page.tsx`
- [Auth API](https://github.com/shakthi2704/elegant-layers/blob/main/app/api/auth/%5B...all%5D/route.ts): `app/api/auth/[...all]/route.ts`
- [Role gate](https://github.com/shakthi2704/elegant-layers/blob/main/lib/require-role.ts): `lib/require-role.ts`
- [Authentication](https://github.com/shakthi2704/elegant-layers/blob/main/lib/auth.ts): `lib/auth.ts`
- [Prisma client](https://github.com/shakthi2704/elegant-layers/blob/main/lib/prisma.ts): `lib/prisma.ts`
- **PostgreSQL**
- [Pagination](https://github.com/shakthi2704/elegant-layers/blob/main/components/layout/table-pagination.tsx): `components/layout/table-pagination.tsx`
- [Date formatting](https://github.com/shakthi2704/elegant-layers/blob/main/lib/format.ts): `lib/format.ts`

### Other components

- **Staff**

## Connections

- Staff → POS screen: uses
- POS screen → POS terminal: renders (evidence: `app/(dashboard)/pos/[id]/page.tsx`)
- POS terminal → Sale actions: calls (evidence: `components/pos/pos-terminal.tsx`)
- POS screen → Role gate: checks access (evidence: `app/(dashboard)/pos/[id]/page.tsx`)
- Cake orders → Role gate: checks access (evidence: `app/(dashboard)/cake-orders/[id]/page.tsx`)
- Cake orders → Prisma client: reads order (evidence: `app/(dashboard)/cake-orders/[id]/page.tsx`)
- Cake order forms → Products: references actions (evidence: `components/cake-orders/cake-order-form.tsx`)
- Products → Role gate: checks access (evidence: `app/(dashboard)/products/actions.ts`)
- Products → Prisma client: reads and writes (evidence: `app/(dashboard)/products/actions.ts`)
- Products → PostgreSQL: persists through
- Prisma client → PostgreSQL: connects (evidence: `lib/prisma.ts`)
- Auth API → Authentication: dispatches to (evidence: `app/api/auth/[...all]/route.ts`)
- Role gate → Authentication: checks session (evidence: `lib/require-role.ts`)
- Authentication → Prisma client: uses (evidence: `lib/auth.ts`)
- Sign-in → Role gate: references
- POS screen → Prisma client: loads sale data (evidence: `app/(dashboard)/pos/[id]/page.tsx`)
- POS screen → Date formatting: formats values (evidence: `app/(dashboard)/pos/[id]/page.tsx`)
- Cake orders → Date formatting: formats dates (evidence: `app/(dashboard)/cake-orders/[id]/page.tsx`)
- Reports → Date formatting: uses (evidence: `components/reports/product-sales-table.tsx`)
- Pagination → POS screen: supports lists
