# charliemeyer2000/website2 architecture

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

- Interactive diagram: https://gitdiagram.com/charliemeyer2000/website2
- Repository: https://github.com/charliemeyer2000/website2

## Overview

##### Project Type and Purpose
- This is a full-stack Next.js (pages router) blog/website, using SSG/SSR for content pages, MDX for authoring, serverless API routes for dynamic features (guestbook, view counts, XKCD fetch), and NextAuth for GitHub-based authentication.

##### Main Components
a. Client (Browser)
- React components under `/components` and page components under `/pages`.
- Uses SCSS modules for styling and Framer Motion for animations.
b. Next.js Server (Server-Side Rendering & Serverless Functions)
- Page rendering: `getStaticProps` / `getStaticPaths` pull MDX files from `/posts` and transform them via `next-mdx-remote` + remark-rehype.
- API layer under `/pages/api`:
- `/api/auth/[...nextauth]`: NextAuth.js handles GitHub OAuth flows.
- `/api/dynamo/*`: CRUD endpoints (`addNote`, `getNotes`, `getViews`, `updateItem`) that talk to DynamoDB via `utils/config/dynamoConfig.js`.
- `/api/xkcd/today`: fetches current XKCD strip.
c. Data Layer / External Services
- AWS DynamoDB: two tables, one for “slug”-based view counts, one for “note”-based guestbook entries.
- GitHub OAuth via NextAuth.js.
- External HTTP fetch to `https://xkcd.com` for the latest comic.
d. Static Assets & Build
- Build config: `next.config.js`, `jsconfig.json`, SCSS global styles in `/styles`.
- Hosted on Vercel (or another Node-capable host).

##### Relationships & Data Flows
- Page request → Next.js server → SSG/SSR → HTML + JS bundle → Browser.
- Client hook (`useViews`) → `/api/dynamo/getViews` → DynamoDB → response → UI.
- Client hook (`useGuestbook`) → `/api/dynamo/addNote` → DynamoDB → updated list.
- Authentication flow: Browser ↔ NextAuth endpoint ↔ GitHub OAuth provider.
- MDX rendering happens at build‐time (SSG), no runtime DB dependency for posts.

##### Architectural Patterns & Design Principles
- SSG/SSR hybrid using Next.js pages router.
- Client‐side state & data fetching via custom React hooks.
- Separation of concerns:
- `/components`: reusable UI pieces
- `/pages`: route definitions & data loading
- `/utils`: data configuration & hooks
- `/public` & `/static`: assets
- Serverless functions for microservices‐style API endpoints.
- MDX content pipeline integrated into Next.js build.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::client

    subgraph "Client (Browser Layer)"
        C1["UI Components"]:::client
        C2["Page Components"]:::client
        C3["Styling (SCSS Modules & Global Styles)"]:::client
        C4["React Hooks & Data Fetching"]:::client
    end

    subgraph "Server (Next.js Layer)"
        SSR["Next.js SSG/SSR"]:::server
        API["API Routes"]:::server
        subgraph "SSG/SSR Details"
            S1["pages/posts/[slug].js"]:::server
            S2["pages/posts/index.js"]:::server
            S3["posts/*.mdx"]:::server
            S4["utils/hooks/getPosts.js"]:::server
            S5["utils/hooks/getStaticPaths.js"]:::server
        end
        subgraph "API Routes Details"
            S6["pages/api/auth/[...nextauth].js"]:::server
            S7["pages/api/dynamo/addNote.js<br>getNotes.js<br>getViews.js<br>updateItem.js"]:::server
            S8["pages/api/xkcd/today.js"]:::server
        end
    end

    subgraph "Data Layer (AWS DynamoDB)"
        DB[("DynamoDB Tables")]:::data
    end

    subgraph "External Services & Assets"
        E1["GitHub OAuth Provider"]:::external
        E2["XKCD API (xkcd.com)"]:::external
        E3["Vercel CDN / Static Hosting"]:::external
        E4["public/ & static/ folders"]:::external
        E5["next.config.js<br>jsconfig.json<br>README.md<br>CLAUDE.md"]:::external
    end

    Browser -->|"page request"| SSR
    Browser -->|"API call"| API
    C4 -->|"useViews/useGuestbook"| API
    SSR -->|"build-time MDX"| S3
    API --> DB
    API --> E1
    API --> E2
    SSR --> C2
    SSR --> C1

    click C1 "https://github.com/charliemeyer2000/website2/tree/main/components/"
    click C2 "https://github.com/charliemeyer2000/website2/blob/main/pages/index.js"
    click C2 "https://github.com/charliemeyer2000/website2/blob/main/pages/guestbook.js"
    click C2 "https://github.com/charliemeyer2000/website2/blob/main/pages/posts/[slug].js"
    click C2 "https://github.com/charliemeyer2000/website2/blob/main/pages/posts/index.js"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/styles/globals.scss"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/styles/nprogress.scss"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/styles/pojoaque.scss"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/pages/index.module.scss"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/pages/guestbook.module.scss"
    click C3 "https://github.com/charliemeyer2000/website2/blob/main/components/**/*.module.scss"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/useViews.js"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/useGuestbook.js"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/getPosts.js"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/getStaticPaths.js"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/useNavTitles.js"
    click C4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/useProgress.js"
    click S1 "https://github.com/charliemeyer2000/website2/blob/main/pages/posts/[slug].js"
    click S2 "https://github.com/charliemeyer2000/website2/blob/main/pages/posts/index.js"
    click S4 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/getPosts.js"
    click S5 "https://github.com/charliemeyer2000/website2/blob/main/utils/hooks/getStaticPaths.js"
    click S3 "https://github.com/charliemeyer2000/website2/tree/main/posts/"
    click S6 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/auth/[...nextauth].js"
    click S7 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/dynamo/addNote.js"
    click S7 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/dynamo/getNotes.js"
    click S7 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/dynamo/getViews.js"
    click S7 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/dynamo/updateItem.js"
    click S7 "https://github.com/charliemeyer2000/website2/blob/main/utils/config/dynamoConfig.js"
    click S8 "https://github.com/charliemeyer2000/website2/blob/main/pages/api/xkcd/today.js"
    click DB "https://github.com/charliemeyer2000/website2/blob/main/utils/config/dynamoConfig.js"
    click E4 "https://github.com/charliemeyer2000/website2/tree/main/public/"
    click E4 "https://github.com/charliemeyer2000/website2/tree/main/static/"
    click E5 "https://github.com/charliemeyer2000/website2/blob/main/next.config.js"
    click E5 "https://github.com/charliemeyer2000/website2/blob/main/jsconfig.json"
    click E5 "https://github.com/charliemeyer2000/website2/blob/main/README.md"
    click E5 "https://github.com/charliemeyer2000/website2/blob/main/CLAUDE.md"

    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef server fill:#FFFACD,stroke:#333,stroke-width:1px;
    classDef data fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
