# msaifurrijaal/volunpath-fe architecture

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

- Interactive diagram: https://gitdiagram.com/msaifurrijaal/volunpath-fe
- Repository: https://github.com/msaifurrijaal/volunpath-fe

## Overview

##### Project type and purpose
- This is a Next.js–based full-stack web application.
- It renders React pages on the server (SSR/SSG) and also exposes API routes for authentication via NextAuth.
- It consumes external REST endpoints for events, activities, and auth via an Axios-based service layer.

##### File structure
- src/app – Next.js App Router: page.tsx, nested layouts, route handlers under src/app/api/auth.
- src/components – Reusable UI components by category: layout, partials (NavBar, Footer), ux building blocks (dialogs, skeletons), and page-specific UI.
- src/configs – Configuration of AxiosInstance (base URL, interceptors), TanStack-Query providers, NextAuth authOptions and matchers.
- src/services – Thin wrappers over AxiosInstance to call external APIs: auth (login, register, refresh), activity (getActivities), event (getEvents).
- src/context – React Context for storing user data.
- src/middleware.ts + src/middlewares/withAuth.ts – Global and route-level auth middleware.
- src/utils, src/types, public, theme.ts, etc. support styling, typing, and assets.

##### README
- Confirms Next.js application bootstrapped with create-next-app.
- Mentions NextAuth for auth, font optimization, Vercel deployment.
- No internal database code → application relies on external REST/identity services.

