# jerome-marshall/ux-tools architecture

> Architecture diagram of the GitHub repository jerome-marshall/ux-tools, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jerome-marshall/ux-tools
- Repository: https://github.com/jerome-marshall/ux-tools

## Overview

##### Project type and purpose
- This is a full-stack Next.js 13 application that uses the App Router for its UI, tRPC for its API layer, Drizzle (via `drizzle.config.ts`) for ORM/DB schema, and a layered folder structure (`use-cases`, `data-access`, `server/api`, `server/db`).
- Purpose: It provides authenticated user flows (“auth”), a protected dashboard, projects → studies → results workflows, and preview/site public flows. It persists data in a relational database (managed via Drizzle migrations).

##### File structure
- Frontend:
· `src/app` — Next.js pages and layouts, split into three parallel segments: `(app)` (authenticated), `(preview)` (testing preview of studies), and `(site)` (public landing).
· `src/components` — reusable UI components, organized by feature (projects, studies, results, ui primitives).
· `src/hooks`, `src/lib`, `src/utils`, `src/data-access` — client-side logic for fetching, state management, utilities.
· `src/trpc/client.tsx`, `src/trpc/query-client.ts` — tRPC client and React Query integration for front end.
- Backend:
· `src/app/api/trpc/[trpc]/route.ts` & `src/app/api/auth/[...all]/route.ts` — Next.js API routes for tRPC and authentication.
· `src/server/api/routers/*.ts` — tRPC routers for projects, studies, tests.
· `src/server/api/trpc.ts` — tRPC server configuration.
· `src/use-cases` — business-logic layer (authorization, projects, studies, tests, tree-tests).
· `src/data-access/*.ts` & `src/server/db/schema` — data access and schema definitions for Drizzle ORM.
· `src/server/db/migrations` — SQL migrations to evolve the database.
· `src/lib/auth.ts` / `auth-client.ts` — shared auth logic (JWT, sessions).
- Config/build: `next.config.ts`, `drizzle.config.ts`, `tsconfig.json`, linters, bundlers.

