# jwbfut/jawbts-website-next architecture

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

- Interactive diagram: https://gitdiagram.com/jwbfut/jawbts-website-next
- Repository: https://github.com/jwbfut/jawbts-website-next

## Overview

##### Overall Structure & Project Purpose
- Project Type: A full-stack web application (frontend built with Next.js) that integrates with back-end API services.
- Main Purposes: User authentication, personalized profile management, and music handling (adding, modifying, playing).

##### Main Components to Highlight
a. Frontend (Next.js Application)
- App Layer: This includes the primary routing (the “app” directory) which is organized into sections such as:
- Authentication (app/auth): Handles GitHub OAuth callbacks, logout, OTP, refresh token endpoints.
- Navigation (app/nav): Supports different pages such as a root navigation, profiles, and music pages (including add and modify features).
- Global Components: Shared layout (app/layout.tsx and app/nav/layout.tsx), styling (global.css, banner_styles.module.css), and error handling (app/not-found.tsx).
- Components Layer: Contains reusable logic (under components/logic) such as:
- Audio processing (audioFetcher, audioModified)
- Event bus for intra-component communication.
- Server actions logic for handling API calls.
- Utility functions (e.g., asyncUtils, authUtils, and various service-specific utils).
- UI Elements: Components for music lists, music player, navigation bar, and a redirect handler to encapsulate presentation and interactions.

b. Communication & Integration Points
- Back-end API Integration: As mentioned in the README, this project requires connectivity with the Jawbts API Next service. Mark this as an external service that interfaces with the frontend (e.g., for user data, music data, etc.).
- GitHub OAuth2.0 for authentication.
- TailwindCSS for styling.
- MP4Box.js and ffmpeg.wasm for media file processing.
- jose for JWT encryption/decryption.
- node-qrcode for QR code generation.
- Vercel deployment for hosting.

