# shyamkano/lumen architecture

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

- Interactive diagram: https://gitdiagram.com/shyamkano/lumen
- Repository: https://github.com/shyamkano/lumen

## Overview

#### Purpose and Runtime
LUMEN is a Next.js 16 App Router publishing and knowledge-archival platform: users create long-form, code, and audio narratives; discover them socially; and preserve forks, versions, and anonymous identities. React 19 renders server/client UI, with deployment-oriented routing rooted at `src/app/layout.tsx` and `src/app/page.tsx`.

#### Application Shell and Access Control
The root layout composes global styling, navigation, theming, onboarding, and query-state providers. Authentication is Supabase-based for email/social login and profile recovery; middleware/proxy integration protects or contextualizes requests before page/action execution.
- `src/app/layout.tsx`
- `src/app/auth/actions.ts`
- `src/app/auth/callback/route.ts`
- `src/proxy.ts`
- `src/lib/supabase/middleware.ts`

#### Persistence and Service Boundary
Supabase PostgreSQL is the system of record, including structured narrative data (notably JSONB per README). Separate client, server, and privileged admin Supabase adapters establish the trust boundary between browser reads, authenticated server operations, and administrative work. The database contract is represented in `supabase-schema.sql` and generated/domain types.
- `src/lib/supabase/client.ts`
- `src/lib/supabase/server.ts`
- `src/lib/supabase/admin.ts`
- `supabase-schema.sql`
- `src/types/supabase.ts`

#### Narrative Creation and Publication
The writing workspace is the core authoring pipeline: TipTap/ProseMirror-based rich text, code/audio/image inputs, previews, metadata, and draft persistence produce publishable posts. Server actions centralize mutations for posts and drafts, while validations constrain content at the write boundary. Uploads are exposed through a dedicated route.
- `src/app/new/page.tsx`
- `src/components/editor/EditorWorkspace.tsx`
- `src/components/editor/TipTapEditor.tsx`
- `src/app/actions/posts.ts`
- `src/app/actions/drafts.ts`
- `src/app/api/upload/route.ts`

#### Archival, Lineage, and Read Surfaces
Published narratives are consumed through canonical post routes, archival readers, and lineage visualizations. The architecture treats posts as evolving assets: post views support version/history-oriented reading and fork genealogy, with post analytics as a separate surface.
- `src/app/post/[slug]/page.tsx`
- `src/app/post/[slug]/lineage/page.tsx`
- `src/components/post/ArchivalReader.tsx`
- `src/components/post/LineageTree.tsx`
- `src/app/post/[slug]/analytics/page.tsx`

#### Network and Discovery Mechanics
Feeds, profiles, search, maps, requests, comments, follows, engagement, and notifications form the community layer around the post graph. Mutations are grouped by domain as server actions; TanStack Query provider supports client-side cached and optimistic interaction state. Shadow aliases are an alternate identity/read route.
- `src/app/feed/page.tsx`
- `src/app/map/page.tsx`
- `src/app/requests/page.tsx`
- `src/app/actions/social.ts`
- `src/app/actions/comments.ts`
- `src/app/actions/notifications.ts`
- `src/app/alias/[alias]/page.tsx`

