# kelvince01/quillert architecture

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

- Interactive diagram: https://gitdiagram.com/kelvince01/quillert
- Repository: https://github.com/kelvince01/quillert

## Overview

##### Project Type and Purpose
- This is a full-stack, content-driven web application built with Next.js (App Router) and TypeScript.
- It serves as a blog/CMS with public pages (posts, categories, tags), account management (login, registration), an admin dashboard (CRUD on posts, categories, tags, comments), file uploads, and dynamic OG image generation.
- Data is stored in a Supabase (PostgreSQL) backend; file uploads use UploadThing; user auth integrates with Supabase and GitHub OAuth.

##### Core Directory Analysis
- src/app: Next.js routing hierarchy
- /(main): public-facing pages and posts
- /accounts: login & register flows
- /admin: protected dashboard for content management
- /api: serverless endpoints (increment-view, og image, uploadthing)
- components: UI building blocks organized by feature (admin, posts, comments, UI primitives)
- lib, utils, hooks: shared logic (auth helpers, Supabase client, utilities)
- supabase/: local Supabase config and seed scripts
- worker/: background task runner (e.g., scheduled jobs)
- config, constants, styles: site configuration, CSS (Tailwind + PostCSS)
- next.config.js, tailwind.config.ts, tsconfig.json: build tooling and lint/prettier configs

##### Main System Components
A. Client (Browser)
- React pages (App Router)
- Static assets from /public
B. Next.js Server
- SSR/SSG rendering on Vercel (or Node)
- API Routes:
- /api/increment-view → updates post view count
- /api/og → dynamic OG image generation
- /api/uploadthing → file upload handling
- Middleware for auth, routing, redirects
C. Supabase Backend
- PostgreSQL database (tables: posts, categories, tags, comments, users)
- Auth service (JWT sessions, OAuth with GitHub)
- Storage (optional for file assets)
- Edge functions or triggers (optional)
D. External Services
- GitHub OAuth provider
- UploadThing (hosted file storage or S3)
- Vercel CDN / Edge network
E. Worker Process
- worker/index.ts → background tasks (e.g., batch processing, scheduled jobs)

##### Relationships and Data Flows
- Client → Next.js Server: page requests, form submissions, API calls
- Next.js Server → Supabase:
- Queries for public pages (posts, authors, categories)
- Mutations for admin actions (create/update/delete)
- Auth flows (session management)
- Next.js Server → External OAuth: user login redirects and callbacks
- Next.js API Routes → UploadThing service for file storage
- Supabase Triggers → Worker or edge functions (if configured)

##### Architectural Patterns and Principles
- Feature-folder structure: groups code by domain (accounts, admin, posts)
- Component-driven UI: reusable primitives in components/ui
- Serverless functions for micro-endpoints (increment-view, og, uploadthing)
- Separation of concerns: UI vs data layer (lib/supabase, utils)
- SSR/SSG where appropriate (Public pages), CSR for admin modals/forms

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend" 
        Browser["Browser (React Pages)"]:::frontend
        StaticAssets["Static Assets (/public)"]:::frontend
    end

    subgraph "Server (Next.js)" 
        AppRouter["Next.js App Router"]:::backend
        Middleware["Middleware (Auth & Routing)"]:::backend
        subgraph "API Routes"
            IncView["/api/increment-view"]:::api
            OG["/api/og"]:::api
            UploadAPI["/api/uploadthing"]:::api
            AuthCB["/auth/callback"]:::api
        end
    end

    subgraph "Database (Supabase)"
        Postgres["PostgreSQL Database"]:::db
        AuthService["Auth Service (OAuth, JWT)"]:::db
        Storage["Storage (Optional)"]:::db
    end

    subgraph "External Services"
        GitHub["GitHub OAuth Provider"]:::external
        UploadThing["UploadThing API"]:::external
        Vercel["Vercel CDN / Edge"]:::external
    end

    Worker["Worker Process (Background Tasks)"]:::worker

    Browser -->|page/API requests| AppRouter
    Browser -->|fetch static assets| StaticAssets
    AppRouter -->|queries/mutations| Postgres
    AppRouter -->|auth flows| AuthService
    AppRouter -->|file uploads| UploadThing
    AppRouter -->|OAuth redirects| GitHub
    AppRouter -->|storage access| Storage
    AppRouter -->|uses middleware| Middleware
    AppRouter --> IncView
    AppRouter --> OG
    AppRouter --> UploadAPI
    AppRouter --> AuthCB
    Postgres -->|triggers/jobs| Worker

    click Browser "https://github.com/kelvince01/quillert/blob/master/src/app/(main)/page.tsx"
    click StaticAssets "https://github.com/kelvince01/quillert/tree/master/public/"
    click AppRouter "https://github.com/kelvince01/quillert/tree/master/src/app"
    click Middleware "https://github.com/kelvince01/quillert/blob/master/src/middleware.ts"
    click IncView "https://github.com/kelvince01/quillert/blob/master/src/app/api/increment-view/route.ts"
    click OG "https://github.com/kelvince01/quillert/blob/master/src/app/api/og/route.ts"
    click UploadAPI "https://github.com/kelvince01/quillert/blob/master/src/app/api/uploadthing/route.ts"
    click AuthCB "https://github.com/kelvince01/quillert/blob/master/src/app/auth/callback/route.ts"
    click Postgres "https://github.com/kelvince01/quillert/blob/master/supabase/config.toml"
    click AuthService "https://github.com/kelvince01/quillert/blob/master/supabase/config.toml"
    click Storage "https://github.com/kelvince01/quillert/blob/master/supabase/config.toml"
    click GitHub "https://github.com/kelvince01/quillert/blob/master/src/components/accounts/github-auth-button.tsx"
    click UploadThing "https://github.com/kelvince01/quillert/blob/master/src/app/api/uploadthing/core.ts"
    click Worker "https://github.com/kelvince01/quillert/blob/master/worker/index.ts"

    classDef frontend fill:#E0F7FA,stroke:#006064,color:#000;
    classDef backend fill:#E8F5E9,stroke:#1B5E20,color:#000;
    classDef db fill:#FFF3E0,stroke:#E65100,color:#000;
    classDef external fill:#F3E5F5,stroke:#6A1B9A,color:#000;
    classDef worker fill:#ECEFF1,stroke:#546E7A,color:#000;
    classDef api fill:#C8E6C9,stroke:#2E7D32,color:#000;
```