- “Navigation & Profiles” module: This shows how user navigation (app/nav) is structured, with a separate branch for the profiles page.
- “Music Module”: Emphasize components under app/nav/music; include the add, modify and main music pages. Complement this with corresponding UI components (e.g., musicPlayer.jsx, musicListModifer.tsx) and the logic layers which handle audio processing.
- “Core Layout & Global Styling”: Indicate that the app uses Next.js page layouts with app/layout.tsx and app/nav/layout.tsx for consistent styling and routing. This layer ensures a unified look and feel.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    UB("User Browser"):::external

    %% Frontend Modules
    subgraph "Authentication Module"
        AuthCallback("GitHub OAuth Callback"):::auth
        AuthLogout("Logout Endpoint"):::auth
        AuthOTP("OTP Endpoint"):::auth
        AuthRefresh("Refresh Token Endpoint"):::auth
        AuthUtils("Auth Utils"):::auth
    end

    subgraph "Navigation & Profiles Module"
        NavPage("Navigation Page"):::nav
        ProfilesPage("Profiles Page"):::nav
        NavLayout("Navigation Layout"):::nav
    end

    subgraph "Music Module"
        MusicMain("Music Main Page"):::music
        MusicAdd("Add Music Page"):::music
        MusicModify("Modify Music Page"):::music
        MusicPlayerUI("Music Player UI"):::music
        MusicListUI("Music List Modifier UI"):::music
        AudioFetcher("Audio Fetcher"):::music
        AudioModified("Audio Modified"):::music
    end

    subgraph "Core Layout & Global Styling"
        MainLayout("Main Layout"):::layout
        GlobalCSS("Global CSS"):::layout
        BannerStyles("Banner Styles"):::layout
    end

    subgraph "Utility/Logic Components"
        ServerActions("Server Actions (TS)"):::util
        ServerActionsJS("Server Actions (JS)"):::util
        EventBus("Event Bus"):::util
        AsyncUtils("Async Utils"):::util
        Others("Other Utilities"):::util
    end

    subgraph "External API & Deployment"
        APIService("Jawbts API Next"):::external
        Vercel("Vercel Hosting"):::deploy
        VercelConfig("Vercel Config"):::deploy
        NextConfig("Next.js Config"):::deploy
    end

    %% Connections from User
    UB -->|"authenticates"| AuthCallback
    UB -->|"navigates to"| NavPage

    %% Authentication Module interactions
    AuthUtils -->|"supports"| AuthCallback
    AuthUtils -->|"supports"| AuthLogout
    AuthUtils -->|"supports"| AuthOTP
    AuthUtils -->|"supports"| AuthRefresh

    %% Navigation & Profiles interactions
    NavPage -->|"leads to"| ProfilesPage
    MainLayout -->|"includes"| NavLayout

    %% Music Module interactions
    NavPage -->|"accesses"| MusicMain
    MusicMain -->|"triggers"| MusicAdd
    MusicMain -->|"triggers"| MusicModify
    MusicMain -->|"displays"| MusicPlayerUI
    MusicMain -->|"displays"| MusicListUI
    MusicPlayerUI -->|"fetches audio via"| AudioFetcher
    MusicListUI -->|"modifies audio via"| AudioModified
    MusicMain -->|"gets music data from"| APIService

    %% Global Layout & Styling influences
    MainLayout -->|"applies"| GlobalCSS
    MainLayout -->|"applies"| BannerStyles

    %% Utility/Logic integration
    ServerActions -->|"calls"| APIService
    ServerActionsJS -->|"calls"| APIService
    AsyncUtils -->|"assists"| ServerActions
    EventBus -->|"coordinates"| MusicPlayerUI
    EventBus -->|"coordinates"| MusicListUI

    %% Navigation data fetching
    NavPage -->|"fetches profile data from"| APIService

    %% Deployment & External Configuration
    Vercel -->|"hosts"| MainLayout
    VercelConfig -->|"configures"| Vercel
    NextConfig -->|"configures"| Vercel

    %% Core Layout interaction with external API
    MainLayout -->|"renders API calls to"| APIService

    %% Styles
    classDef auth fill:#ffcccc,stroke:#900,stroke-width:2px;
    classDef nav fill:#ccffcc,stroke:#090,stroke-width:2px;
    classDef music fill:#ccccff,stroke:#009,stroke-width:2px;
    classDef layout fill:#ffffcc,stroke:#990,stroke-width:2px;
    classDef util fill:#ffccff,stroke:#909,stroke-width:2px;
    classDef external fill:#e6e6e6,stroke:#666,stroke-width:2px;
    classDef deploy fill:#cce6ff,stroke:#006,stroke-width:2px;

    %% Click Events for Authentication Module
    click AuthCallback "https://github.com/jwbfut/jawbts-website-next/blob/main/app/auth/github/callback/page.tsx"
    click AuthLogout "https://github.com/jwbfut/jawbts-website-next/blob/main/app/auth/logout/page.tsx"
    click AuthOTP "https://github.com/jwbfut/jawbts-website-next/blob/main/app/auth/otp/page.tsx"
    click AuthRefresh "https://github.com/jwbfut/jawbts-website-next/blob/main/app/auth/refresh/page.tsx"
    click AuthUtils "https://github.com/jwbfut/jawbts-website-next/blob/main/components/utils/authUtils.ts"

    %% Click Events for Navigation & Profiles Module
    click NavPage "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/page.tsx"
    click ProfilesPage "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/profiles/page.tsx"
    click NavLayout "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/layout.tsx"

    %% Click Events for Music Module
    click MusicMain "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/music/page.tsx"
    click MusicAdd "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/music/add/page.tsx"
    click MusicModify "https://github.com/jwbfut/jawbts-website-next/blob/main/app/nav/music/modify/page.tsx"
    click MusicPlayerUI "https://github.com/jwbfut/jawbts-website-next/blob/main/components/ui/musicPlayer.jsx"
    click MusicListUI "https://github.com/jwbfut/jawbts-website-next/blob/main/components/ui/musicListModifer.tsx"
    click AudioFetcher "https://github.com/jwbfut/jawbts-website-next/blob/main/components/logic/audioFetcher.ts"
    click AudioModified "https://github.com/jwbfut/jawbts-website-next/blob/main/components/logic/audioModified.ts"

    %% Click Events for Core Layout & Global Styling
    click MainLayout "https://github.com/jwbfut/jawbts-website-next/blob/main/app/layout.tsx"
    click GlobalCSS "https://github.com/jwbfut/jawbts-website-next/blob/main/app/global.css"
    click BannerStyles "https://github.com/jwbfut/jawbts-website-next/blob/main/app/banner_styles.module.css"

    %% Click Events for Utility/Logic Components
    click ServerActions "https://github.com/jwbfut/jawbts-website-next/blob/main/components/logic/serverActions.ts"
    click ServerActionsJS "https://github.com/jwbfut/jawbts-website-next/blob/main/components/logic/serverActionsJS.js"
    click EventBus "https://github.com/jwbfut/jawbts-website-next/blob/main/components/logic/eventBus.ts"
    click AsyncUtils "https://github.com/jwbfut/jawbts-website-next/blob/main/components/utils/asyncUtils.ts"
    click Others "https://github.com/jwbfut/jawbts-website-next/tree/main/components/utils/"

    %% Click Events for Deployment Configurations
    click VercelConfig "https://github.com/jwbfut/jawbts-website-next/blob/main/.github/workflows/vercel.yml"
    click NextConfig "https://github.com/jwbfut/jawbts-website-next/blob/main/next.config.mjs"
```
