# yeolyi/blog architecture

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

- Interactive diagram: https://gitdiagram.com/yeolyi/blog
- Repository: https://github.com/yeolyi/blog

## Overview

##### Project type and purpose
- This is a full-stack, content-rich web portal built on Next.js (App Router + MDX support) that serves localized blog posts, computer-science tutorials, memes, and user-generated comments. It integrates Supabase for authentication, data storage (Postgres + Storage), and RLS policies, plus uses serverless functions (Vercel/Next.js API routes) for image proxying, crawling, and other background actions.

##### Key components from file structure
- Presentation layer:
- app/ – Next.js “app” routes (localized pages under [locale], dynamic MDX-based routes, API routes under app/api).
- public/ – static assets and service workers (pixelateWorker.js).
- components/ – React UI (layout, mdx renderers, CS‐flow visualizations, meme UI, auth providers).
- Data layer:
- db/ – Supabase client wrappers and CRUD methods for comments, memes, memeTag, storage.
- swr/ & store/ – client-side data fetching and state management hooks (SWR providers, React Context).
- types/ – TypeScript types for database schemas and helpers.
- Business logic / serverless functions:
- actions/ – Puppeteer‐based crawlers and image processors (crawl.ts, image.ts, resend.ts).
- app/api/ – Next.js API routes for image proxying and sitemap generation.
- Configuration & tooling:
- next.config.mjs, tsconfig.json, tailwind.config.js, biome.json – build, lint, and styling configurations.
- .husky, lint-staged – pre-commit hooks.

##### Architectural patterns and relationships
- JAMstack / Serverless: Next.js front end (SSR/SSG/ISR) fetches data either directly via Supabase JS client (with server components or client SWR hooks) or through internal API routes.
- Separation of concerns:
- Presentation (React components in app/ + components/)
- Application/Service layer (Supabase wrappers in db/, SWR/store, custom actions/)
- Data persistence (Supabase Postgres + Storage buckets)
- External integrations: Supabase Auth, Supabase Storage, third-party crawling via Puppeteer, Vercel edge network.

##### Elements
- Client → Next.js SSR/CSR
- Next.js → Supabase (read/write)
- Next.js → API Routes → Supabase Storage
- Background “actions/” → Supabase
- Blue for presentation layer
- Green for service/API layer
- Orange for data layer
- Gray for external/third-party
- Rounded rectangles for React components/modules
- Clouds for external services

## Diagram (Mermaid)