#### AI and External Integration
Mistral-backed editorial assistance is isolated behind server API routes and AI library modules, keeping API credentials off the client. Public external post endpoints provide a machine-consumable boundary for retrieving posts by username and slug.
- `src/app/api/ai/route.ts`
- `src/app/api/ai/narrative/route.ts`
- `src/lib/ai/openai.ts`
- `src/app/api/external/posts/[username]/route.ts`
- `src/app/api/external/posts/[username]/[slug]/route.ts

#### Governance and Operational Surfaces
Administrative moderation/user controls, user settings, notification preferences, analytics, and public crawler metadata complete the operational perimeter.
- `src/app/admin/page.tsx`
- `src/app/admin/actions.ts`
- `src/app/settings/page.tsx`
- `src/app/analytics/page.tsx`
- `src/app/sitemap.ts`

Main entry points: [`src/lib/supabase/server.ts`](https://github.com/shyamkano/lumen/blob/main/src/lib/supabase/server.ts) (Supabase adapters), [`src/components/editor/EditorWorkspace.tsx`](https://github.com/shyamkano/lumen/blob/main/src/components/editor/EditorWorkspace.tsx) (Editor workspace), [`src/app/post/[slug]/page.tsx`](https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/page.tsx) (Canonical post reader), [`src/app/post/[slug]/lineage/page.tsx`](https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/lineage/page.tsx) (Lineage reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User experience"]
  node_root_layout["App shell<br/>Next layout<br/>[layout.tsx]"]
  node_authoring_page["Writing workspace<br/>authoring page<br/>[page.tsx]"]
  node_editor_workspace["Editor workspace<br/>React client"]
  node_tiptap_editor["Rich text editor<br/>TipTap editor<br/>[TipTapEditor.tsx]"]
  node_post_reader["Canonical post reader<br/>post page<br/>[page.tsx]"]
  node_lineage_view["Lineage reader<br/>lineage page<br/>[page.tsx]"]
  node_archival_reader["Archival reader<br/>React view<br/>[ArchivalReader.tsx]"]
  node_lineage_tree["Lineage tree<br/>React visualization<br/>[LineageTree.tsx]"]
  node_community["Community surfaces<br/>feed and discovery pages<br/>[page.tsx]"]
end

subgraph group_server["Server boundary"]
  node_auth_actions["Auth flows<br/>server actions<br/>[actions.ts]"]
  node_auth_callback["OAuth callback<br/>route handler<br/>[route.ts]"]
  node_request_proxy{{"Request proxy<br/>middleware<br/>[proxy.ts]"}}
  node_supabase_middleware["Supabase session middleware<br/>middleware adapter<br/>[middleware.ts]"]
  node_post_actions["Post mutations<br/>server actions<br/>[posts.ts]"]
  node_draft_actions["Draft mutations<br/>server actions<br/>[drafts.ts]"]
  node_upload_api["Upload API<br/>route handler<br/>[route.ts]"]
  node_social_actions["Social mutations<br/>server actions<br/>[social.ts]"]
  node_ai_api["Editorial AI API<br/>route handler<br/>[route.ts]"]
end

subgraph group_data["Data and identity"]
  node_supabase_adapters["Supabase adapters<br/>client/server/admin adapters<br/>[server.ts]"]
  node_database[("Supabase PostgreSQL<br/>system of record")]
end

subgraph group_external["External consumers"]
  node_ai_client["Mistral integration<br/>AI library<br/>[openai.ts]"]
  node_external_posts_api["Public posts API<br/>route handler<br/>[route.ts]"]
end

node_root_layout -->|"requests pass through"| node_request_proxy
node_request_proxy -->|"uses session handling"| node_supabase_middleware
node_auth_actions -->|"authenticates via"| node_supabase_adapters
node_auth_callback -->|"establishes session"| node_supabase_adapters
node_authoring_page -->|"renders"| node_editor_workspace
node_editor_workspace -->|"hosts"| node_tiptap_editor
node_editor_workspace -->|"publishes"| node_post_actions
node_editor_workspace -->|"persists drafts"| node_draft_actions
node_editor_workspace -->|"uploads media"| node_upload_api
node_post_actions -->|"writes through"| node_supabase_adapters
node_draft_actions -->|"writes through"| node_supabase_adapters
node_upload_api -->|"stores metadata"| node_supabase_adapters
node_post_reader -->|"renders"| node_archival_reader
node_lineage_view -->|"renders"| node_lineage_tree
node_post_reader -->|"reads post history"| node_supabase_adapters
node_lineage_view -->|"reads genealogy"| node_supabase_adapters
node_community -->|"submits interactions"| node_social_actions
node_social_actions -->|"writes through"| node_supabase_adapters
node_ai_api -->|"invokes"| node_ai_client
node_external_posts_api -->|"retrieves posts"| node_supabase_adapters
node_supabase_adapters -->|"reads and writes"| node_database

click node_root_layout "https://github.com/shyamkano/lumen/blob/main/src/app/layout.tsx"
click node_auth_actions "https://github.com/shyamkano/lumen/blob/main/src/app/auth/actions.ts"
click node_auth_callback "https://github.com/shyamkano/lumen/blob/main/src/app/auth/callback/route.ts"
click node_request_proxy "https://github.com/shyamkano/lumen/blob/main/src/proxy.ts"
click node_supabase_middleware "https://github.com/shyamkano/lumen/blob/main/src/lib/supabase/middleware.ts"
click node_authoring_page "https://github.com/shyamkano/lumen/blob/main/src/app/new/page.tsx"
click node_editor_workspace "https://github.com/shyamkano/lumen/blob/main/src/components/editor/EditorWorkspace.tsx"
click node_tiptap_editor "https://github.com/shyamkano/lumen/blob/main/src/components/editor/TipTapEditor.tsx"
click node_post_actions "https://github.com/shyamkano/lumen/blob/main/src/app/actions/posts.ts"
click node_draft_actions "https://github.com/shyamkano/lumen/blob/main/src/app/actions/drafts.ts"
click node_upload_api "https://github.com/shyamkano/lumen/blob/main/src/app/api/upload/route.ts"
click node_post_reader "https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/page.tsx"
click node_lineage_view "https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/lineage/page.tsx"
click node_archival_reader "https://github.com/shyamkano/lumen/blob/main/src/components/post/ArchivalReader.tsx"
click node_lineage_tree "https://github.com/shyamkano/lumen/blob/main/src/components/post/LineageTree.tsx"
click node_community "https://github.com/shyamkano/lumen/blob/main/src/app/feed/page.tsx"
click node_social_actions "https://github.com/shyamkano/lumen/blob/main/src/app/actions/social.ts"
click node_ai_api "https://github.com/shyamkano/lumen/blob/main/src/app/api/ai/route.ts"
click node_ai_client "https://github.com/shyamkano/lumen/blob/main/src/lib/ai/openai.ts"
click node_external_posts_api "https://github.com/shyamkano/lumen/blob/main/src/app/api/external/posts/%5Busername%5D/%5Bslug%5D/route.ts"
click node_supabase_adapters "https://github.com/shyamkano/lumen/blob/main/src/lib/supabase/server.ts"
click node_database "https://github.com/shyamkano/lumen/blob/main/supabase-schema.sql"

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_root_layout,node_authoring_page,node_editor_workspace,node_tiptap_editor,node_post_reader,node_lineage_view,node_archival_reader,node_lineage_tree,node_community toneBlue
class node_auth_actions,node_auth_callback,node_request_proxy,node_supabase_middleware,node_post_actions,node_draft_actions,node_upload_api,node_social_actions,node_ai_api toneAmber
class node_supabase_adapters,node_database toneMint
class node_ai_client,node_external_posts_api toneRose
```

