How bytepute/website works
1. Project shape
- This is a Next.js App Router application built as a small content management site for articles, with a public reading surface and an admin editing surface.
- The repo is organized around route segments in app/, shared UI in components/, and database/domain logic in lib/ plus Prisma schema/migrations.
2. Route topology
- Public routes:
- app/page.tsx — landing page
- app/articles/page.tsx — article index
- app/articles/[slug]/page.tsx — article detail page
- Admin routes:
- app/admin/page.tsx — admin entry/dashboard
- app/admin/articles/new/page.tsx — create article
- app/admin/articles/[id]/edit/page.tsx — edit article
- This is a route-driven architecture rather than a separate frontend/backend split.
3. Content domain
- The central domain model is Article.
- The article lifecycle is: list → read → create → edit.
- The naming (slug for public detail pages, id for admin edit pages) suggests a clear boundary between public URL identity and internal database identity.
4. Data access layer
- lib/articles.ts is the main domain/data access module for article operations.
- lib/prisma.ts centralizes the Prisma client, so database access is funneled through a single ORM boundary.
- prisma/schema.prisma and the migration files define the persistence model and its evolution, making the database a first-class part of the architecture.
5. Admin mutation flow
- app/admin/actions.ts indicates the admin side uses server actions for mutations rather than a separate REST API.
- The likely flow is: admin form submits → server action runs on the server → Prisma writes to the database → updated article data is revalidated/rendered.
- This keeps write operations close to the route that owns them and avoids an extra API layer.
6. Public read flow
- Public article pages are read-only consumers of the article domain.
- components/articles-list.tsx, components/article-detail.tsx, and components/article-content.tsx separate the list/detail rendering concerns from the route files.
- The public side is therefore “route composes data + presentation components,” with data coming from the shared article layer.
7. Admin UI boundary
- components/admin-gate.tsx and proxy.ts are the main protection mechanisms around admin routes.
- lib/auth.ts likely contains auth/session checks, while the gate component controls rendering access inside the UI and the proxy enforces route-level protection.
- This creates a distinct boundary between anonymous public browsing and privileged content management.
8. Forms and editing UX
- components/article-form.tsx and components/edit-article-panel.tsx are the main edit/create interfaces.
- These components are reused by the new/edit admin pages, so the form logic is shared and the route files stay thin.
- The admin UI is therefore centered on a reusable form/editor component rather than page-specific form implementations.
9. Shared presentation system
- The app uses a component library based on shadcn/ui with primitives in components/ui/ (button, input, label, textarea).
- components/site-header.tsx, components/loading-fallbacks.tsx, and components/theme-provider.tsx support cross-cutting app presentation concerns.
- app/layout.tsx and app/globals.css provide the global shell and styling foundation for both public and admin areas.
10. Runtime and persistence boundaries
- The application runs as a single Next.js server/client app; there is no separate backend service or standalone API project in the tree.
- Persistence is handled through Prisma + a relational database, with migrations in prisma/migrations/.
- That means the major boundaries are:
- browser UI
- Next.js route/server-action layer
- auth/protection layer
- Prisma-backed data layer
- database
11. What to show in an architecture diagram
- A good diagram should show:
- Public routes feeding shared article display components
- Admin routes feeding form/editor components
- Admin requests passing through auth/protection before mutations
- Server actions and lib/articles/lib/prisma as the bridge to the database
- Prisma schema/migrations as the persistence contract
- The key architectural idea is a single Next.js application with strong separation between public read paths and protected admin write paths.
Main entry points: layout.tsx App shell · articles.ts Articles domain · article-form.tsx Article form · proxy.ts Route proxy
Components 28
Public surface
Anonymous reading routes and article display
- Article index · Lists published articles
app/articles/page.tsx - Article detail · Renders a single article by slug
app/articles/[slug]/page.tsx - Landing page · Front page entry point
app/page.tsx - Articles list · Shared article index presentation
components/articles-list.tsx - Article detail view · Article page presentation wrapper
components/article-detail.tsx - Article content · Article body rendering component
components/article-content.tsx
Admin surface
Protected editing routes and write flows
- Admin dashboard · Admin entry and overview
app/admin/page.tsx - New article · Create article page
app/admin/articles/new/page.tsx - Edit article · Edit article page
app/admin/articles/[id]/edit/page.tsx - Admin actions · Server-side mutation entry points
app/admin/actions.ts - Article form · Shared create/edit form
components/article-form.tsx - Edit panel · Admin editing UI wrapper
components/edit-article-panel.tsx
Shared UI
Cross-cutting layout and reusable presentation components
- App shell · Global app layout and providers
app/layout.tsx - Global styles · Application-wide styling foundation
app/globals.css - Site header · Shared top-level navigation and branding
components/site-header.tsx - Theme provider · App-wide theme and client UI context
components/theme-provider.tsx - Loading states · Shared loading and fallback UI
components/loading-fallbacks.tsx - Button · Shared button primitive
components/ui/button.tsx - Input · Shared input primitive
components/ui/input.tsx - Label · Shared label primitive
components/ui/label.tsx - Textarea · Shared textarea primitive
components/ui/textarea.tsx
Domain data
Article logic, auth, and ORM boundary
- Articles domain · Article queries and mutations
lib/articles.ts - Prisma client · Centralized database client
lib/prisma.ts
Persistence
Schema and migration contract
- Schema · Prisma data model definition
prisma/schema.prisma - Migrations · Database evolution history
prisma/migrations/migration_lock.toml
Access control
Route and UI protection for admin access
- Admin gate · UI-level access gate for admin pages
components/admin-gate.tsx - Route proxy · Route-level admin protection
proxy.ts - Auth · Authentication and authorization checks
lib/auth.ts
Connections 38
- Landing page → Site header: composes · Uses shared site chrome
- Landing page → Articles domain: reads · Fetches article data for landing content
- Article index → Articles list: renders · Delegates index presentation
- Article index → Articles domain: reads · Loads published articles
- Article detail → Article detail view: renders · Delegates single-article presentation
- Article detail → Articles domain: reads · Loads article by slug
- Article detail view → Article content: includes · Uses body rendering component
- Article detail → Site header: composes · Shares global navigation
- Admin dashboard → Admin gate: guards · Blocks unauthorized access in UI
- Admin dashboard → Articles domain: reads · Shows managed content state
- New article → Admin gate: guards · Requires admin access
- New article → Edit panel: renders · Uses shared editor wrapper
- Edit article → Admin gate: guards · Requires admin access
- Edit article → Edit panel: renders · Uses shared editor wrapper
- Edit panel → Article form: contains · Wraps the reusable form
- Article form → Input: uses · Text input primitive
- Article form → Textarea: uses · Body editing primitive
- Article form → Label: uses · Field labeling primitive
- Article form → Button: uses · Submit action primitive
- Admin actions → Articles domain: mutates · Routes writes through domain layer
- Articles domain → Prisma client: queries · Uses centralized ORM client
- Prisma client → Schema: maps to · Backed by Prisma schema
- Schema → Migrations: evolves via · Schema changes are captured in migrations
- Route proxy → Auth: enforces · Checks route access before admin entry
- Admin gate → Auth: checks · Uses auth state for UI gating
- App shell → Theme provider: wraps · Provides client theme context
- App shell → Site header: includes · Shared shell chrome
- App shell → Loading states: uses · Provides app-level fallback UI
- App shell → Global styles: loads · Imports global stylesheet
- App shell → Landing page: hosts · Root route within global shell
- App shell → Article index: hosts · Public route within global shell
- App shell → Article detail: hosts · Public route within global shell
- App shell → Admin dashboard: hosts · Admin route within global shell
- App shell → New article: hosts · Admin route within global shell
- App shell → Edit article: hosts · Admin route within global shell
- Route proxy → Admin dashboard: protects · Blocks unprivileged route entry
- Route proxy → New article: protects · Blocks unprivileged route entry
- Route proxy → Edit article: protects · Blocks unprivileged route entry