# brilliahib/cms-impact-x architecture

> Architecture diagram of the GitHub repository brilliahib/cms-impact-x, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/brilliahib/cms-impact-x
- Repository: https://github.com/brilliahib/cms-impact-x

## Overview

##### Project Type and Purpose
- This is a full-stack Next.js web application (using the App Router) that implements authentication, user profiles, activity feeds, followers, and content creation.
- It leverages NextAuth for auth, custom API routes under `src/app/api`, and a React component library (Atomic-to-Organism) for the UI.

##### File Structure Analysis
- Top-level config and metadata: ESLint, Prettier, Husky, Tailwind/PostCSS, Next.js config.
- `public/`: static assets (logo, profile images).
- `src/app/`: Next.js App Router folder
- `(auth)`: login/register layouts & pages
- `(apps)`: authenticated “app” area with sub-routes for activity, followers, profile (with nested dynamic `[username]`, edit, security).
- `api/auth/[...nextauth]/route.ts`: NextAuth endpoint
- Global layout (`layout.tsx`), root page (`page.tsx`), global CSS.
- `src/components/`: Atomic Design structure
- `atoms/`, `molecules/`, `organisms/`, `ui/` primitives
- A `GlobalProvider` for context/theme.
- `src/http/`: client-side service wrappers (activity, auth, feeds, profile) using `axios` from `src/lib/axios.ts`.
- `src/lib/`: shared utilities (`auth.ts`, `utils.ts`, HTTP client).
- `src/types/`, `src/validators/`, `src/utils/`: type definitions, input validation, helper functions.

##### Key Architectural Patterns & Technologies
- Next.js App Router (Server Components & Client Components)
- NextAuth for authentication
- Atomic Design component methodology
- API Routes for backend logic
- axios-based HTTP client + React Query / custom fetch logic (implied)
- TypeScript across layers for type safety

##### Main Components
a. Frontend
- Next.js App (Server Components & Client Components)
- Atomic UI library (atoms → molecules → organisms)
- Global Context Provider
b. Backend/API
- Next.js API Routes (`/api/auth`, other resource endpoints)
- NextAuth handler (OAuth/JWT, session callbacks)
- Business logic modules (validators, service functions)
c. Data Layer
- Database (e.g., Postgres/Mongo—implied by NextAuth adapter)
- Entities: Users, Profiles, Activities, Feeds, Followers
d. External Services
- OAuth providers (GitHub, Google, etc. if configured)
- Vercel hosting/Edge functions (deployment target)

##### Relationships & Data Flow
- User → Next.js front-end pages/components
- Components call `http/*` service functions → Axios → Next.js API routes
- API routes validate input (`validators/*`), orchestrate business logic (`lib/*`, `utils/*`), read/write to DB
- NextAuth API route → Session DB → Generates JWT/cookie → back to client

