How shyamkano/lumen works
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: server.ts Supabase adapters · EditorWorkspace.tsx Editor workspace · [slug]/page.tsx Canonical post reader · lineage/page.tsx Lineage reader
Components 22
User experience
App Router pages and client workspace.
- App shell · Composes global providers, navigation, theming, and onboarding.
src/app/layout.tsx - Writing workspace · Core narrative creation and publication entry point.
src/app/new/page.tsx - Editor workspace · Coordinates inputs, previews, metadata, and draft persistence.
src/components/editor/EditorWorkspace.tsx - Rich text editor
src/components/editor/TipTapEditor.tsx - Canonical post reader · Version-oriented published narrative surface.
src/app/post/[slug]/page.tsx - Lineage reader · Displays fork genealogy.
src/app/post/[slug]/lineage/page.tsx - Archival reader
src/components/post/ArchivalReader.tsx - Lineage tree
src/components/post/LineageTree.tsx - Community surfaces · Feeds, maps, requests, aliases, and social discovery.
src/app/feed/page.tsx
Server boundary
Protected routes, server actions, and APIs.
- Auth flows · Email/social login and profile recovery.
src/app/auth/actions.ts - OAuth callback
src/app/auth/callback/route.ts - Request proxy · Contextualizes or protects requests before execution.
src/proxy.ts - Supabase session middleware
src/lib/supabase/middleware.ts - Post mutations · Central post write boundary.
src/app/actions/posts.ts - Draft mutations
src/app/actions/drafts.ts - Upload API · Accepts authoring media uploads.
src/app/api/upload/route.ts - Social mutations · Follows, engagement, and community interactions.
src/app/actions/social.ts - Editorial AI API · Keeps editorial assistance credentials server-side.
src/app/api/ai/route.ts
Data and identity
Supabase adapters and database contract.
- Supabase adapters · Separates browser, authenticated server, and privileged access.
src/lib/supabase/server.ts - Supabase PostgreSQL · Stores structured narratives, identities, lineage, and social data.
supabase-schema.sql
External consumers
AI provider and machine-facing access.
- Mistral integration
src/lib/ai/openai.ts - Public posts API · Machine-consumable post retrieval by username and slug.
src/app/api/external/posts/[username]/[slug]/route.ts
Connections 21
- 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