How irfan-rg/inkwell works
Purpose and Runtime
Inkwell is a multi-user Markdown blogging platform: readers browse and search published posts, while authenticated authors manage categories, drafts, posts, and media. It runs as a TypeScript Next.js App Router application with React, Tailwind/Radix UI, tRPC, Drizzle, PostgreSQL/Supabase, and Vercel-oriented deployment.
Primary application shell and route fallback are in app/layout.tsx, app/page.tsx, and app/not-found.tsx.
Route Domains and Entry Points
Public pages are grouped independently from authoring routes:
• Landing, about, blog index, and slugged reader pages: app/(public)/page.tsx, app/(public)/blogs/page.tsx, app/(public)/blogs/[slug]/page.tsx.
• Authenticated dashboard, new-post, edit-post, and category management: app/(auth)/dashboard/page.tsx, app/(auth)/dashboard/new/page.tsx, app/(auth)/dashboard/edit/[id]/page.tsx.
• Login/signup flow is isolated under app/auth/login/page.tsx and app/auth/signup/page.tsx.
Route-group layouts provide public versus authenticated composition at app/(public)/layout.tsx and app/(auth)/layout.tsx.
Authentication and Authorization Boundary
Supabase Auth is the identity provider. Client/server Supabase adapters and auth utilities form the boundary between route/UI code and identity/session handling: lib/supabase/client.ts, lib/supabase/server.ts, lib/auth.ts.
components/auth/AuthGuard.tsx protects author-facing UI. Database-level access control is expected through Supabase Row Level Security policy definitions in supabase-rls-policies.sql, complementing application authorization for authoring and editing.
API and Backend Composition
Browser data operations use a typed tRPC client/provider layer in lib/trpc.tsx, routed by the Next route handler at app/api/trpc/[trpc]/route.ts. The server assembles router namespaces in server/api/root.ts and exposes tRPC context/transport setup from server/api/trpc.ts.
Core backend capabilities are separated into:
• Post lifecycle, reading/querying, drafts, and editing: server/api/routers/post.ts.
• Category management/filtering: server/api/routers/category.ts.
• Media upload operations backed by Supabase Storage: server/api/routers/upload.ts.
This keeps page/components dependent on typed procedures rather than directly on SQL or storage credentials.
Editorial Workflow and Reader Presentation
components/blog/PostForm.tsx is the central authoring surface, composed with components/blog/MarkdownEditor.tsx, components/blog/MarkdownRenderer.tsx, and components/blog/ImageUpload.tsx. It supports Markdown composition, live rendering, cover/inline media upload, and persisted post state.
Public discovery is built from components/blog/PostList.tsx, components/blog/PostCard.tsx, components/blog/SearchBar.tsx, and components/blog/CategoryFilter.tsx; selected posts resolve into the public slug route. This is the principal flow: reader query/filter → tRPC post/category fetch → rendered published content.
Persistence, Schema, and Media
Drizzle connects application server code to PostgreSQL via server/db/index.ts; the relational model is defined in server/db/schema.ts. Versioned schema evolution is captured in drizzle/0001_magenta_chat.sql, drizzle/0002_wakeful_malice.sql, and drizzle/0003_add_archived_field.sql.
Supabase serves two distinct infrastructure roles: Auth/RLS for user-scoped access and Storage for uploaded images. lib/supabase/keep-alive.ts and app/api/keep-alive/route.ts provide an operational endpoint intended to keep the database/service active.
Shared Presentation and Client State
The global visual system starts at app/globals.css; shared navigation/chrome lives in components/layout/Navbar.tsx and components/layout/Footer.tsx. Theme state is supplied through components/theme/ThemeProvider.tsx.
Client-side transient state is centralized in lib/store.ts, while React Query is used through the tRPC integration for asynchronous API cache/state. Reusable primitives under components/ui establish the shared accessible design-system boundary without embedding domain behavior.
Main entry points: layout.tsx Application shell · root.ts tRPC server composition · trpc.tsx tRPC client provider · page.tsx Author dashboard routes
Components 20
Next.js routes
- Application shell · Global layout, fallback, and visual foundation.
app/layout.tsx - Public reader routes · Landing, blog index, and slugged post pages.
app/(public)/page.tsx - Author dashboard routes · Dashboard, post creation, editing, and categories.
app/(auth)/dashboard/page.tsx - Login and signup
app/auth/login/page.tsx - Keep-alive endpoint · Keeps the database/service active.
app/api/keep-alive/route.ts
UI and client state
- Author access guard
components/auth/AuthGuard.tsx - Discovery UI · Lists, cards, search, and category filtering.
components/blog/PostList.tsx - Post authoring UI · Form combines Markdown editing, rendering, and image upload.
components/blog/PostForm.tsx - Shared chrome and theme
components/layout/Navbar.tsx - Client state and query cache
lib/store.ts
Typed API
- tRPC client provider
lib/trpc.tsx - tRPC route handler
app/api/trpc/[trpc]/route.ts - tRPC server composition · Root router namespaces and server transport context.
server/api/root.ts - Post procedures · Published reads, drafts, editing, and lifecycle operations.
server/api/routers/post.ts - Category procedures
server/api/routers/category.ts - Media upload procedures
server/api/routers/upload.ts
Data and infrastructure
- Supabase Auth and RLS · Session adapters and database row-level policies enforce user access.
lib/supabase/server.ts - Drizzle data access · Database connection and relational schema.
server/db/index.ts - PostgreSQL / Supabase · Stores users' scoped editorial data.
- Supabase Storage · Stores uploaded post images.
Connections 23
- Application shell → Public reader routes: hosts
- Application shell → Author dashboard routes: hosts
- Application shell → Login and signup: hosts
- Application shell → Shared chrome and theme: uses
- Author dashboard routes → Author access guard: protected by
- Author access guard → Supabase Auth and RLS: checks session
- Login and signup → Supabase Auth and RLS: authenticates with
- Public reader routes → Discovery UI: renders
- Author dashboard routes → Post authoring UI: renders
- Discovery UI → tRPC client provider: queries
- Post authoring UI → tRPC client provider: persists through
- tRPC client provider → Client state and query cache: caches in
- tRPC client provider → tRPC route handler: calls
- tRPC route handler → tRPC server composition: dispatches to
- tRPC server composition → Post procedures: mounts
- tRPC server composition → Category procedures: mounts
- tRPC server composition → Media upload procedures: mounts
- Post procedures → Drizzle data access: reads and writes
- Category procedures → Drizzle data access: reads and writes
- Drizzle data access → PostgreSQL / Supabase: connects to
- Supabase Auth and RLS → PostgreSQL / Supabase: enforces RLS on
- Media upload procedures → Supabase Storage: uploads media
- Keep-alive endpoint → PostgreSQL / Supabase: keeps active