# daryllukas/notion-blog architecture

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

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

## Overview

##### Main Components

a. Client-Side Layer:
- Sub-components:
- Pages (About, Blog, Contact, Projects)
- Components (Header, Posts, Filters)
- Client-side State Management (categories, page, query)

b. Server-Side Layer:
- Sub-components:
- API Routes (/api/posts, /api/posts/cache)
- Middleware
- Revalidation Handler

c. External Services:
- Connection to Notion's API

d. Data Flow Layer:
- Cache Management
- Post Synchronization
- Search & Filter Pipeline

##### Relationships and Interactions

- Client → API Routes → Notion CMS
- Notion CMS → Cache → Client
- Search/Filter requests → Client-side State → UI Updates

##### Specific Implementation Details

- Authentication flow with Notion
- Post retrieval and caching mechanism
- Search and category filtering pipeline
- Server-side rendering paths
- Client-side state management

##### Key Technical Elements to Highlight

- Next.js 13 App Router architecture
- Integration with react-notion-x renderer
- Notion unofficial API client
- Cache management system
- Responsive design implementation

**[Client Layer]**
- ↕
**[Next.js App Router Layer]**
- ↕
**[API Routes Layer]**
- ↕
**[External Services Layer]**

Important Implementation Notes:

##### Responsive design breakpoints

Remember to:
- Keep components grouped logically
- Use clear, consistent naming
- Notes for important configuration details (environment variables)
- Error handling paths
- Data persistence flows

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Pages --> |Navigation| Components
        Pages --> |State Updates| ClientState
        Components --> |UI Updates| ClientState

        subgraph Pages
            About["About Page"]:::page
            Blog["Blog Page"]:::page
            Contact["Contact Page"]:::page
            Projects["Projects Page"]:::page
        end

        subgraph Components
            Header["Header Component"]:::component
            PostsGrid["Posts Grid"]:::component
            Filters["Filter Components"]:::component
            ThemeToggle["Theme Toggle"]:::component
        end

        subgraph ClientState
            Categories["Categories State"]:::state
            PageState["Page State"]:::state
            QueryState["Query State"]:::state
        end
    end

    subgraph ServerSide
        APIRoutes --> |Data Fetch| Cache
        Cache --> |Cached Data| APIRoutes
        Middleware --> |Request Processing| APIRoutes

        subgraph APIRoutes
            PostsAPI["Posts API"]:::api
            CacheAPI["Cache API"]:::api
            RevalidateAPI["Revalidation Handler"]:::api
        end
    end

    subgraph Services
        NotionIntegration["Notion Integration"]:::service
        PostsService["Posts Service"]:::service
        SearchUtil["Search Utility"]:::service
    end

    subgraph ExternalServices
        NotionCMS["Notion CMS"]:::external
    end

    Components --> |API Requests| APIRoutes
    APIRoutes --> |Data Fetch| Services
    Services --> |Content Fetch| NotionCMS
    NotionCMS --> |Content| Services
    Services --> |Processed Data| APIRoutes
    APIRoutes --> |Response| Components

    %% Click Events
    click About "https://github.com/daryllukas/notion-blog/blob/main/src/app/about/page.tsx"
    click Blog "https://github.com/daryllukas/notion-blog/blob/main/src/app/blog/page.tsx"
    click Contact "https://github.com/daryllukas/notion-blog/blob/main/src/app/contact/page.tsx"
    click Projects "https://github.com/daryllukas/notion-blog/blob/main/src/app/projects/page.tsx"
    click Header "https://github.com/daryllukas/notion-blog/blob/main/src/components/header/header.tsx"
    click PostsGrid "https://github.com/daryllukas/notion-blog/blob/main/src/components/posts/posts-grid.tsx"
    click Filters "https://github.com/daryllukas/notion-blog/tree/main/src/components/filter"
    click ThemeToggle "https://github.com/daryllukas/notion-blog/blob/main/src/components/theme-toggle.tsx"
    click PostsAPI "https://github.com/daryllukas/notion-blog/blob/main/src/app/api/posts/route.ts"
    click CacheAPI "https://github.com/daryllukas/notion-blog/blob/main/src/app/api/posts/cache/route.ts"
    click Middleware "https://github.com/daryllukas/notion-blog/blob/main/src/middleware.ts"
    click RevalidateAPI "https://github.com/daryllukas/notion-blog/blob/main/src/pages/api/revalidate.ts"
    click Categories "https://github.com/daryllukas/notion-blog/blob/main/src/states/categories.ts"
    click PageState "https://github.com/daryllukas/notion-blog/blob/main/src/states/page.ts"
    click QueryState "https://github.com/daryllukas/notion-blog/blob/main/src/states/query.ts"
    click PostsService "https://github.com/daryllukas/notion-blog/blob/main/src/services/posts.ts"
    click NotionIntegration "https://github.com/daryllukas/notion-blog/blob/main/src/libs/notion.ts"
    click SearchUtil "https://github.com/daryllukas/notion-blog/blob/main/src/utils/search.ts"

    %% Styling
    classDef page fill:#2563eb,color:white
    classDef component fill:#3b82f6,color:white
    classDef state fill:#60a5fa,color:white
    classDef api fill:#22c55e,color:white
    classDef service fill:#7c3aed,color:white
    classDef external fill:#f97316,color:white

    %% Legend
    subgraph Legend
        L1["Pages"]:::page
        L2["Components"]:::component
        L3["State"]:::state
        L4["API Routes"]:::api
        L5["Services"]:::service
        L6["External"]:::external
    end
```
