# artixxkrieger/kccf-rotc architecture

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

- Interactive diagram: https://gitdiagram.com/artixxkrieger/kccf-rotc
- Repository: https://github.com/artixxkrieger/kccf-rotc

## Overview

This is a Next.js inventory and supply-management application, with screens for dashboard, inventory, receiving, requests, issuances, reports, audit, and users. The apparent user journey spans stock receipt, request handling, issuance, returns, and review, but the README is only the framework starter template and does not document that workflow. The graph therefore preserves the domain areas visible in the tree without asserting an unverified sequence between them. API-to-database and authentication relationships are included where the source index or excerpts show them; unsampled UI-to-endpoint wiring is omitted.

Main entry points: [`lib/db.ts`](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/db.ts) (Neon database), [`lib/audit.ts`](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/audit.ts) (Audit logging), [`lib/api.ts`](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/api.ts) (API client), [`lib/guard.ts`](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/guard.ts) (Permission guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Operations UI"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_inventory["Inventory<br/>[page.tsx]"]
  node_receiving["Receiving<br/>[page.tsx]"]
  node_requests["Requests<br/>[page.tsx]"]
  node_issuances["Issuances<br/>[page.tsx]"]
  node_reports["Reports<br/>[page.tsx]"]
  node_auditui["Audit view<br/>[page.tsx]"]
  node_usersui["User management<br/>[page.tsx]"]
  node_settings["Settings<br/>[page.tsx]"]
end

subgraph group_service["Application API"]
  node_dashboardapi["Dashboard data<br/>[route.ts]"]
  node_inventoryapi["Inventory service<br/>[route.ts]"]
  node_receivingapi["Receiving service<br/>[route.ts]"]
  node_requestsapi["Request service<br/>[route.ts]"]
  node_issuancesapi["Issuance service<br/>[route.ts]"]
  node_returnsapi["Returns service<br/>[route.ts]"]
  node_reportsapi["Reports service<br/>[route.ts]"]
  node_auditapi["Audit service<br/>[route.ts]"]
  node_usersapi["User service<br/>[route.ts]"]
  node_storageapi["Storage service<br/>[route.ts]"]
end

subgraph group_identity["Identity and controls"]
  node_clientapi["API client<br/>[api.ts]"]
  node_login["Login and signup<br/>[route.ts]"]
  node_signup["Account signup<br/>[route.ts]"]
  node_session["Signed sessions<br/>[session.ts]"]
  node_authorization["Permission guard<br/>[guard.ts]"]
  node_rbac["Role permissions<br/>[rbac.ts]"]
  node_rate["Rate limiting<br/>[rate-limit.ts]"]
  node_sanitize["Input sanitation<br/>[sanitize.ts]"]
end

subgraph group_data["Data and audit"]
  node_database[("Neon database<br/>[db.ts]")]
  node_auditlog["Audit logging<br/>[audit.ts]"]
  node_auditactions["Audit actions<br/>[audit-actions.ts]"]
  node_storage["Storage adapter<br/>[storage.ts]"]
end

node_user(("Staff user"))

node_user -.->|"opens"| node_dashboard
node_user -.->|"manages"| node_inventory
node_user -.->|"records"| node_receiving
node_user -.->|"submits"| node_requests
node_user -.->|"reviews"| node_issuances
node_user -.->|"views"| node_reports
node_user -.->|"reviews"| node_auditui
node_user -.->|"manages"| node_usersui
node_user -.->|"configures"| node_settings
node_dashboard -->|"uses"| node_clientapi
node_inventory -->|"uses"| node_clientapi
node_receiving -->|"uses"| node_clientapi
node_requests -->|"uses"| node_clientapi
node_issuances -->|"uses"| node_clientapi
node_reports -->|"uses"| node_clientapi
node_auditui -->|"uses"| node_clientapi
node_settings -->|"uses"| node_clientapi
node_dashboardapi -->|"queries"| node_database
node_inventoryapi -->|"reads and writes"| node_database
node_receivingapi -->|"reads and writes"| node_database
node_requestsapi -->|"reads and writes"| node_database
node_issuancesapi -->|"reads and writes"| node_database
node_returnsapi -->|"reads and writes"| node_database
node_usersapi -->|"reads and writes"| node_database
node_storageapi -->|"delegates"| node_storage
node_storage -.->|"uses"| node_database
node_login -->|"queries"| node_database
node_login -->|"signs"| node_session
node_login -->|"limits"| node_rate
node_login -->|"records"| node_auditlog
node_signup -->|"creates account"| node_database
node_signup -->|"signs"| node_session
node_signup -->|"limits"| node_rate
node_signup -->|"records"| node_auditlog
node_auditlog -->|"inserts records"| node_database
node_auditlog -->|"uses types"| node_auditactions
node_inventoryapi -->|"records changes"| node_auditlog
node_receivingapi -->|"records changes"| node_auditlog
node_requestsapi -->|"records changes"| node_auditlog
node_issuancesapi -->|"records changes"| node_auditlog
node_returnsapi -->|"records changes"| node_auditlog
node_inventoryapi -->|"checks access"| node_authorization
node_receivingapi -->|"checks access"| node_authorization
node_requestsapi -->|"checks access"| node_authorization
node_issuancesapi -->|"checks access"| node_authorization
node_authorization -->|"checks roles"| node_rbac
node_authorization -->|"gets user"| node_session
node_inventoryapi -->|"cleans input"| node_sanitize

click node_dashboard "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/dashboard/page.tsx"
click node_inventory "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/inventory/page.tsx"
click node_receiving "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/receiving/page.tsx"
click node_requests "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/requests/page.tsx"
click node_issuances "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/issuances/page.tsx"
click node_reports "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/reports/page.tsx"
click node_auditui "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/audit/page.tsx"
click node_usersui "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/users/page.tsx"
click node_settings "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/settings/page.tsx"
click node_clientapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/api.ts"
click node_dashboardapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/dashboard/route.ts"
click node_inventoryapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/inventory/route.ts"
click node_receivingapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/receiving/route.ts"
click node_requestsapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/requests/route.ts"
click node_issuancesapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/issuances/route.ts"
click node_returnsapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/returns/route.ts"
click node_reportsapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/reports/route.ts"
click node_auditapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/audit/route.ts"
click node_usersapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/users/route.ts"
click node_storageapi "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/storage/route.ts"
click node_login "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/login/route.ts"
click node_signup "https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/signup/route.ts"
click node_session "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/session.ts"
click node_authorization "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/guard.ts"
click node_rbac "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/rbac.ts"
click node_rate "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/rate-limit.ts"
click node_database "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/db.ts"
click node_auditlog "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/audit.ts"
click node_auditactions "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/audit-actions.ts"
click node_sanitize "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/sanitize.ts"
click node_storage "https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/storage.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_dashboard,node_inventory,node_receiving,node_requests,node_issuances,node_reports,node_auditui,node_usersui,node_settings,node_user toneBlue
class node_dashboardapi,node_inventoryapi,node_receivingapi,node_requestsapi,node_issuancesapi,node_returnsapi,node_reportsapi,node_auditapi,node_usersapi,node_storageapi toneAmber
class node_clientapi,node_login,node_signup,node_session,node_authorization,node_rbac,node_rate,node_sanitize toneMint
class node_database,node_auditlog,node_auditactions,node_storage toneRose
```

## Components

### Operations UI

- [Dashboard](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`
- [Inventory](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/inventory/page.tsx): `app/(app)/inventory/page.tsx`
- [Receiving](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/receiving/page.tsx): `app/(app)/receiving/page.tsx`
- [Requests](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/requests/page.tsx): `app/(app)/requests/page.tsx`
- [Issuances](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/issuances/page.tsx): `app/(app)/issuances/page.tsx`
- [Reports](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/reports/page.tsx): `app/(app)/reports/page.tsx`
- [Audit view](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/audit/page.tsx): `app/(app)/audit/page.tsx`
- [User management](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/users/page.tsx): `app/(app)/users/page.tsx`
- [Settings](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/(app)/settings/page.tsx): `app/(app)/settings/page.tsx`

### Application API

- [Dashboard data](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/dashboard/route.ts): `app/api/dashboard/route.ts`
- [Inventory service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/inventory/route.ts): `app/api/inventory/route.ts`
- [Receiving service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/receiving/route.ts): `app/api/receiving/route.ts`
- [Request service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/requests/route.ts): `app/api/requests/route.ts`
- [Issuance service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/issuances/route.ts): `app/api/issuances/route.ts`
- [Returns service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/returns/route.ts): `app/api/returns/route.ts`
- [Reports service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/reports/route.ts): `app/api/reports/route.ts`
- [Audit service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/audit/route.ts): `app/api/audit/route.ts`
- [User service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/users/route.ts): `app/api/users/route.ts`
- [Storage service](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/storage/route.ts): `app/api/storage/route.ts`

### Identity and controls

- [API client](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/api.ts): `lib/api.ts`
- [Login and signup](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/login/route.ts): `app/api/login/route.ts`
- [Account signup](https://github.com/artixxkrieger/kccf-rotc/blob/main/app/api/signup/route.ts): `app/api/signup/route.ts`
- [Signed sessions](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/session.ts): `lib/session.ts`
- [Permission guard](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/guard.ts): `lib/guard.ts`
- [Role permissions](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/rbac.ts): `lib/rbac.ts`
- [Rate limiting](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/rate-limit.ts): `lib/rate-limit.ts`
- [Input sanitation](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/sanitize.ts): `lib/sanitize.ts`

### Data and audit

- [Neon database](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/db.ts): `lib/db.ts`
- [Audit logging](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/audit.ts): `lib/audit.ts`
- [Audit actions](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/audit-actions.ts): `lib/audit-actions.ts`
- [Storage adapter](https://github.com/artixxkrieger/kccf-rotc/blob/main/lib/storage.ts): `lib/storage.ts`

### Other components

- **Staff user**

## Connections

- Staff user → Dashboard: opens
- Staff user → Inventory: manages
- Staff user → Receiving: records
- Staff user → Requests: submits
- Staff user → Issuances: reviews
- Staff user → Reports: views
- Staff user → Audit view: reviews
- Staff user → User management: manages
- Staff user → Settings: configures
- Dashboard → API client: uses (evidence: `app/(app)/dashboard/page.tsx`)
- Inventory → API client: uses (evidence: `app/(app)/inventory/page.tsx`)
- Receiving → API client: uses
- Requests → API client: uses (evidence: `app/(app)/requests/page.tsx`)
- Issuances → API client: uses (evidence: `app/(app)/issuances/page.tsx`)
- Reports → API client: uses (evidence: `app/(app)/reports/page.tsx`)
- Audit view → API client: uses (evidence: `app/(app)/audit/page.tsx`)
- Settings → API client: uses (evidence: `app/(app)/settings/page.tsx`)
- Dashboard data → Neon database: queries (evidence: `app/api/dashboard/route.ts`)
- Inventory service → Neon database: reads and writes (evidence: `app/api/inventory/route.ts`)
- Receiving service → Neon database: reads and writes (evidence: `app/api/receiving/route.ts`)
- Request service → Neon database: reads and writes (evidence: `app/api/requests/route.ts`)
- Issuance service → Neon database: reads and writes (evidence: `app/api/issuances/route.ts`)
- Returns service → Neon database: reads and writes (evidence: `app/api/returns/route.ts`)
- User service → Neon database: reads and writes (evidence: `app/api/users/route.ts`)
- Storage service → Storage adapter: delegates (evidence: `app/api/storage/route.ts`)
- Storage adapter → Neon database: uses
- Login and signup → Neon database: queries (evidence: `app/api/login/route.ts`)
- Login and signup → Signed sessions: signs (evidence: `app/api/login/route.ts`)
- Login and signup → Rate limiting: limits (evidence: `app/api/login/route.ts`)
- Login and signup → Audit logging: records (evidence: `app/api/login/route.ts`)
- Account signup → Neon database: creates account (evidence: `app/api/signup/route.ts`)
- Account signup → Signed sessions: signs (evidence: `app/api/signup/route.ts`)
- Account signup → Rate limiting: limits (evidence: `app/api/signup/route.ts`)
- Account signup → Audit logging: records (evidence: `app/api/signup/route.ts`)
- Audit logging → Neon database: inserts records (evidence: `lib/audit.ts`)
- Audit logging → Audit actions: uses types (evidence: `lib/audit.ts`)
- Inventory service → Audit logging: records changes (evidence: `app/api/inventory/route.ts`)
- Receiving service → Audit logging: records changes (evidence: `app/api/receiving/route.ts`)
- Request service → Audit logging: records changes (evidence: `app/api/requests/route.ts`)
- Issuance service → Audit logging: records changes (evidence: `app/api/issuances/route.ts`)
- Returns service → Audit logging: records changes (evidence: `app/api/returns/route.ts`)
- Inventory service → Permission guard: checks access (evidence: `app/api/inventory/route.ts`)
- Receiving service → Permission guard: checks access (evidence: `app/api/receiving/route.ts`)
- Request service → Permission guard: checks access (evidence: `app/api/requests/route.ts`)
- Issuance service → Permission guard: checks access (evidence: `app/api/issuances/route.ts`)
- Permission guard → Role permissions: checks roles (evidence: `lib/guard.ts`)
- Permission guard → Signed sessions: gets user (evidence: `lib/guard.ts`)
- Inventory service → Input sanitation: cleans input (evidence: `app/api/inventory/route.ts`)
