# stphnhthwy/feed architecture

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

- Interactive diagram: https://gitdiagram.com/stphnhthwy/feed
- Repository: https://github.com/stphnhthwy/feed

## Overview

##### Project type and purpose
- This is a full-stack Next.js application, bootstrapped with create-next-app, using Prisma to interact with a SQLite database.
- The app exposes a simple “posts” API (src/app/api/posts/route.ts), renders a feed page (src/app/feed/page.tsx), and serves static uploads (public/uploads).

##### File structure
- Top-level:
- src/app – Next.js “app” directory containing server and client code (pages, API routes, layouts, CSS).
- src/lib/db.ts – Prisma client instantiation.
- prisma – schema.prisma, migrations, and dev.db (SQLite).
- public/uploads – static assets (sample videos, user uploads).
- scripts/seed.ts – seed script to populate the database.
- config files: next.config.ts, eslint.config.mjs, postcss.config.mjs, tsconfig.json.
- Pattern: React + SSR/SSG pages in app/, serverless API routes under app/api, ORM layer in lib/db.ts, file-based routing.

##### README for additional insights
- Confirms a standard Next.js stack.

##### Details to capture
- SSR vs. client-side fetch distinction
- File-based routing paths (app/feed/page.tsx → /feed, app/api/posts/route.ts → /api/posts)
- Prisma’s role in schema management and migrations
- Static asset handling (public/uploads directory)
- Build/deploy pipeline (Next.js build → Vercel hosting)

- Prisma Client connected to “SQLite Dev Database (prisma/dev.db)”
- Annotation of external font optimization and Vercel deployment

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Client["Client Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend (Next.js App)" 
        style Frontend fill:#cce5ff,stroke:#004085
        HomePage["Home Page\n(src/app/page.tsx)"]:::frontend
        FeedPage["Feed Page\n(src/app/feed/page.tsx)"]:::frontend
        Layout["Layout\n(src/app/layout.tsx)"]:::frontend
        GlobalCSS["Global Stylesheet\n(src/app/globals.css)"]:::frontend
    end

    %% API Layer
    subgraph "API (Serverless Functions)"
        style API fill:#d4edda,stroke:#155724
        PostsAPI["API Route: /api/posts\n(src/app/api/posts/route.ts)"]:::api
    end

    %% ORM Layer
    subgraph "ORM Layer (Prisma)"
        style ORM fill:#fff3cd,stroke:#856404
        PrismaClient["Prisma Client\n(src/lib/db.ts)"]:::db
        Schema["Schema Definition\n(prisma/schema.prisma)"]:::db
        Migrations["Migrations\n(prisma/migrations)"]:::db
    end

    %% Database Layer
    subgraph "Database"
        style Database fill:#ffe5b4,stroke:#c77600
        SQLiteDB["SQLite Dev DB\n(prisma/dev.db)"]:::db
    end

    %% Storage Layer
    subgraph "Static Storage"
        style Storage fill:#f8d7da,stroke:#721c24
        Uploads["Uploads Folder\n(public/uploads)"]:::storage
    end

    %% Scripts & External
    subgraph "Ancillary"
        style Ancillary fill:#e2e3e5,stroke:#6c757d,stroke-dasharray: 5 5
        Seed["Seed Script\n(scripts/seed.ts)"]:::script
        Config["Next.js Config\n(next.config.ts)"]:::script
    end

    ExternalFont["next/font Service"]:::external
    Vercel["Vercel Deployment"]:::external

    %% Connections
    Client -->|"GET pages"| HomePage
    Client -->|"GET /feed"| FeedPage
    HomePage -->|"uses Layout & CSS"| Layout
    FeedPage -->|"uses Layout & CSS"| Layout
    FeedPage -->|"fetch posts"| PostsAPI
    PostsAPI -->|"queries"| PrismaClient
    PrismaClient -->|"reads/writes"| SQLiteDB
    PrismaClient -->|"schema/migrations"| Schema
    PrismaClient -->|"schema/migrations"| Migrations
    PostsAPI -->|"serves/uploads"| Uploads
    Seed -->|"populates"| SQLiteDB
    Seed -->|"via Prisma Client"| PrismaClient
    Config -->|"build config"| HomePage
    Config -->|"build config"| FeedPage
    Config -->|"build config"| PostsAPI
    HomePage -->|"build uses"| ExternalFont
    FeedPage -->|"build uses"| ExternalFont
    HomePage -->|"deployed on"| Vercel
    FeedPage -->|"deployed on"| Vercel
    PostsAPI -->|"deployed on"| Vercel

    %% Click Events
    click HomePage "https://github.com/stphnhthwy/feed/blob/main/src/app/page.tsx"
    click FeedPage "https://github.com/stphnhthwy/feed/blob/main/src/app/feed/page.tsx"
    click PostsAPI "https://github.com/stphnhthwy/feed/blob/main/src/app/api/posts/route.ts"
    click PrismaClient "https://github.com/stphnhthwy/feed/blob/main/src/lib/db.ts"
    click SQLiteDB "https://github.com/stphnhthwy/feed/blob/main/prisma/dev.db"
    click Schema "https://github.com/stphnhthwy/feed/blob/main/prisma/schema.prisma"
    click Migrations "https://github.com/stphnhthwy/feed/tree/main/prisma/migrations"
    click Uploads "https://github.com/stphnhthwy/feed/tree/main/public/uploads"
    click Seed "https://github.com/stphnhthwy/feed/blob/main/scripts/seed.ts"
    click GlobalCSS "https://github.com/stphnhthwy/feed/blob/main/src/app/globals.css"
    click Layout "https://github.com/stphnhthwy/feed/blob/main/src/app/layout.tsx"
    click Config "https://github.com/stphnhthwy/feed/blob/main/next.config.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef api fill:#d4edda,stroke:#155724,color:#155724
    classDef db fill:#fff3cd,stroke:#856404,color:#856404
    classDef storage fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef script fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-dasharray: 5 5
    classDef external fill:#f1f1f1,stroke:#888888,color:#888888,stroke-dasharray: 2 2
```
