# jongsujin/fantajin-blog architecture

> Architecture diagram of the GitHub repository jongsujin/fantajin-blog, 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/jongsujin/fantajin-blog
- Repository: https://github.com/jongsujin/fantajin-blog

## Overview

##### Project type and purpose
- This is a Next.js-based statically-generated (with optional SSR/ISR) blog that uses MDX for content pages.
- It’s a full-stack JAMstack application built with TypeScript, Tailwind CSS, and deployed on Vercel.

##### File structure
- **app/** – Next.js App Router layout, page and route definitions (server and client components).
- **public/** – Static assets (images, logo, profile pics).
- **src/** – Modular source code following a layered domain approach:
- **_app/providers/** – React context and global providers
- **entities/** – Domain models (post, category), API calls, and content (MDX files)
- **screens/** – Page-level UI components that tie entities → widgets → providers
- **shared/ui/** – Generic UI primitives (Card, Pagination, MDXImage)
- **widget/** – Reusable feature widgets (header, comments, post-card, tag)
- Config files: **next.config.ts**, **postcss.config.mjs**, ESLint, Prettier, TypeScript.

##### Insights from README
- JAMstack design: build-time MDX processing into static HTML pages (SSG); optional dynamic SSR.
- Tech stack reaffirms: Next.js, MDX, Tailwind CSS, TypeScript, Vercel.

##### Main components
a. Frontend:
– Next.js App Router (Server-side & Client-side components)
– React Context Providers (ThemeContext, other global state)
– UI Layer: Screens → Widgets → Shared UI primitives
b. Content pipeline:
– MDX files under `entities/post/content/posts`
– MDX loader → Static generation at build time or on-demand ISR
c. Data & API:
– `src/entities/post/api/post.ts` (fetching from local MDX or external endpoints)
– Category model under `entities/category`
d. Static assets:
– `public` folder served by Vercel CDN
e. Deployment & Hosting:
– Vercel build & deployment pipeline
– Git repo triggers Vercel CI/CD

##### Relationships & interactions
- Browser → Vercel Edge Network → Next.js Serverless Functions (for SSR/ISR)
- Next.js build process parses MDX → generates static pages → uploaded to CDN
- At runtime, pages use React Providers → render Screens → mount Widgets → compose Shared UI
- API module can fetch external data or local MDX frontmatter dynamically
- Static assets (images, CSS) served directly by CDN

##### Architectural patterns & technologies
- Layered domain architecture (entities → widgets → screens → app router)
- Component composition (widgets + shared primitives)
- JAMstack (SSG/ISR) for performance & SEO
- Context providers for global theming/state
- File-based routing with Next.js App Router
- MDX integration for content as React components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Request Flow
    Browser["Browser"]:::infra --> Edge["Vercel Edge Network"]:::infra
    Edge --> SSR["Next.js Serverless Functions\n(SSR/ISR)"]:::infra
    Edge --> StaticHTML["Static HTML\nfrom CDN"]:::infra

    %% Content Pipeline
    subgraph "Content Pipeline"
      direction TB
      MDXFiles(("MDX Content\nentities/post/content/posts")):::content
      MDXProcessor["MDX Processor\n(build-time)"]:::content
      MDXFiles --> MDXProcessor
      MDXProcessor --> StaticHTML
    end

    %% Infrastructure
    subgraph "Infrastructure"
      direction TB
      Git["Git Repo"]:::infra
      Git --> Edge
      CDN["Vercel CDN\n(public assets)"]:::infra
      StaticAssets["Static Assets\npublic/"]:::infra
      StaticAssets --> CDN
    end

    %% Domain Logic
    subgraph "Domain Logic"
      direction TB
      API["Post API\nsrc/entities/post/api/post.ts"]:::domain
      Category["Category Model\nsrc/entities/category/model/category.ts"]:::domain
      MDXFiles --> API
      Category --> API
    end

    %% UI Presentation
    subgraph "UI Presentation"
      direction TB
      AppRouter["Next.js App Router\n(app/)"]:::ui
      Providers["React Context Providers\nsrc/_app/providers"]:::ui
      Screens["Screens\nsrc/screens"]:::ui
      Widgets["Widgets\nsrc/widget"]:::ui
      Primitives["Shared UI Primitives\nsrc/shared/ui"]:::ui

      AppRouter --> Providers
      Providers --> Screens
      Screens --> Widgets
      Widgets --> Primitives
      AppRouter --> StaticHTML
      AppRouter --> SSR
    end

    %% Click Events
    click AppRouter "https://github.com/jongsujin/fantajin-blog/tree/main/app/"
    click Providers "https://github.com/jongsujin/fantajin-blog/tree/main/src/_app/providers/"
    click Screens "https://github.com/jongsujin/fantajin-blog/tree/main/src/screens/"
    click Widgets "https://github.com/jongsujin/fantajin-blog/tree/main/src/widget/"
    click Primitives "https://github.com/jongsujin/fantajin-blog/tree/main/src/shared/ui/"
    click API "https://github.com/jongsujin/fantajin-blog/blob/main/src/entities/post/api/post.ts"
    click Category "https://github.com/jongsujin/fantajin-blog/blob/main/src/entities/category/model/category.ts"
    click MDXFiles "https://github.com/jongsujin/fantajin-blog/tree/main/src/entities/post/content/posts/"
    click StaticAssets "https://github.com/jongsujin/fantajin-blog/tree/main/public/"

    %% Styling
    classDef ui fill:#bbdefb,stroke:#0d47a1,color:#0d47a1
    classDef domain fill:#c8e6c9,stroke:#1b5e20,color:#1b5e20
    classDef content fill:#ffe0b2,stroke:#e65100,color:#e65100
    classDef infra fill:#eceff1,stroke:#37474f,color:#37474f
```