```mermaid
graph TB

    subgraph "Client (Browser)"
        Browser["Web Browser"]:::client
        AuthProv["AuthProvider"]:::client
        SWRProv["SWRProvider"]:::client
        CommentUI["Comment UI Components"]:::client
        MemeUI["Meme UI Components"]:::client
        CSFlowUI["CS-flow Visualization"]:::client
    end

    subgraph "Server (Next.js Application)"
        AppRouter["Next.js App Router"]:::server
        MDXBlog["Localized MDX Routes"]:::server
        CSTut["CS Tutorials MDX Subsystem"]:::server
        MemePages["Meme Pages"]:::server
        ImageProxy["Image Proxy API Route"]:::server
        Sitemap["Sitemap API Route"]:::server
        Actions["Background Actions (actions/)"]:::server
    end

    subgraph "Data Layer (Supabase & DB Wrappers)"
        SupabaseDB["Supabase Postgres"]:::data
        SupabaseStorage["Supabase Storage"]:::data
        DBIndex["Supabase Client Wrapper"]:::data
        DBAuth["Auth Wrappers"]:::data
        CommentCRUD["Comment CRUD"]:::data
        MemeCRUD["Meme CRUD & Tagging"]:::data
        StorageWrapper["Storage Wrapper"]:::data
    end

    subgraph "Client Data & State"
        SWRAuth["swr/auth.ts"]:::data
        SWRComment["swr/comment.ts"]:::data
        SWRMeme["swr/meme.ts"]:::data
        StoreSession["store/session.ts"]:::data
        StoreCrawl["store/crawl.ts"]:::data
        StoreTemp["store/tempUser.ts"]:::data
        TypesDB["database.types.ts"]:::data
        TypesHelpers["helper.types.ts"]:::data
    end

    subgraph "External Services & Config"
        Puppeteer["Puppeteer Crawler"]:::external
        Vercel["Vercel Edge Network"]:::external
        StaticAssets["Static Assets & SW"]:::external
        MDXContent["MDX Content Directory"]:::external
        I18nUtils["i18n Utilities"]:::external
        Config["Build & Lint Configs"]:::external
    end

    %% Connections
    Browser --> AuthProv
    Browser --> SWRProv
    Browser --> AppRouter
    AuthProv --> SWRProv

    AppRouter --> MDXBlog
    MDXBlog --> MDXContent
    AppRouter --> CSTut
    AppRouter --> MemePages

    AppRouter --> ImageProxy
    AppRouter --> Sitemap

    ImageProxy --> SupabaseStorage
    Sitemap --> SupabaseDB

    AppRouter --> DBIndex
    AppRouter --> DBAuth
    DBIndex --> SupabaseDB
    DBAuth --> SupabaseDB

    CommentUI --> SWRComment
    SWRComment --> CommentCRUD
    CommentCRUD --> SupabaseDB

    MemeUI --> SWRMeme
    SWRMeme --> MemeCRUD
    MemeCRUD --> SupabaseDB

    CSFlowUI --> CSTut

    Actions --> Puppeteer
    Actions --> SupabaseDB
    Actions --> SupabaseStorage

    %% Click Events
    click AppRouter "https://github.com/yeolyi/blog/tree/main/app/"
    click MDXBlog "https://github.com/yeolyi/blog/tree/main/app/[locale]/(mdx)/post"
    click CSTut "https://github.com/yeolyi/blog/tree/main/app/[locale]/(mdx)/cs"
    click MemePages "https://github.com/yeolyi/blog/tree/main/app/[locale]/memes"
    click ImageProxy "https://github.com/yeolyi/blog/blob/main/app/api/image-proxy/route.ts"
    click Sitemap "https://github.com/yeolyi/blog/blob/main/app/sitemap.ts"
    click AuthProv "https://github.com/yeolyi/blog/blob/main/components/AuthProvider.tsx"
    click SWRProv "https://github.com/yeolyi/blog/blob/main/components/SWRProvider.tsx"
    click DBIndex "https://github.com/yeolyi/blog/blob/main/db/index.ts"
    click DBAuth "https://github.com/yeolyi/blog/blob/main/db/auth.ts"
    click CommentCRUD "https://github.com/yeolyi/blog/blob/main/db/comment/create.ts"
    click MemeCRUD "https://github.com/yeolyi/blog/blob/main/db/meme/create.ts"
    click StorageWrapper "https://github.com/yeolyi/blog/blob/main/db/storage.ts"
    click SWRAuth "https://github.com/yeolyi/blog/blob/main/swr/auth.ts"
    click SWRComment "https://github.com/yeolyi/blog/blob/main/swr/comment.ts"
    click SWRMeme "https://github.com/yeolyi/blog/blob/main/swr/meme.ts"
    click StoreSession "https://github.com/yeolyi/blog/blob/main/store/session.ts"
    click StoreCrawl "https://github.com/yeolyi/blog/blob/main/store/crawl.ts"
    click StoreTemp "https://github.com/yeolyi/blog/blob/main/store/tempUser.ts"
    click TypesDB "https://github.com/yeolyi/blog/blob/main/types/database.types.ts"
    click TypesHelpers "https://github.com/yeolyi/blog/blob/main/types/helper.types.ts"
    click Puppeteer "https://github.com/yeolyi/blog/blob/main/actions/crawl.ts"
    click StaticAssets "https://github.com/yeolyi/blog/tree/main/public/"
    click MDXContent "https://github.com/yeolyi/blog/tree/main/mdx/"
    click I18nUtils "https://github.com/yeolyi/blog/blob/main/i18n/navigation.ts"
    click Config "https://github.com/yeolyi/blog/blob/main/next.config.mjs"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef server fill:#d4edda,stroke:#333,stroke-width:1px
    classDef data fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
