# churnobyl/churnobyl-blog architecture

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

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

## Overview

##### Project type and purpose
- This is a Gatsby-based, TypeScript-powered static site (SSG) that sources content from local MDX files and Supabase. It generates blogs, book summaries, category/tag pages, etc., into a React frontend, and is deployed to Netlify.

##### File structure
- Top-level configs: gatsby-config.ts, gatsby-node.ts, netlify.toml, package.json, tsconfig.json, tailwind/PostCSS config
- src/gatsby & src/createPages.ts: build-time logic that reads MDX and Supabase data, creates nodes and pages
- src/mdx: custom MDX handlers, components, and parser—local content source
- src/api: runtime/client wrappers around Supabase for dynamic interactions (comments, likes)
- src/components & src/templates & src/pages: React UI (atomic components, layouts, pages, templates)
- src/hooks, src/theme, src/styles: cross-cutting concerns (hooks, theming, CSS)
- supabase/config.toml: local Supabase project config

##### README insights
- Intended for Netlify one-click deployment

a. Main components
- Content Sources (Local MDX folder + Supabase Database)
- Build Pipeline (Gatsby Core + Node APIs + MDX Generator + GraphQL layer + src/gatsby scripts)
- Static Site Output (pre-rendered HTML/CSS/JS)
- Client-side App (React components in browser + runtime API calls)
- External Service (Supabase)
- Hosting & CDN (Netlify)

