# axelreid/developer-portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/axelreid/developer-portfolio
- Repository: https://github.com/axelreid/developer-portfolio

## Overview

##### Project Type & Purpose
- This is a full-stack Next.js (T3 Stack) application serving a personal portfolio (marketing site) plus an authenticated dashboard for managing feedback, certificates, projects, uploads, and users.
- Key tech: Next.js (frontend + API routes), React, tRPC (RPC-style API), NextAuth.js (authentication), Prisma (ORM/DB), Tailwind CSS, Firebase (uploads), and third-party OAuth.

##### High-Level Components
a. Client-Side (Browser)
- React/Next.js pages in `src/pages` (public site and `/dashboard` area)
- UI components in `src/components` (modals, carousels, forms, canvas, etc.)
- Styling via Tailwind (`tailwind.config.cjs`, `src/styles/globals.css`)
- Static/public assets under `public/` (3D scenes, images)
b. Next.js Server (Node.js runtime)
- Frontend rendering: SSR/SSG via Next.js pages (`_app.tsx`, `_document.tsx`)
- API layer:
◦ NextAuth routes (`/api/auth/[...nextauth].ts`) for login
◦ Custom REST endpoint for image upload (`/api/upload.ts`)
◦ tRPC router endpoint (`/api/trpc/[trpc].ts`) forwarding to your routers
c. tRPC & Business Logic
- Router definitions in `src/server/api/routers/*.ts` (projects, feedbacks, users, etc.)
- Root router in `src/server/api/root.ts`
- tRPC context, initialization in `src/server/api/trpc.ts`
d. Database & ORM
- Prisma schema in `prisma/schema.prisma`
- Database client setup in `src/server/db.ts`
- Used by tRPC resolvers & NextAuth to persist users, projects, feedback, tags, certificates
e. Authentication & Authorization
- NextAuth config in `src/server/auth.ts` (providers, sessions)
- Session handling on both client (`next-auth/react`) and server (tRPC context)
f. Storage / External Services
- Firebase or other cloud storage via `src/utils/firebase.ts` and `src/utils/uploader.ts`
- OAuth providers defined in env / NextAuth for GitHub, Google, etc.
g. Utilities & Shared Types
- Shared tRPC client in `src/utils/api.ts`
- Type definitions in `src/types/*.d.ts`
- Env variables in `src/env/*.mjs`

##### Relationships & Data Flows
- Browser → Next.js page (React)
- React UI invokes tRPC client (`src/utils/api.ts`) or NextAuth hooks → Next.js API route `/api/trpc/*` or `/api/auth/*`
- tRPC route handlers use Prisma client → Database → return data to client
- For uploads, browser sends multipart to `/api/upload` → server uses Firebase SDK → external storage → returns URL → Prisma persists metadata
- Authentication flows: Browser ↔ NextAuth routes ↔ DB for session/cookies ↔ tRPC context enforces authorization

