# danny-ssong/book-journey architecture

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

- Interactive diagram: https://gitdiagram.com/danny-ssong/book-journey
- Repository: https://github.com/danny-ssong/book-journey

## Overview

##### Project type and purpose
- This is a full-stack web application built on Next.js 14, using the App Router (src/app).
- It’s a “Book Journey” social/review platform where users can search book metadata (via Kakao Open API), create posts/reviews, view feed/statistics, and manage profiles.
- Supabase provides authentication, database, and edge functions; Tailwind CSS handles styling.

##### File structure
- Top-level config: next.config.js/mjs, tsconfig.json, tailwind.config.ts, supabase/config.toml.
- “src/app”: the Next.js App Router with nested folders for each route (/, /books, /posts, /users, /search, /manage, etc.).
- Each route contains page.tsx entrypoints, server-actions (src/app/actions), dynamic segments ([isbn], [postId], [userId]).
- Shared UI components under src/app/_components and route-scoped components under route/_components.
- Hooks (src/app/_hooks) for infinite scrolling, data fetching, theming, user state.
- Library functions (src/app/_lib) for server-side data access (getPostsGroupBy, getMe, revalidatePath).
- API routes under src/app/api (revalidate).
- “src/components/ui”: a design-system layer of generic UI primitives (buttons, cards, popovers).
- “src/lib” and “src/utils”: generic utilities (auth, caching, middleware).
- “supabase” folder: database schema (seed.sql), Supabase CLI config (config.toml).
- Types in “src/types” for domain objects (book, post, user, profile).

##### README for additional insights
- Confirms tech stack: Next.js, Tailwind CSS, Supabase, Kakao Open API.
- Indicates environment setup necessary for Supabase and Kakao credentials.

##### Detail without over-splitting
- Logical groupings (e.g., “src/app/_components” as UI layer vs “src/app/actions” as Mutation layer).
- Dynamic routes and server-side data fetching.
- Convey how the design system (ui primitives) underpins all client UIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Browser/Client\n(React SPA, SSR/SSG)"]:::frontend
    Browser -->|"HTTP Requests / Client Components"| NextJS

    %% Next.js Server Layer
    subgraph "Next.js Server (App Router + Server Actions)" 
        direction TB
        Layout["App Router & Layouts"]:::server
        PageHome["Home Feed Route\nsrc/app/(home)/page.tsx"]:::server
        PageBook["Book Detail Route\nsrc/app/books/[isbn]/page.tsx"]:::server
        PagePostView["View Post Route\nsrc/app/posts/[postId]/page.tsx"]:::server
        PagePostNew["New Post Route\nsrc/app/posts/new/page.tsx"]:::server
        PagePostEdit["Edit Post Route\nsrc/app/posts/edit/[postId]/page.tsx"]:::server
        PageUser["User Profile Route\nsrc/app/users/[userId]/page.tsx"]:::server
        SharedUI["Shared UI Components\nsrc/app/_components"]:::frontend
        Hooks["Data Fetch Hooks & Client Utils\nsrc/app/_hooks"]:::frontend
        LibServer["Server-side Data Libraries\nsrc/app/_lib"]:::server
        Actions["Server Actions (Mutations)\nsrc/app/actions"]:::server
        APIReval["API Route: Revalidate\nsrc/app/api/revalidate/route.ts"]:::server
    end

    NextJS["Next.js Server"]:::server
    NextJS -->|uses| Layout
    Layout --> PageHome
    Layout --> PageBook
    Layout --> PagePostView
    Layout --> PagePostNew
    Layout --> PagePostEdit
    Layout --> PageUser
    PageHome --> SharedUI
    PageBook --> SharedUI
    PagePostView --> SharedUI
    PagePostNew --> SharedUI
    PagePostEdit --> SharedUI
    PageUser --> SharedUI
    SharedUI --> Hooks
    SharedUI --> LibServer
    Hooks -->|fetch| LibServer
    Actions -->|mutate| LibServer
    APIReval -->|calls| LibServer

    %% External Services
    Kakao["Kakao Open API\n(Book Metadata)"]:::external
    Supabase["Supabase\n(Auth, Postgres, Edge Functions)"]:::external

    NextJS -->|"CRUD / Auth"| Supabase
    NextJS -->|"Book Data"| Kakao

    %% Infrastructure
    CDN["Vercel / CDN\n(Static Assets)"]:::infra
    CDN -->|serves| Browser
    NextJS --> CDN

    %% Click Events
    click Layout "https://github.com/danny-ssong/book-journey/blob/main/src/app/layout.tsx"
    click PageHome "https://github.com/danny-ssong/book-journey/blob/main/src/app/(home)/page.tsx"
    click PageBook "https://github.com/danny-ssong/book-journey/blob/main/src/app/books/[isbn]/page.tsx"
    click PagePostView "https://github.com/danny-ssong/book-journey/blob/main/src/app/posts/[postId]/page.tsx"
    click PagePostNew "https://github.com/danny-ssong/book-journey/blob/main/src/app/posts/new/page.tsx"
    click PagePostEdit "https://github.com/danny-ssong/book-journey/blob/main/src/app/posts/edit/[postId]/page.tsx"
    click PageUser "https://github.com/danny-ssong/book-journey/blob/main/src/app/users/[userId]/page.tsx"
    click SharedUI "https://github.com/danny-ssong/book-journey/tree/main/src/app/_components"
    click Hooks "https://github.com/danny-ssong/book-journey/tree/main/src/app/_hooks"
    click LibServer "https://github.com/danny-ssong/book-journey/tree/main/src/app/_lib"
    click Actions "https://github.com/danny-ssong/book-journey/tree/main/src/app/actions"
    click APIReval "https://github.com/danny-ssong/book-journey/blob/main/src/app/api/revalidate/route.ts"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef server fill:#E8F5E9,stroke:#1B5E20,color:#2E7D32
    classDef external fill:#FFF3E0,stroke:#E65100,color:#BF360C
    classDef infra fill:#ECEFF1,stroke:#37474F,color:#263238
```