## Components

### User experience

App Router pages and client workspace.

- [App shell](https://github.com/shyamkano/lumen/blob/main/src/app/layout.tsx): Next layout · Composes global providers, navigation, theming, and onboarding. · `src/app/layout.tsx`
- [Writing workspace](https://github.com/shyamkano/lumen/blob/main/src/app/new/page.tsx): authoring page · Core narrative creation and publication entry point. · `src/app/new/page.tsx`
- [Editor workspace](https://github.com/shyamkano/lumen/blob/main/src/components/editor/EditorWorkspace.tsx): React client · Coordinates inputs, previews, metadata, and draft persistence. · `src/components/editor/EditorWorkspace.tsx`
- [Rich text editor](https://github.com/shyamkano/lumen/blob/main/src/components/editor/TipTapEditor.tsx): TipTap editor · `src/components/editor/TipTapEditor.tsx`
- [Canonical post reader](https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/page.tsx): post page · Version-oriented published narrative surface. · `src/app/post/[slug]/page.tsx`
- [Lineage reader](https://github.com/shyamkano/lumen/blob/main/src/app/post/%5Bslug%5D/lineage/page.tsx): lineage page · Displays fork genealogy. · `src/app/post/[slug]/lineage/page.tsx`
- [Archival reader](https://github.com/shyamkano/lumen/blob/main/src/components/post/ArchivalReader.tsx): React view · `src/components/post/ArchivalReader.tsx`
- [Lineage tree](https://github.com/shyamkano/lumen/blob/main/src/components/post/LineageTree.tsx): React visualization · `src/components/post/LineageTree.tsx`
- [Community surfaces](https://github.com/shyamkano/lumen/blob/main/src/app/feed/page.tsx): feed and discovery pages · Feeds, maps, requests, aliases, and social discovery. · `src/app/feed/page.tsx`

### Server boundary

Protected routes, server actions, and APIs.

- [Auth flows](https://github.com/shyamkano/lumen/blob/main/src/app/auth/actions.ts): server actions · Email/social login and profile recovery. · `src/app/auth/actions.ts`
- [OAuth callback](https://github.com/shyamkano/lumen/blob/main/src/app/auth/callback/route.ts): route handler · `src/app/auth/callback/route.ts`
- [Request proxy](https://github.com/shyamkano/lumen/blob/main/src/proxy.ts): middleware · Contextualizes or protects requests before execution. · `src/proxy.ts`
- [Supabase session middleware](https://github.com/shyamkano/lumen/blob/main/src/lib/supabase/middleware.ts): middleware adapter · `src/lib/supabase/middleware.ts`
- [Post mutations](https://github.com/shyamkano/lumen/blob/main/src/app/actions/posts.ts): server actions · Central post write boundary. · `src/app/actions/posts.ts`
- [Draft mutations](https://github.com/shyamkano/lumen/blob/main/src/app/actions/drafts.ts): server actions · `src/app/actions/drafts.ts`
- [Upload API](https://github.com/shyamkano/lumen/blob/main/src/app/api/upload/route.ts): route handler · Accepts authoring media uploads. · `src/app/api/upload/route.ts`
- [Social mutations](https://github.com/shyamkano/lumen/blob/main/src/app/actions/social.ts): server actions · Follows, engagement, and community interactions. · `src/app/actions/social.ts`
- [Editorial AI API](https://github.com/shyamkano/lumen/blob/main/src/app/api/ai/route.ts): route handler · Keeps editorial assistance credentials server-side. · `src/app/api/ai/route.ts`

### Data and identity

Supabase adapters and database contract.

- [Supabase adapters](https://github.com/shyamkano/lumen/blob/main/src/lib/supabase/server.ts): client/server/admin adapters · Separates browser, authenticated server, and privileged access. · `src/lib/supabase/server.ts`
- [Supabase PostgreSQL](https://github.com/shyamkano/lumen/blob/main/supabase-schema.sql): system of record · Stores structured narratives, identities, lineage, and social data. · `supabase-schema.sql`

### External consumers

AI provider and machine-facing access.

- [Mistral integration](https://github.com/shyamkano/lumen/blob/main/src/lib/ai/openai.ts): AI library · `src/lib/ai/openai.ts`
- [Public posts API](https://github.com/shyamkano/lumen/blob/main/src/app/api/external/posts/%5Busername%5D/%5Bslug%5D/route.ts): route handler · Machine-consumable post retrieval by username and slug. · `src/app/api/external/posts/[username]/[slug]/route.ts`

## Connections

- App shell → Request proxy: requests pass through
- Request proxy → Supabase session middleware: uses session handling
- Auth flows → Supabase adapters: authenticates via
- OAuth callback → Supabase adapters: establishes session
- Writing workspace → Editor workspace: renders
- Editor workspace → Rich text editor: hosts
- Editor workspace → Post mutations: publishes
- Editor workspace → Draft mutations: persists drafts
- Editor workspace → Upload API: uploads media
- Post mutations → Supabase adapters: writes through
- Draft mutations → Supabase adapters: writes through
- Upload API → Supabase adapters: stores metadata
- Canonical post reader → Archival reader: renders
- Lineage reader → Lineage tree: renders
- Canonical post reader → Supabase adapters: reads post history
- Lineage reader → Supabase adapters: reads genealogy
- Community surfaces → Social mutations: submits interactions
- Social mutations → Supabase adapters: writes through
- Editorial AI API → Mistral integration: invokes
- Public posts API → Supabase adapters: retrieves posts
- Supabase adapters → Supabase PostgreSQL: reads and writes
