# philip2death/it-hosting architecture

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

- Interactive diagram: https://gitdiagram.com/philip2death/it-hosting
- Repository: https://github.com/philip2death/it-hosting

## Overview

##### Project Type and Purpose
- This is a full-stack web application template (“IT Hosting Platform”) built with Next.js 15 App Router, Tailwind CSS v4, Turbopack, Prisma, and NextAuth.
- It provides user-facing pages (marketing, docs, dashboard) plus a suite of server/API routes for authentication, user management, support tickets, and settings.

##### Main Architectural Layers & Components
a. Client Layer (Browser)
- React UI components under src/app and src/components
- Tailwind CSS for styling
- Client-side state/hooks (e.g., SessionProviderWrapper)
b. Frontend / Edge Layer (Next.js App Router)
- Page routes (src/app/**/page.tsx) rendered server-side or statically
- API routes (src/app/api/**/route.ts) implemented as serverless functions
- NextAuth middleware in src/app/api/auth/[...nextauth]
c. Business / Domain Layer
- Route handlers (login, register, profile, settings, support-ticket) contain orchestration logic
- src/lib for shared utilities:
– prisma.ts (Prisma Client instantiation)
– security/env-check.ts (environment validation)
d. Data Layer
- Prisma ORM connected to a PostgreSQL (or MySQL) database
- Database schema and migrations under prisma/
- supabaseClient.js for optional direct Supabase interactions
e. External Services & Infrastructure
- NextAuth providers (OAuth, email, etc.)
- Supabase (optional storage/real-time service)
- Vercel (hosting/deployment)
- GitHub Actions & Playwright for CI/CD & E2E testing

##### Relationships and Data Flows
- User’s browser ↔ Next.js pages (HTTP/HTTPS)
- Next.js page/server code → API routes (internal fetch)
- API routes → Prisma Client → Database (SQL)
- NextAuth route ↔ Auth provider or credentials store
- supabaseClient ↔ Supabase REST/Realtime API
- CI/CD pipeline: GitHub Actions → build/test → deploy to Vercel