b. Relationships & interactions
- Build time:
- Gatsby Core reads MDX files via mdxGenerator.ts → creates Gatsby nodes
- src/gatsby/*.ts functions read nodes & Supabase via getSupabase.ts → build GraphQL schema → create pages with templates
- Output: static assets (HTML, CSS, JS) written to “public” for Netlify
- Runtime (client in browser):
- React components rendered on page load
- src/api/interact.ts & getSupabase.ts make API calls to Supabase for comments, likes, real-time data
- Deployment & delivery:
- Netlify picks up “public” folder, deploys to CDN
- Users request pages; CDN serves static files

c. Architectural patterns & design principles
- Static-Site Generation with Gatsby (SSG)
- Component-driven UI (atomic React components + templates)
- Headless CMS approach: local MDX + Supabase as data sources
- Separation of concerns: build-time vs runtime code in distinct folders (src/gatsby vs src/api)
- Type safety with TypeScript interfaces/types

d. Key technologies/frameworks
- Gatsby (SSG + GraphQL)
- React + TypeScript
- MDX processing (custom mdxGenerator, MDX components)
- Supabase (Postgres + auth)
- Tailwind/PostCSS for styling
- Netlify for hosting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Content Sources
    subgraph "Content Sources"
        direction TB
        MDX["Local MDX\n(src/mdx/)"]:::external
        SupabaseDB["Supabase Database"]:::external
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        direction TB
        GatsbyConfig["gatsby-config.ts"]:::build
        GatsbyNode["gatsby-node.ts"]:::build
        CreatePages["createPages Logic\n(src/createPages.ts)"]:::build
        subgraph "Page Creation Logic"
            direction TB
            CreatePosts["createPosts.ts"]:::build
            CreateBookPage["createBookPage.ts"]:::build
            CreatePostList["createPostList.ts"]:::build
            CreateByCategory["createPostListByCategory.ts"]:::build
            CreateByTag["createPostListByTag.ts"]:::build
        end
    end

    %% Static Site Output
    subgraph "Static Site Output"
        direction TB
        Public["public/\n(static files)"]:::output
    end

    %% Client-side App
    subgraph "Client App"
        direction TB
        ReactUI["React Components\n(src/components/)"]:::runtime
        Templates["Page Templates\n(src/templates/)"]:::runtime
        Pages["Top-level Pages\n(src/pages/)"]:::runtime
        Hooks["Hooks\n(src/hooks/)"]:::runtime
        ThemeStyles["Theme & Styles"]:::runtime
        GatsbyBrowser["Gatsby Browser APIs\n(gatsby-browser.js)"]:::runtime
    end

    %% External Services
    subgraph "External Service"
        direction TB
        SupConfig["supabase/config.toml"]:::external
        GetSupabase["getSupabase.ts"]:::external
        Interact["interact.ts"]:::external
        SupTypes["supabase types\n(src/types/supabase.ts)"]:::external
    end

    %% Hosting & CDN
    subgraph "Hosting & CDN"
        direction TB
        Netlify["Netlify CDN"]:::hosting
    end

    %% User
    User["User (Browser)"]:::external

    %% Connections - Build time
    MDX -->|reads MDX| GatsbyConfig
    SupabaseDB -->|fetches schema| GatsbyConfig
    GatsbyConfig --> GatsbyNode
    GatsbyNode --> CreatePages
    CreatePages --> CreatePosts
    CreatePages --> CreateBookPage
    CreatePages --> CreatePostList
    CreatePages --> CreateByCategory
    CreatePages --> CreateByTag
    CreatePosts --> Public
    CreateBookPage --> Public
    CreatePostList --> Public
    CreateByCategory --> Public
    CreateByTag --> Public

    %% Connections - Deployment
    Public --> Netlify
    Netlify --> User

    %% Connections - Runtime
    User -->|loads static assets| ReactUI
    ReactUI -->|renders templates| Templates
    Templates --> Pages
    ReactUI -->|calls| GetSupabase
    ReactUI -->|calls| Interact
    GetSupabase --> SupabaseDB
    Interact --> SupabaseDB

    %% Styles & hooks usage
    ReactUI --> Hooks
    ReactUI --> ThemeStyles
    ThemeStyles --> GatsbyBrowser

    %% Click Events
    click MDX "https://github.com/churnobyl/churnobyl-blog/tree/main/src/mdx/"
    click SupConfig "https://github.com/churnobyl/churnobyl-blog/blob/main/supabase/config.toml"
    click GetSupabase "https://github.com/churnobyl/churnobyl-blog/blob/main/src/api/getSupabase.ts"
    click Interact "https://github.com/churnobyl/churnobyl-blog/blob/main/src/api/interact.ts"
    click SupTypes "https://github.com/churnobyl/churnobyl-blog/blob/main/src/types/supabase.ts"
    click GatsbyConfig "https://github.com/churnobyl/churnobyl-blog/blob/main/gatsby-config.ts"
    click GatsbyNode "https://github.com/churnobyl/churnobyl-blog/blob/main/gatsby-node.ts"
    click CreatePages "https://github.com/churnobyl/churnobyl-blog/blob/main/src/createPages.ts"
    click CreatePosts "https://github.com/churnobyl/churnobyl-blog/blob/main/src/gatsby/createPosts.ts"
    click CreateBookPage "https://github.com/churnobyl/churnobyl-blog/blob/main/src/gatsby/createBookPage.ts"
    click CreatePostList "https://github.com/churnobyl/churnobyl-blog/blob/main/src/gatsby/createPostList.ts"
    click CreateByCategory "https://github.com/churnobyl/churnobyl-blog/blob/main/src/gatsby/createPostListByCategory.ts"
    click CreateByTag "https://github.com/churnobyl/churnobyl-blog/blob/main/src/gatsby/createPostListByTag.ts"
    click Public "https://github.com/churnobyl/churnobyl-blog/tree/main/public/"
    click ReactUI "https://github.com/churnobyl/churnobyl-blog/tree/main/src/components/"
    click Templates "https://github.com/churnobyl/churnobyl-blog/tree/main/src/templates/"
    click Pages "https://github.com/churnobyl/churnobyl-blog/tree/main/src/pages/"
    click Hooks "https://github.com/churnobyl/churnobyl-blog/tree/main/src/hooks/"
    click ThemeStyles "https://github.com/churnobyl/churnobyl-blog/blob/main/src/theme/theme.ts"
    click ThemeStyles "https://github.com/churnobyl/churnobyl-blog/blob/main/src/styles/global.css"
    click ThemeStyles "https://github.com/churnobyl/churnobyl-blog/blob/main/tailwind.config.js"
    click ThemeStyles "https://github.com/churnobyl/churnobyl-blog/blob/main/postcss.config.js"
    click GatsbyBrowser "https://github.com/churnobyl/churnobyl-blog/blob/main/gatsby-browser.js"
    click Netlify "https://github.com/churnobyl/churnobyl-blog/blob/main/netlify.toml"

    %% Styles
    classDef build fill:#cce5ff,stroke:#004085;
    classDef runtime fill:#d4edda,stroke:#155724;
    classDef external fill:#fff3cd,stroke:#856404;
    classDef output fill:#e2e3e5,stroke:#6c757d;
    classDef hosting fill:#d1ecf1,stroke:#0c5460;
```