##### Architectural Highlights
- Atomic Design ensures UI reusability and separation of concerns.
- Next.js App Router separates server vs. client code.
- API Routes colocate frontend/backbone in a single repo (monorepo style).
- Shared TypeScript types (`src/types/*`) guarantee consistency across client & server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        direction TB
        NextLayout["Global Layout\n(src/app/layout.tsx)"]:::ui
        NextPage["Root Page\n(src/app/page.tsx)"]:::ui
        subgraph "Auth Pages"
            direction TB
            AuthLayout["Auth Layout\n(src/app/(auth)/layout.tsx)"]:::ui
            LoginPage["Login Page\n(src/app/(auth)/login/page.tsx)"]:::ui
            RegPage["Register Page\n(src/app/(auth)/register/page.tsx)"]:::ui
        end
        subgraph "App Pages"
            direction TB
            AppLayout["App Layout\n(src/app/(apps)/layout.tsx)"]:::ui
            ActivityPage["Activity Page\n(src/app/(apps)/activity/page.tsx)"]:::ui
            FollowersPage["Followers Page\n(src/app/(apps)/followers/page.tsx)"]:::ui
            subgraph "Profile Pages"
                direction TB
                ProfileRoot["Profile Root\n(src/app/(apps)/profile/page.tsx)"]:::ui
                ProfileOverview["Profile Overview\n(src/app/(apps)/profile/[username]/page.tsx)"]:::ui
                EditProfile["Edit Profile\n(src/app/(apps)/profile/edit/page.tsx)"]:::ui
                SecuritySettings["Security Settings\n(src/app/(apps)/profile/security/page.tsx)"]:::ui
            end
        end
        subgraph "Atomic Components"
            direction TB
            Atoms["Atoms\n(src/components/atoms/)"]:::ui
            Molecules["Molecules\n(src/components/molecules/)"]:::ui
            Organisms["Organisms\n(src/components/organisms/)"]:::ui
            UIPrimitives["UI Primitives\n(src/components/ui/)"]:::ui
            GlobalProvider["GlobalProvider\n(src/components/organisms/GlobalProvider.tsx)"]:::ui
        end
        subgraph "HTTP Services"
            direction TB
            Axios["Axios Instance\n(src/lib/axios.ts)"]:::ui
            AuthSrv["Auth Services\n(src/http/auth/)"]:::ui
            ActivitySrv["Activity Services\n(src/http/activity/)"]:::ui
            FeedsSrv["Feeds Services\n(src/http/feeds/)"]:::ui
            ProfileSrv["Profile Services\n(src/http/profile/)"]:::ui
        end
        NextLayout --> NextPage
        NextPage --> AuthLayout
        AuthLayout --> LoginPage
        AuthLayout --> RegPage
        NextPage --> AppLayout
        AppLayout --> ActivityPage
        AppLayout --> FollowersPage
        AppLayout --> ProfileRoot
        ProfileRoot --> ProfileOverview
        ProfileRoot --> EditProfile
        ProfileRoot --> SecuritySettings
        NextPage --> Atoms
        Atoms --> Molecules
        Molecules --> Organisms
        Organisms --> UIPrimitives
        UIPrimitives --> GlobalProvider
        LoginPage -->|uses| Axios
        ActivityPage -->|calls| ActivitySrv
        FollowersPage -->|calls| FeedsSrv
        ProfileOverview -->|calls| ProfileSrv
    end

    subgraph "API Layer"
        direction TB
        NextAuthRoute["NextAuth Route\n(src/app/api/auth/[...nextauth]/route.ts)"]:::api
        AuthAPI["/api/auth"]:::api
        FeedAPI["/api/feeds"]:::api
        ActivityAPI["/api/activity"]:::api
        ProfileAPI["/api/profile"]:::api
    end

    subgraph "Data Layer"
        direction TB
        DB[(Database)]:::data
        Users["User Entity"]:::data
        ProfileEntity["Profile Entity"]:::data
        ActivityEntity["Activity Entity"]:::data
        FeedEntity["Feed Entity"]:::data
        FollowersEntity["Followers Entity"]:::data
    end

    subgraph "External Services"
        direction TB
        OAuth["OAuth Providers"]:::ext
        CDN["Public CDN"]:::ext
        Vercel["Vercel Hosting"]:::ext
    end

    %% Connections
    AuthSrv -->|HTTP| NextAuthRoute
    ActivitySrv -->|HTTP| ActivityAPI
    FeedsSrv -->|HTTP| FeedAPI
    ProfileSrv -->|HTTP| ProfileAPI

    NextAuthRoute -->|adapter calls| DB
    AuthAPI -->|queries| DB
    ActivityAPI -->|queries| DB
    FeedAPI -->|queries| DB
    ProfileAPI -->|queries| DB

    DB --> Users
    DB --> ProfileEntity
    DB --> ActivityEntity
    DB --> FeedEntity
    DB --> FollowersEntity

    NextAuthRoute --> OAuth
    CDN --> NextLayout
    Vercel --> NextPage

    %% Click Events
    click NextLayout "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/layout.tsx"
    click NextPage "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/page.tsx"
    click AuthLayout "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(auth)/layout.tsx"
    click LoginPage "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(auth)/login/page.tsx"
    click RegPage "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(auth)/register/page.tsx"
    click AppLayout "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/layout.tsx"
    click ActivityPage "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/activity/page.tsx"
    click FollowersPage "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/followers/page.tsx"
    click ProfileOverview "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/profile/[username]/page.tsx"
    click EditProfile "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/profile/edit/page.tsx"
    click SecuritySettings "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/profile/security/page.tsx"
    click ProfileRoot "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/(apps)/profile/page.tsx"
    click NextAuthRoute "https://github.com/brilliahib/cms-impact-x/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click Atoms "https://github.com/brilliahib/cms-impact-x/tree/main/src/components/atoms/"
    click Molecules "https://github.com/brilliahib/cms-impact-x/tree/main/src/components/molecules/"
    click Organisms "https://github.com/brilliahib/cms-impact-x/tree/main/src/components/organisms/"
    click UIPrimitives "https://github.com/brilliahib/cms-impact-x/tree/main/src/components/ui/"
    click GlobalProvider "https://github.com/brilliahib/cms-impact-x/blob/main/src/components/organisms/GlobalProvider.tsx"
    click Axios "https://github.com/brilliahib/cms-impact-x/blob/main/src/lib/axios.ts"
    click AuthSrv "https://github.com/brilliahib/cms-impact-x/tree/main/src/http/auth/"
    click ActivitySrv "https://github.com/brilliahib/cms-impact-x/tree/main/src/http/activity/"
    click FeedsSrv "https://github.com/brilliahib/cms-impact-x/tree/main/src/http/feeds/"
    click ProfileSrv "https://github.com/brilliahib/cms-impact-x/tree/main/src/http/profile/"

    classDef ui fill:#E0F2FE,stroke:#0369A1
    classDef api fill:#D1FAE5,stroke:#065F46
    classDef data fill:#FEF3C7,stroke:#B45309
    classDef ext fill:#E5E7EB,stroke:#6B7280
```