##### Key architecture insights from README
- Bootstrapped with Create Next App.
- Next.js App Router, optimized fonts, deployed on Vercel.

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Client Side"
    AuthUI["Next.js React UI - Authenticated"]:::frontend
    PreviewUI["Next.js React UI - Preview"]:::frontend
    PublicUI["Next.js React UI - Public Site"]:::frontend
    TRPCClient["tRPC Client"]:::frontend
  end

  subgraph "Next.js Server & API"
    AuthRoute["API Route - Auth"]:::api
    TRPCRoute["API Route - tRPC"]:::api
  end

  subgraph "tRPC Server"
    TRPCServer["tRPC Server Config"]:::api
    RootRouter["Root Router"]:::api
    ProjectsRouter["Projects Router"]:::api
    StudiesRouter["Studies Router"]:::api
    TestsRouter["Tests Router"]:::api
  end

  subgraph "Business Logic Use-Cases"
    AuthUC["Authorization Use-Case"]:::business
    ProjectsUC["Projects Use-Case"]:::business
    StudiesUC["Studies Use-Case"]:::business
    TestsUC["Tests Use-Case"]:::business
    TreeTestsUC["Tree-Tests Use-Case"]:::business
  end

  subgraph "Data Access & ORM"
    ProjectsDA["Projects Data-Access"]:::data
    StudiesDA["Studies Data-Access"]:::data
    TestsDA["Tests Data-Access"]:::data
    TreeTestsDA["Tree-Tests Data-Access"]:::data
    UtilsDA["Data-Access Utils"]:::data
    DrizzleConfig["Drizzle ORM Configuration"]:::data
    Schema["DB Schema Definitions"]:::data
    Migrations["DB Migrations"]:::data
  end

  subgraph "Shared & External"
    AuthLogic["Authentication Logic"]:::external
    SharedUtils["Shared Utilities & Types"]:::external
    Vercel["Vercel Hosting"]:::external
    CDN["Font CDN"]:::external
  end

  %% Connections
  AuthUI -->|uses| TRPCClient
  PreviewUI -->|uses| TRPCClient
  PublicUI -->|uses| TRPCClient
  TRPCClient -->|calls| TRPCRoute
  AuthUI -->|calls| AuthRoute
  TRPCRoute -->|forwards| TRPCServer
  AuthRoute -->|auth logic| AuthLogic
  TRPCRoute -->|routes to| RootRouter
  RootRouter -->|exposes| ProjectsRouter
  RootRouter -->|exposes| StudiesRouter
  RootRouter -->|exposes| TestsRouter
  ProjectsRouter -->|executes| ProjectsUC
  StudiesRouter -->|executes| StudiesUC
  TestsRouter -->|executes| TestsUC
  ProjectsUC -->|uses| ProjectsDA
  StudiesUC -->|uses| StudiesDA
  TestsUC -->|uses| TestsDA
  TreeTestsUC -->|uses| TreeTestsDA
  ProjectsDA -->|defines| Schema
  StudiesDA -->|defines| Schema
  TestsDA -->|defines| Schema
  TreeTestsDA -->|defines| Schema
  Schema -->|managed by| Migrations
  Vercel -->|hosts| AuthUI
  Vercel -->|hosts| PreviewUI
  Vercel -->|hosts| PublicUI
  Vercel -->|hosts| TRPCRoute
  CDN -->|provides fonts to| AuthUI
  CDN -->|provides fonts to| PreviewUI
  CDN -->|provides fonts to| PublicUI

  %% Click Events
  click AuthUI "https://github.com/jerome-marshall/ux-tools/tree/main/src/app/(app)"
  click PreviewUI "https://github.com/jerome-marshall/ux-tools/tree/main/src/app/(preview)"
  click PublicUI "https://github.com/jerome-marshall/ux-tools/tree/main/src/app/(site)"
  click AuthRoute "https://github.com/jerome-marshall/ux-tools/blob/main/src/app/api/auth/[...all]/route.ts"
  click TRPCRoute "https://github.com/jerome-marshall/ux-tools/blob/main/src/app/api/trpc/[trpc]/route.ts"
  click TRPCClient "https://github.com/jerome-marshall/ux-tools/blob/main/src/trpc/client.tsx"
  click TRPCClient "https://github.com/jerome-marshall/ux-tools/blob/main/src/trpc/query-client.ts"
  click TRPCServer "https://github.com/jerome-marshall/ux-tools/blob/main/src/server/api/trpc.ts"
  click RootRouter "https://github.com/jerome-marshall/ux-tools/blob/main/src/server/api/root.ts"
  click ProjectsRouter "https://github.com/jerome-marshall/ux-tools/blob/main/src/server/api/routers/projects.ts"
  click StudiesRouter "https://github.com/jerome-marshall/ux-tools/blob/main/src/server/api/routers/studies.ts"
  click TestsRouter "https://github.com/jerome-marshall/ux-tools/blob/main/src/server/api/routers/tests.ts"
  click AuthUC "https://github.com/jerome-marshall/ux-tools/blob/main/src/use-cases/authorization.ts"
  click ProjectsUC "https://github.com/jerome-marshall/ux-tools/blob/main/src/use-cases/projects.ts"
  click StudiesUC "https://github.com/jerome-marshall/ux-tools/blob/main/src/use-cases/studies.ts"
  click TestsUC "https://github.com/jerome-marshall/ux-tools/blob/main/src/use-cases/tests.ts"
  click TreeTestsUC "https://github.com/jerome-marshall/ux-tools/blob/main/src/use-cases/tree-tests.ts"
  click ProjectsDA "https://github.com/jerome-marshall/ux-tools/blob/main/src/data-access/projects.ts"
  click StudiesDA "https://github.com/jerome-marshall/ux-tools/blob/main/src/data-access/studies.ts"
  click TestsDA "https://github.com/jerome-marshall/ux-tools/blob/main/src/data-access/tests.ts"
  click TreeTestsDA "https://github.com/jerome-marshall/ux-tools/blob/main/src/data-access/tree-tests.ts"
  click UtilsDA "https://github.com/jerome-marshall/ux-tools/blob/main/src/data-access/utils.ts"
  click DrizzleConfig "https://github.com/jerome-marshall/ux-tools/blob/main/drizzle.config.ts"
  click Schema "https://github.com/jerome-marshall/ux-tools/tree/main/src/server/db/schema"
  click Migrations "https://github.com/jerome-marshall/ux-tools/tree/main/src/server/db/migrations"
  click AuthLogic "https://github.com/jerome-marshall/ux-tools/blob/main/src/lib/auth.ts"
  click AuthLogic "https://github.com/jerome-marshall/ux-tools/blob/main/src/lib/auth-client.ts"
  click SharedUtils "https://github.com/jerome-marshall/ux-tools/tree/main/src/utils"
  click SharedUtils "https://github.com/jerome-marshall/ux-tools/tree/main/src/zod-schemas"

  %% Styles
  classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
  classDef api fill:#d4edda,stroke:#155724,color:#155724
  classDef business fill:#d4edda,stroke:#155724,color:#155724
  classDef data fill:#fff3cd,stroke:#856404,color:#856404
  classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
