# leejinhee1/uxwritingsystem architecture

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

- Interactive diagram: https://gitdiagram.com/leejinhee1/uxwritingsystem
- Repository: https://github.com/leejinhee1/uxwritingsystem

## Overview

UX Writing System is an internal tool for managing five layers of UX-writing rules and auditing UI copy. Its main workflow is text submission through the test experience, rule preparation and deterministic/AI checks, then returning violations and rewrite suggestions while storing an audit record. Reference pages expose the rule layers; admin pages manage them, and audit feedback and bulk checking are additional capabilities. The README documents these product flows; links involving unsampled test and admin pages are documented rather than verified in source excerpts.

Main entry points: [`src/lib/db.ts`](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/lib/db.ts) (Prisma Client), [`src/app/(reference)`](https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/(reference)) (Rule Reference), [`src/app/admin`](https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/admin) (Rule Admin), [`src/app/api/audit/route.ts`](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/route.ts) (Single Audit API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_test_ui["Audit Testing"]
  node_reference_ui["Rule Reference"]
  node_layer_overview["Layer Overview<br/>[LayerOverview.tsx]"]
  node_site_nav["Site Navigation<br/>[Nav.tsx]"]
end

subgraph group_management["Rule Management"]
  node_admin_ui["Rule Admin"]
  node_admin_sidebar["Admin Navigation<br/>[AdminSidebar.tsx]"]
  node_rule_api["Rule CRUD API<br/>[route.ts]"]
  node_rule_item_api["Rule Item API<br/>[route.ts]"]
  node_auth_api["Admin Authentication<br/>[route.ts]"]
end

subgraph group_audit["Audit Processing"]
  node_audit_api["Single Audit API<br/>[route.ts]"]
  node_bulk_api["Bulk Audit API<br/>[route.ts]"]
  node_audit_engine["Audit Engine<br/>[audit.ts]"]
  node_feedback_api["Audit Feedback API<br/>[route.ts]"]
end

subgraph group_persistence["Persistence"]
  node_db_client["Prisma Client<br/>[db.ts]"]
  node_rule_store[("Rules and Audits<br/>[schema.prisma]")]
end

node_writer(("Copywriter"))
node_openai{{"OpenAI gpt-4o"}}

node_writer -.->|"enters copy"| node_test_ui
node_test_ui -.->|"submits text"| node_audit_api
node_audit_api -->|"prepares and audits"| node_audit_engine
node_audit_api -->|"loads rules, saves audit"| node_db_client
node_bulk_api -->|"prepares and audits"| node_audit_engine
node_bulk_api -->|"loads rules, saves audits"| node_db_client
node_audit_engine -->|"requests AI review"| node_openai
node_audit_api -.->|"returns audit results"| node_writer
node_bulk_api -.->|"returns batch summary"| node_writer
node_writer -.->|"browses rules"| node_reference_ui
node_reference_ui -->|"renders overview"| node_layer_overview
node_reference_ui -->|"reads rules"| node_db_client
node_reference_ui -->|"uses navigation"| node_site_nav
node_writer -.->|"manages rules"| node_admin_ui
node_admin_ui -->|"renders navigation"| node_admin_sidebar
node_admin_ui -.->|"performs CRUD"| node_rule_api
node_admin_ui -.->|"updates or deletes"| node_rule_item_api
node_admin_sidebar -->|"logs out"| node_auth_api
node_rule_api -->|"reads and creates rules"| node_db_client
node_rule_item_api -->|"updates and deletes rules"| node_db_client
node_feedback_api -->|"updates feedback"| node_db_client
node_db_client -.->|"persists records"| node_rule_store

click node_test_ui "https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/test"
click node_reference_ui "https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/(reference)"
click node_layer_overview "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/LayerOverview.tsx"
click node_site_nav "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/Nav.tsx"
click node_admin_ui "https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/admin"
click node_admin_sidebar "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/AdminSidebar.tsx"
click node_rule_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/rules/route.ts"
click node_rule_item_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/rules/%5Bid%5D/route.ts"
click node_auth_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/auth/route.ts"
click node_audit_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/route.ts"
click node_bulk_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/bulk/route.ts"
click node_audit_engine "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/lib/audit.ts"
click node_feedback_api "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/%5Bid%5D/feedback/route.ts"
click node_db_client "https://github.com/leejinhee1/uxwritingsystem/blob/main/src/lib/db.ts"
click node_rule_store "https://github.com/leejinhee1/uxwritingsystem/blob/main/prisma/schema.prisma"

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_test_ui,node_reference_ui,node_layer_overview,node_site_nav toneBlue
class node_admin_ui,node_admin_sidebar,node_rule_api,node_rule_item_api,node_auth_api toneAmber
class node_audit_api,node_bulk_api,node_audit_engine,node_feedback_api toneMint
class node_db_client,node_rule_store toneRose
class node_writer,node_openai toneIndigo
```

## Components

### User Experience

- [Audit Testing](https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/test): `src/app/test`
- [Rule Reference](https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/(reference)): `src/app/(reference)`
- [Layer Overview](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/LayerOverview.tsx): `src/components/LayerOverview.tsx`
- [Site Navigation](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/Nav.tsx): `src/components/Nav.tsx`

### Rule Management

- [Rule Admin](https://github.com/leejinhee1/uxwritingsystem/tree/main/src/app/admin): `src/app/admin`
- [Admin Navigation](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/components/AdminSidebar.tsx): `src/components/AdminSidebar.tsx`
- [Rule CRUD API](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/rules/route.ts): `src/app/api/rules/route.ts`
- [Rule Item API](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/rules/%5Bid%5D/route.ts): `src/app/api/rules/[id]/route.ts`
- [Admin Authentication](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/auth/route.ts): `src/app/api/auth/route.ts`

### Audit Processing

- [Single Audit API](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/route.ts): `src/app/api/audit/route.ts`
- [Bulk Audit API](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/bulk/route.ts): `src/app/api/audit/bulk/route.ts`
- [Audit Engine](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/lib/audit.ts): `src/lib/audit.ts`
- [Audit Feedback API](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/app/api/audit/%5Bid%5D/feedback/route.ts): `src/app/api/audit/[id]/feedback/route.ts`

### Persistence

- [Prisma Client](https://github.com/leejinhee1/uxwritingsystem/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Rules and Audits](https://github.com/leejinhee1/uxwritingsystem/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **Copywriter**
- **OpenAI gpt-4o**

## Connections

- Copywriter → Audit Testing: enters copy (evidence: `README.md`)
- Audit Testing → Single Audit API: submits text (evidence: `README.md`)
- Single Audit API → Audit Engine: prepares and audits (evidence: `src/app/api/audit/route.ts`)
- Single Audit API → Prisma Client: loads rules, saves audit (evidence: `src/app/api/audit/route.ts`)
- Bulk Audit API → Audit Engine: prepares and audits (evidence: `src/app/api/audit/bulk/route.ts`)
- Bulk Audit API → Prisma Client: loads rules, saves audits (evidence: `src/app/api/audit/bulk/route.ts`)
- Audit Engine → OpenAI gpt-4o: requests AI review (evidence: `src/lib/audit.ts`)
- Single Audit API → Copywriter: returns audit results (evidence: `README.md`)
- Bulk Audit API → Copywriter: returns batch summary (evidence: `README.md`)
- Copywriter → Rule Reference: browses rules (evidence: `README.md`)
- Rule Reference → Layer Overview: renders overview (evidence: `src/app/(reference)/page.tsx`)
- Rule Reference → Prisma Client: reads rules (evidence: `src/app/(reference)/page.tsx`)
- Rule Reference → Site Navigation: uses navigation (evidence: `src/app/(reference)/layout.tsx`)
- Copywriter → Rule Admin: manages rules (evidence: `README.md`)
- Rule Admin → Admin Navigation: renders navigation (evidence: `src/app/admin/layout.tsx`)
- Rule Admin → Rule CRUD API: performs CRUD (evidence: `README.md`)
- Rule Admin → Rule Item API: updates or deletes (evidence: `README.md`)
- Admin Navigation → Admin Authentication: logs out (evidence: `src/components/AdminSidebar.tsx`)
- Rule CRUD API → Prisma Client: reads and creates rules (evidence: `src/app/api/rules/route.ts`)
- Rule Item API → Prisma Client: updates and deletes rules (evidence: `src/app/api/rules/[id]/route.ts`)
- Audit Feedback API → Prisma Client: updates feedback (evidence: `src/app/api/audit/[id]/feedback/route.ts`)
- Prisma Client → Rules and Audits: persists records (evidence: `src/lib/db.ts`)