##### Detail
- Every layer—from the user’s browser down to each service call.
- Middleware (withAuth) intercepting route requests.
- “SSR/SSG” and “Serverless Functions” where appropriate in the Next.js Server component.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Client-Side UI" 
        direction TB
        Client["Browser"]:::client
        subgraph "UI Layer (React Components)"
            direction TB
            LayoutComponents["Layout Components"]:::client
            Partials["Partials (NavBar, Footer)"]:::client
            UIBlocks["UI Building Blocks"]:::client
            PageUI["Page-specific UI Components"]:::client
        end
        subgraph "Views"
            direction TB
            HomeView["Home View"]:::client
            LoginView["Login View"]:::client
            RegisterView["Register View"]:::client
        end
    end

    %% Data & State Providers
    subgraph "State & Data Providers"
        direction TB
        DataUserContext["DataUser Context"]:::client
        QueryProvider["TanStack Query Provider"]:::client
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AxiosInstance["AxiosInstance Setup"]:::service
        subgraph "Auth Services"
            direction TB
            loginAuth["loginAuth"]:::service
            registerUser["registerUser"]:::service
            refreshToken["refreshToken"]:::service
        end
        getActivities["getActivities"]:::service
        getEvents["getEvents"]:::service
    end

    %% Configuration & Middleware
    subgraph "Config & Middleware"
        direction TB
        AuthOptions["NextAuth Options"]:::config
        Matchers["Auth Matchers"]:::config
        OAuthProviders["OAuth Providers"]:::config
        GlobalMiddleware["Global Middleware"]:::server
        AuthMiddleware["withAuth Middleware"]:::server
    end

    %% Next.js Server
    subgraph "Next.js Server"
        direction TB
        AppRouter["Next.js App Router\n(SSR/SSG)"]:::server
        RootLayout["Root Layout"]:::server
        AppsLayout["Apps Layout"]:::server
        NextAuthRoute["NextAuth Route Handler"]:::server
    end

    %% External Systems
    subgraph "External Services"
        direction TB
        IdentityProvider["Identity Providers"]:::external
        EventsAPI["External Events API"]:::external
        ActivitiesAPI["External Activities API"]:::external
        AuthAPI["External Auth API"]:::external
    end

    %% Utilities & Types
    subgraph "Utilities & Types"
        direction TB
        Formatter["Date Formatter"]:::utility
        ErrorTypes["Error Types"]:::utility
        EventTypes["Event Types"]:::utility
        NextAuthTypes["NextAuth Types"]:::utility
        UserTypes["User Types"]:::utility
        ThemeConfig["Global Theme"]:::utility
    end

    %% Connections
    Client -->|"requests"| AppRouter
    AppRouter -->|"renders pages"| HomeView
    AppRouter --> LoginView
    AppRouter --> RegisterView
    AppRouter -->|"calls API"| NextAuthRoute
    NextAuthRoute -->|"NextAuth flow"| IdentityProvider
    NextAuthRoute --> DataUserContext
    HomeView --> LayoutComponents
    LoginView --> Partials
    RegisterView --> Partials
    DataUserContext --> HomeView
    QueryProvider --> HomeView
    HomeView -->|"useQuery/useMutation"| getActivities
    HomeView --> getEvents
    LoginView --> loginAuth
    RegisterView --> registerUser
    loginAuth --> AxiosInstance
    registerUser --> AxiosInstance
    refreshToken --> AxiosInstance
    getActivities --> AxiosInstance
    getEvents --> AxiosInstance
    AxiosInstance --> AuthAPI
    AxiosInstance --> EventsAPI
    AxiosInstance --> ActivitiesAPI
    GlobalMiddleware --> AppRouter
    AuthMiddleware --> NextAuthRoute
    AuthOptions --> NextAuthRoute
    Matchers --> NextAuthRoute
    OAuthProviders --> NextAuthRoute
    Formatter --> HomeView
    ErrorTypes --> AxiosInstance
    EventTypes --> getEvents
    NextAuthTypes --> NextAuthRoute
    UserTypes --> DataUserContext
    ThemeConfig --> LayoutComponents

    %% Click Events
    click AppRouter "https://github.com/msaifurrijaal/volunpath-fe/tree/main/src/app"
    click RootLayout "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/app/layout.tsx"
    click AppsLayout "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/app/(apps)/layout.tsx"
    click NextAuthRoute "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click LayoutComponents "https://github.com/msaifurrijaal/volunpath-fe/tree/main/src/components/layout"
    click Partials "https://github.com/msaifurrijaal/volunpath-fe/tree/main/src/components/partials"
    click UIBlocks "https://github.com/msaifurrijaal/volunpath-fe/tree/main/src/components/ui/commond"
    click PageUI "https://github.com/msaifurrijaal/volunpath-fe/tree/main/src/components/ui/pages"
    click HomeView "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/views/home/index.tsx"
    click LoginView "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/views/login/index.tsx"
    click LoginView "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/views/login/Login.module.scss"
    click RegisterView "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/views/register/index.tsx"
    click RegisterView "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/views/register/Register.module.scss"
    click AxiosInstance "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/configs/api/AxiosIstance.ts"
    click AuthOptions "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/configs/auth/authOptions.ts"
    click Matchers "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/configs/auth/matchers.ts"
    click OAuthProviders "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/configs/auth/providers/index.tsx"
    click QueryProvider "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/configs/tanstack-query/providers/index.tsx"
    click DataUserContext "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/context/DataUser.tsx"
    click GlobalMiddleware "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/middleware.ts"
    click AuthMiddleware "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/middlewares/withAuth.ts"
    click loginAuth "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/services/auth/loginAuth.ts"
    click registerUser "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/services/auth/registerUser.ts"
    click refreshToken "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/services/auth/refreshToken.ts"
    click getActivities "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/services/activity/getActivities.ts"
    click getEvents "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/services/event/getEvents.ts"
    click Formatter "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/utils/formatter/formatDateToText.ts"
    click ErrorTypes "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/types/errorTypes.ts"
    click EventTypes "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/types/eventTypes.ts"
    click NextAuthTypes "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/types/next-auth.d.ts"
    click UserTypes "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/types/userTypes.ts"
    click ThemeConfig "https://github.com/msaifurrijaal/volunpath-fe/blob/main/src/theme.ts"

    %% Styles
    classDef client fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
    classDef server fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
    classDef service fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px
    classDef external fill:#fff3e0,stroke:#fb8c00,stroke-width:2px
    classDef config fill:#fffde7,stroke:#fdd835,stroke-width:2px
    classDef utility fill:#eceff1,stroke:#607d8b,stroke-width:2px
```
