# zainal21/my-site architecture

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

- Interactive diagram: https://gitdiagram.com/zainal21/my-site
- Repository: https://github.com/zainal21/my-site

## Overview

##### Main Components
- Frontend: This is driven by Next.js. The “pages” directory defines your routes (e.g., home, about, blog, projects, uses, error pages) and API endpoints. Also, note the custom _app.tsx and _document.tsx files, which are central to managing global styles and document structure.
- UI Component Libraries:
- Data Layer: The “data” directory holds static data (experience, projects, links, skills), while “libs” includes helper libraries for blogs, date, fetch functions, and Spotify integration. This layer supports the content displayed on the site.
- State and Context: The “context” directory with ThemeContext.tsx provides a global state (likely for theming) to be shared across components.
- Hooks: Custom hooks like useSpotifyCurrentlyPlaying and useSpotifyPlaylist encapsulate logic for external API interactions.
- API Endpoints: Located under pages/api, including endpoints for Spotify integration (current-playing and playlist) and a generic hello endpoint.
- Layouts: The HomePageLayout under layouts, defining the overall structure of the site’s homepage.
- Static Assets and Configuration: The “public” folder holds images, a resume PDF, and an XML sitemap. Configuration files (next.config.js, tailwind.config.ts, postcss.config.js, tsconfig.json, etc.) define the build and styling systems.

- Next.js Server at the center handily driving both SSR and client interactions.
– Each page (home, about, blog, projects, uses) loads its corresponding React components.
– Highlight the API Routes under “pages/api” as a separate block that the frontend interacts with when fetching external data (such as Spotify playing status).
- Data Management & Integration:
– Show “Hooks” as wrappers that fetch or manage external API data and integrate back into components (e.g., hooks calling Spotify endpoints).
- Global Context:
- External Services:

##### Architectural Patterns and Design Principles
- Component-Based Architecture: The clear separation into a reusable design system and specific modules underlines the importance of high reusability and maintainability.
- API Layer Abstraction: The use of Next.js API routes to interface with external services (like Spotify) creates a decoupled architecture.
- Separation of Concerns: Dividing the project into UI (components), data (data and libs), state (context), and business logic (pages and hooks).
- SSR/Static Rendering: As a Next.js project, note the mix of server side rendering (SSR) and static pages, which is important for performance and SEO.

- Next.js routing layer and globally available context wrapping the application.
- Branch out to show the page components consuming the design system and module components.
- Interaction flow to the API layer for dynamic content (e.g., Spotify).
- Static assets and configuration influencing the overall system.

## Diagram (Mermaid)

```mermaid
graph TD
    browser["Client Browser"]:::browser
    server["Next.js Server/Router"]:::server
    globalContext["Global Context/Theme Provider"]:::globalContext
    pages["Pages & Routing"]:::pages
    designSystem["Reusable UI Components (Design System)"]:::designSystem
    modules["Domain-Specific Modules"]:::modules
    layouts["Page Layouts (HomePageLayout)"]:::layouts
    staticData["Static Data"]:::dataLayer
    dataLibs["Utility/Helper Libraries"]:::dataLayer
    hooks["Custom Hooks"]:::dataLayer
    api["API Endpoints"]:::apiEndpoints
    spotify["External Services (Spotify)"]:::externalService
    staticAssets["Static Assets & Configuration"]:::staticAssets

    browser --> server
    server --> globalContext
    server --> pages
    server --- staticAssets
    globalContext --> pages

    pages --> designSystem
    pages --> modules
    pages --> layouts
    pages --> staticData
    pages --> dataLibs
    pages --> hooks

    hooks --> api
    api --> spotify

    staticData --> designSystem
    staticData --> modules
    dataLibs --> designSystem
    dataLibs --> modules

    click pages "https://github.com/zainal21/my-site/tree/main/pages"
    click designSystem "https://github.com/zainal21/my-site/tree/main/components/design-system"
    click modules "https://github.com/zainal21/my-site/tree/main/components/modules"
    click staticData "https://github.com/zainal21/my-site/tree/main/data"
    click dataLibs "https://github.com/zainal21/my-site/tree/main/libs"
    click globalContext "https://github.com/zainal21/my-site/blob/main/context/ThemeContext.tsx"
    click hooks "https://github.com/zainal21/my-site/tree/main/hooks"
    click api "https://github.com/zainal21/my-site/tree/main/pages/api"
    click layouts "https://github.com/zainal21/my-site/blob/main/layouts/HomePageLayout.tsx"
    click staticAssets "https://github.com/zainal21/my-site/tree/main/public"
    click server "https://github.com/zainal21/my-site/tree/main/pages"

classDef browser fill:#b3cde0,stroke:#333,stroke-width:2px;
classDef server fill:#6495ed,stroke:#333,stroke-width:2px;
classDef pages fill:#6495ed,stroke:#333,stroke-width:2px;
classDef globalContext fill:#90ee90,stroke:#333,stroke-width:2px;
classDef designSystem fill:#90ee90,stroke:#333,stroke-width:2px;
classDef modules fill:#90ee90,stroke:#333,stroke-width:2px;
classDef layouts fill:#90ee90,stroke:#333,stroke-width:2px;
classDef dataLayer fill:#ffa07a,stroke:#333,stroke-width:2px;
classDef apiEndpoints fill:#ff7f7f,stroke:#333,stroke-width:2px;
classDef externalService fill:#ff6347,stroke:#333,stroke-width:2px;
classDef staticAssets fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