##### Architectural Patterns & Principles
- Monolithic full-stack app but clear separation of concerns: Presentation (pages + components), Application logic (tRPC routers), Persistence (Prisma/DB)
- RPC pattern via tRPC instead of REST for type-safe end-to-end types
- Modular routing: each resource (projects, feedbacks, tags…) has its own router file
- File-based routing in Next.js for pages and API
- Environment-driven configuration (`.env.example`, `src/env/*.mjs`)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Layer 1: Client / Browser
    subgraph "Layer 1: Client / Browser"
        PAGES["Next.js Pages (src/pages)"]:::frontend
        UI["UI Components (src/components)"]:::frontend
        STYLING["Styling (Tailwind + CSS)"]:::frontend
        ASSETS["Static/Public Assets (public/)"]:::frontend
    end

    %% Layer 2: Next.js Server
    subgraph "Layer 2: Next.js Server"
        APP["_app.tsx"]:::server
        DOC["_document.tsx"]:::server
        AUTH_ROUTE["NextAuth API Route"]:::server
        UPLOAD_ROUTE["Image Upload API"]:::server
        IMG_ROUTE["Image Process API"]:::server
        TRPC_ROUTE["tRPC API Route"]:::server
    end

    %% Layer 3: Business Logic
    subgraph "Layer 3: Business Logic"
        TRPC_INIT["tRPC Init & Context"]:::server
        ROOT_ROUTER["Root tRPC Router"]:::server
        subgraph "tRPC Routers"
            PROJ["Projects Router"]:::server
            FB["Feedbacks Router"]:::server
            USR["Users Router"]:::server
            TAG["Tags Router"]:::server
            CRT["Certificates Router"]:::server
            IMG_ROUTER["Images Router"]:::server
        end
        DB_CLIENT["Database Client Setup"]:::server
        NEXTAUTH_CFG["NextAuth Config"]:::server
    end

    %% Layer 4: Services & Persistence
    subgraph "Layer 4: Services & Persistence"
        PRISMA["Prisma Schema"]:::db
        DATABASE["Relational Database"]:::db
        FIREBASE["Firebase Storage"]:::external
        UPLOADER_UTIL["Uploader Utility"]:::external
        OAUTH["OAuth Providers"]:::external
    end

    %% Utilities & Config
    subgraph "Utilities & Config"
        TRPC_CLIENT["Shared tRPC Client"]:::server
        ENV_CLIENT["Client Env Definitions"]:::server
        ENV_SERVER["Server Env Definitions"]:::server
        ENV_SCHEMA["Env Schema"]:::server
        TYPES["Type Definitions"]:::server
        STATIC_DATA["Static Data"]:::server
    end

    %% Connections
    ASSETS --> PAGES
    STYLING --> PAGES
    ENV_CLIENT --> PAGES
    STATIC_DATA --> PAGES

    PAGES --> APP
    APP --> DOC

    PAGES --> AUTH_ROUTE
    PAGES --> UPLOAD_ROUTE
    PAGES --> IMG_ROUTE
    PAGES --> TRPC_ROUTE

    UI --> TRPC_CLIENT
    UI --> AUTH_ROUTE
    TYPES --> UI

    TRPC_CLIENT --> TRPC_ROUTE
    AUTH_ROUTE --> NEXTAUTH_CFG
    NEXTAUTH_CFG --> OAUTH
    UPLOAD_ROUTE --> UPLOADER_UTIL
    IMG_ROUTE --> UPLOADER_UTIL
    UPLOADER_UTIL --> FIREBASE

    TRPC_ROUTE --> TRPC_INIT
    TRPC_INIT --> ROOT_ROUTER
    ROOT_ROUTER --> PROJ
    ROOT_ROUTER --> FB
    ROOT_ROUTER --> USR
    ROOT_ROUTER --> TAG
    ROOT_ROUTER --> CRT
    ROOT_ROUTER --> IMG_ROUTER

    PROJ --> DB_CLIENT
    FB --> DB_CLIENT
    USR --> DB_CLIENT
    TAG --> DB_CLIENT
    CRT --> DB_CLIENT
    IMG_ROUTER --> DB_CLIENT
    NEXTAUTH_CFG --> DB_CLIENT

    DB_CLIENT --> PRISMA --> DATABASE
    ENV_SERVER --> NEXTAUTH_CFG
    ENV_SERVER --> DB_CLIENT
    ENV_SERVER --> TRPC_INIT
    ENV_SCHEMA --> ENV_CLIENT
    ENV_SCHEMA --> ENV_SERVER
    TYPES --> ROOT_ROUTER
    TYPES --> TRPC_CLIENT

    %% Click Events
    click PAGES "https://github.com/axelreid/developer-portfolio/tree/main/src/pages"
    click UI "https://github.com/axelreid/developer-portfolio/tree/main/src/components"
    click STYLING "https://github.com/axelreid/developer-portfolio/blob/main/tailwind.config.cjs"
    click STYLING "https://github.com/axelreid/developer-portfolio/blob/main/src/styles/globals.css"
    click ASSETS "https://github.com/axelreid/developer-portfolio/tree/main/public/"
    click APP "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/_app.tsx"
    click DOC "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/_document.tsx"
    click AUTH_ROUTE "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/api/auth/[...nextauth].ts"
    click UPLOAD_ROUTE "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/api/upload.ts"
    click IMG_ROUTE "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/api/image.ts"
    click TRPC_ROUTE "https://github.com/axelreid/developer-portfolio/blob/main/src/pages/api/trpc/[trpc].ts"
    click TRPC_INIT "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/trpc.ts"
    click ROOT_ROUTER "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/root.ts"
    click PROJ "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/project.ts"
    click FB "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/feedbacks.ts"
    click USR "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/users.ts"
    click TAG "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/tags.ts"
    click CRT "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/certificates.ts"
    click IMG_ROUTER "https://github.com/axelreid/developer-portfolio/blob/main/src/server/api/routers/images.ts"
    click DB_CLIENT "https://github.com/axelreid/developer-portfolio/blob/main/src/server/db.ts"
    click NEXTAUTH_CFG "https://github.com/axelreid/developer-portfolio/blob/main/src/server/auth.ts"
    click PRISMA "https://github.com/axelreid/developer-portfolio/blob/main/prisma/schema.prisma"
    click FIREBASE "https://github.com/axelreid/developer-portfolio/blob/main/src/utils/firebase.ts"
    click UPLOADER_UTIL "https://github.com/axelreid/developer-portfolio/blob/main/src/utils/uploader.ts"
    click TRPC_CLIENT "https://github.com/axelreid/developer-portfolio/blob/main/src/utils/api.ts"
    click ENV_CLIENT "https://github.com/axelreid/developer-portfolio/blob/main/src/env/client.mjs"
    click ENV_SERVER "https://github.com/axelreid/developer-portfolio/blob/main/src/env/server.mjs"
    click ENV_SCHEMA "https://github.com/axelreid/developer-portfolio/blob/main/src/env/schema.mjs"
    click TYPES "https://github.com/axelreid/developer-portfolio/tree/main/src/types/"
    click STATIC_DATA "https://github.com/axelreid/developer-portfolio/blob/main/src/static/index.ts"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#8FBC8F,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
