# yuriowindiatmoko2401/santun-app-baseline architecture

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

- Interactive diagram: https://gitdiagram.com/yuriowindiatmoko2401/santun-app-baseline
- Repository: https://github.com/yuriowindiatmoko2401/santun-app-baseline

## Overview

##### Project type and purpose
- This is a full-stack chat application built with Next.js 14, TypeScript, Tailwind CSS.
- It offers real-time messaging using Upstash Redis and Pusher, image uploads via Cloudinary, authentication via Kinde, and other UI niceties (sounds, themes, typing effects).

##### File structure
- Top-level folders:
- public/ – static assets (avatars, sounds, images)
- src/app/ – Next.js “app” directory (page.tsx, layout.tsx, API routes under app/api)
- src/components/ – reusable UI components (chat, sidebar, providers, UI primitives)
- src/actions/ – client-side action handlers (auth, message)
- src/lib/ – wrappers for external services (db.ts for Upstash Redis, pusher.ts for Pusher, utils.ts)
- src/db/ – dummy data or mocks (dummy.ts)
- src/store/ – state management hooks (e.g., usePreferences, useSelectedUser)
- Config files:
- next.config.mjs, tailwind.config.ts for build and styling
- .env.sample for environment variables (Kinde, Upstash, Cloudinary, Pusher)

##### README for additional insights
- Confirms tech stack, key features (real-time chat, auth, image uploads).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE_Browser["Browser (React/Next.js Client)"]:::frontend
        FE_UI["UI Components"]:::frontend
        UI_Primitives["UI Primitives"]:::frontend
        Providers["Providers"]:::frontend
        PrefHook["usePreferences Hook"]:::frontend
        SelHook["useSelectedUser Hook"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API_Layer["Next.js API Layer"]:::backend
        AuthAPI["Auth API Route"]:::backend
        MsgAPI["Message API Routes"]:::backend
        UploadAPI["Cloudinary Signing API"]:::backend
        Lib_DB["DB Wrapper (Upstash Redis)"]:::service
        Lib_Pusher["Pusher Wrapper"]:::service
        Dummy["Dummy Data"]:::service
        Actions_Auth["Auth Actions"]:::service
        Actions_Msg["Message Actions"]:::service
    end

    %% External Services
    Kinde["Kinde Auth Service"]:::external
    PusherSvc["Pusher (Real-time)"]:::external
    Redis["Upstash Redis"]:::external
    Cloud["Cloudinary"]:::external

    %% Connections
    FE_Browser -->|"page load & hydration"| API_Layer
    FE_Browser -->|"/api/auth"| AuthAPI
    FE_Browser -->|"/api/message"| MsgAPI
    FE_Browser -->|"/api/sign-cloudinary-params"| UploadAPI
    FE_Browser <-->|"subscribe/publish events"| PusherSvc

    API_Layer -->|"OAuth token exchange"| Kinde
    API_Layer -->|"store/fetch messages"| Redis
    API_Layer -->|"publish events"| PusherSvc
    API_Layer -->|"request signed params"| Cloud

    %% Grouped UI components
    FE_Browser --> FE_UI
    FE_UI --> UI_Primitives
    FE_UI --> Providers
    FE_Browser --> PrefHook
    FE_Browser --> SelHook

    %% Service wrappers and actions
    API_Layer --> Lib_DB
    API_Layer --> Lib_Pusher
    API_Layer --> Dummy
    API_Layer --> Actions_Auth
    API_Layer --> Actions_Msg

    %% Click Events
    click FE_Browser "https://github.com/yuriowindiatmoko2401/santun-app-baseline/tree/main/src/app/"
    click FE_UI "https://github.com/yuriowindiatmoko2401/santun-app-baseline/tree/main/src/components/"
    click UI_Primitives "https://github.com/yuriowindiatmoko2401/santun-app-baseline/tree/main/src/components/ui/"
    click Providers "https://github.com/yuriowindiatmoko2401/santun-app-baseline/tree/main/src/components/providers/"
    click PrefHook "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/store/usePreferences.ts"
    click SelHook "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/store/useSelectedUser.ts"
    click API_Layer "https://github.com/yuriowindiatmoko2401/santun-app-baseline/tree/main/src/app/api/"
    click AuthAPI "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/app/api/auth/[kindeAuth]/route.ts"
    click UploadAPI "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/app/api/sign-cloudinary-params/route.ts"
    click Lib_DB "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/lib/db.ts"
    click Lib_Pusher "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/lib/pusher.ts"
    click Dummy "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/db/dummy.ts"
    click Actions_Auth "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/actions/auth.actions.ts"
    click Actions_Msg "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/actions/message.actions.ts"
    click Tailwind "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/tailwind.config.ts"
    click Globals "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/src/app/globals.css"
    click Env "https://github.com/yuriowindiatmoko2401/santun-app-baseline/blob/main/ .env.sample"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:1px;
    classDef backend fill:#bbf,stroke:#333,stroke-width:1px;
    classDef service fill:#bfb,stroke:#333,stroke-width:1px;
    classDef external fill:#ffb,stroke:#333,stroke-width:1px;
```
