# wiscaksono/wiscaksono-site architecture

> Architecture diagram of the GitHub repository wiscaksono/wiscaksono-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/wiscaksono/wiscaksono-site
- Repository: https://github.com/wiscaksono/wiscaksono-site

## Overview

##### Main Components Identification
- Content Management: Content stored as markdown files in src/contents (subdirectories for abouts, articles, projects). This content is processed with mdsvex and is rendered on the frontend. It may include static assets (images, preview snapshots) from the static directory.
- Backend & API Layer: SvelteKit endpoints handling authentication (routes/api/auth and its callback), error pages, and data fetching logic (server files in src/routes and hooks.server.ts). This layer acts as an interface between the UI and server-side logic.
- Database & ORM: Database interactions are managed using Drizzle ORM. This includes DB schema definitions, session management, and user handling in src/lib/server/db. The server folder organizes these concerns clearly.
- Authentication & External Services: Integration with Lucia Auth (detailed in the README) and possibly other OAuth processes (e.g., src/lib/server/oauth.ts).

##### Relationships and Interactions
- The UI (components and layouts) renders views based on data from routed pages.
- Dynamic pages (e.g., articles/[slug] or projects/[slug]) dynamically load markdown content from src/contents.
- API routes interact with the backend logic to support authentication and user session management.
- The server components and hooks (e.g., hooks.server.ts) facilitate data fetching, authentication, and middleware functions.
- The ORM layer abstracts database transactions; the UI indirectly triggers database calls via endpoints or server hooks.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project cleanly separates content (markdown files), presentation (Svelte components and layouts), and backend logic (API endpoints, authentication, DB operations).
- File-Based Routing: Leveraging SvelteKit’s file-based routing to map URL paths to corresponding components.
- Component-Based UI: Modular Svelte components (e.g., header, navbar, layout) make the UI highly composable.
- Data Flow: Static and dynamic content (sourced from markdown or the database) flows through the server layer to the UI, managed by directional routing and API calls.

##### Relevant Technologies and Frameworks
- SvelteKit for the frontend application and routing.
- mdsvex for converting markdown files into Svelte components.
- Drizzle ORM for database schema, queries, and entity management.
- Lucia Auth for user authentication and session management.
- Tailwind CSS for styling.
- Vite, TypeScript, and various linting/prettier configurations for build and development processes.
- GitHub configuration files indicate continuous integration and dependency management.

##### Detailed Component Breakdown
- Content: Represent the src/contents folder structure, illustrating that it contains markdown sources for different sections (abouts, articles, projects).
- Backend/API: Include the routes/api folder, noting authentication endpoints and other potential API gateways.
- Database & Services: On the backend side, include a node for Drizzle ORM usage, with schema definitions, session management, and user database components.
- External Libraries/Services: Optionally add nodes for Lucia Auth, mdsvex, and Tailwind CSS to indicate they are foundational to specific system functions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    B["Browser (User Request)"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        RT["Routes (SvelteKit)"]:::frontend
        CP["Components (Svelte)"]:::frontend
    end

    %% Content Layer
    subgraph "Content Layer"
        MD["Markdown Files"]:::content
    end

    %% Backend/API Layer
    subgraph "Backend/API Layer"
        AUTH["Auth Endpoint (+server.ts)"]:::backend
        CALLB["Auth Callback (+server.ts)"]:::backend
        HOOKS["Server Hooks (hooks.server.ts)"]:::backend
    end

    %% Database & External Services
    DB["Database (Drizzle ORM)"]:::database
    OAUTH["OAuth Integration"]:::external

    %% Data Flow
    B -->|"sends request"| RT
    RT -->|"renders UI"| CP
    RT -->|"fetches content"| MD
    RT -->|"calls authentication API"| AUTH
    HOOKS -->|"handles middleware"| RT
    AUTH -->|"queries/updates"| DB
    CALLB -->|"integrates with"| OAUTH
    HOOKS -->|"validates session"| DB

    %% Click Events
    click RT "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/routes"
    click CP "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/lib/components"
    click MD "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/contents"
    click AUTH "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/routes/api/auth"
    click CALLB "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/routes/api/auth/callback"
    click HOOKS "https://github.com/wiscaksono/wiscaksono-site/blob/master/src/hooks.server.ts"
    click DB "https://github.com/wiscaksono/wiscaksono-site/tree/master/src/lib/server/db"
    click OAUTH "https://github.com/wiscaksono/wiscaksono-site/blob/master/src/lib/server/oauth.ts"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#036,stroke-width:2px
    classDef content fill:#FFB6C1,stroke:#C00,stroke-width:2px
    classDef backend fill:#C6F1C2,stroke:#080,stroke-width:2px
    classDef database fill:#FFF3B0,stroke:#B8860B,stroke-width:2px
    classDef external fill:#E0BBE4,stroke:#600,stroke-width:2px
```