##### Architectural Patterns & Design Principles
- Layered architecture: presentation, API/business logic, data access
- Serverless functions for each API endpoint (One-to-one mapping: file-based API routing)
- Atomic CSS with Tailwind (no proprietary CSS architecture needed)
- Prisma migrations ensure schema versioning (declarative infra as code)
- App Router organizes code by route rather than by type

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers Top to Bottom
    subgraph "Browser (Client Layer)"
        Browser["Browser<br/>(src/app/, src/components/)"]:::frontend
        click Browser "https://github.com/philip2death/it-hosting/tree/main/src/app/"
    end

    subgraph "Next.js App Router"
        subgraph "Pages"
            Pages["Page Routes<br/>(src/app/**/page.tsx)"]:::backend
            click Pages "https://github.com/philip2death/it-hosting/tree/main/src/app/"
        end
        subgraph "API Routes"
            LoginApi["/api/login<br/>(route.ts)"]:::backend
            click LoginApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/login/route.ts"
            RegisterApi["/api/register<br/>(route.ts)"]:::backend
            click RegisterApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/register/route.ts"
            ProfileApi["/api/profile<br/>(route.ts)"]:::backend
            click ProfileApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/profile/route.ts"
            SettingsAccountApi["/api/settings/account<br/>(route.ts)"]:::backend
            click SettingsAccountApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/settings/account/route.ts"
            SettingsPasswordApi["/api/settings/password<br/>(route.ts)"]:::backend
            click SettingsPasswordApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/settings/password/route.ts"
            SupportApi["/api/support-ticket<br/>(route.ts)"]:::backend
            click SupportApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/support-ticket/route.ts"
            UserApi["/api/user<br/>(route.ts)"]:::backend
            click UserApi "https://github.com/philip2death/it-hosting/blob/main/src/app/api/user/route.ts"
        end
    end

    subgraph "Business / Domain Layer"
        PrismaClient["prisma.ts<br/>(Prisma Client)"]:::backend
        click PrismaClient "https://github.com/philip2death/it-hosting/blob/main/src/lib/prisma.ts"
        EnvCheck["env-check.ts<br/>(Env Validation)"]:::backend
        click EnvCheck "https://github.com/philip2death/it-hosting/blob/main/src/lib/security/env-check.ts"
    end

    subgraph "Data Layer"
        Schema["schema.prisma"]:::database
        click Schema "https://github.com/philip2death/it-hosting/blob/main/prisma/schema.prisma"
        Migrations["prisma/migrations/..."]:::database
        click Migrations "https://github.com/philip2death/it-hosting/tree/main/prisma/migrations/"
        DB["PostgreSQL<br/>(Prisma)"]:::database
    end

    subgraph "External Services"
        NextAuth["NextAuth<br/>([...nextauth]/route.ts)"]:::external
        click NextAuth "https://github.com/philip2death/it-hosting/blob/main/src/app/api/auth/[...nextauth]/route.ts"
        AuthConfig["auth.ts<br/>(NextAuth Config)"]:::external
        click AuthConfig "https://github.com/philip2death/it-hosting/blob/main/src/config/auth.ts"
        SupabaseClient["supabaseClient.js"]:::external
        click SupabaseClient "https://github.com/philip2death/it-hosting/blob/main/src/supabaseClient.js"
        Supabase["Supabase API"]:::external
    end

    subgraph "CI/CD & Deployment"
        GH_CI["GitHub Actions<br/>(ci.yml)"]:::ci
        click GH_CI "https://github.com/philip2death/it-hosting/blob/main/.github/workflows/ci.yml"
        GH_Playwright["Playwright Workflow<br/>(playwright.yml)"]:::ci
        click GH_Playwright "https://github.com/philip2death/it-hosting/blob/main/.github/workflows/playwright.yml"
        Vercel["Vercel Deployment<br/>(vercel.json)"]:::ci
        click Vercel "https://github.com/philip2death/it-hosting/blob/main/vercel.json"
    end

    %% Data Flows
    Browser -->|HTTP/HTTPS| Pages
    Pages -->|Internal Fetch| LoginApi
    Pages -->|Internal Fetch| RegisterApi
    Pages -->|Internal Fetch| ProfileApi
    Pages -->|Internal Fetch| SettingsAccountApi
    Pages -->|Internal Fetch| SettingsPasswordApi
    Pages -->|Internal Fetch| SupportApi
    Pages -->|Internal Fetch| UserApi

    LoginApi -->|calls| PrismaClient
    RegisterApi -->|calls| PrismaClient
    ProfileApi -->|calls| PrismaClient
    SettingsAccountApi -->|calls| PrismaClient
    SettingsPasswordApi -->|calls| PrismaClient
    SupportApi -->|calls| PrismaClient
    UserApi -->|calls| PrismaClient

    PrismaClient -->|SQL Queries| DB
    EnvCheck -->|validates env| PrismaClient

    %% External Interactions
    LoginApi -->|auth flow| NextAuth
    NextAuth -->|uses config| AuthConfig
    Browser -->|SDK| SupabaseClient
    SupabaseClient -->|REST/Realtime| Supabase

    %% CI/CD
    GH_CI -.->|runs tests| GH_Playwright
    GH_CI -.->|build & deploy| Vercel

    %% Styles
    classDef frontend fill:#bae8ff,stroke:#0366d6,color:#0366d6
    classDef backend fill:#d4f9d8,stroke:#21bf73,color:#196f3d
    classDef database fill:#ffe5b4,stroke:#ff9f43,color:#cc5500
    classDef external fill:#e0b3ff,stroke:#9b59b6,color:#6c3483
    classDef ci fill:#f0f0f0,stroke:#95a5a6,color:#7f8c8d
```
