# fazers/portfolio architecture

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

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

## Overview

##### Main Components
- Frontend Application – Located in the “apps/web” folder. This is the Next.js application that combines React components, Tailwind CSS styling, and pages/APIs. It also includes support for MDX, global error handling, and middleware.
- API & Business Logic – The “packages/api” folder contains tRPC router definitions that serve as the core API layer.
- Authentication Module – The “packages/auth” folder provides authentication logic using NextAuth.
- Database Layer – The “packages/db” folder implements typesafe database calls using Drizzle and Supabase, including schema definitions and client configuration.
- Transactional Services – The “packages/transactional” folder manages email, SMS, and similar services for notifications or contact forms.
- UI Components – The “packages/ui” folder houses a start of a UI package that leverages shadcn-ui principles for reusable UI elements and components.
- Shared Validators – The “packages/validators” folder contains common validation logic built with zod.
- Tooling & Configurations – Directories such as “.github”, “tooling”, and various configuration files (e.g., eslint, prettier, tailwind, typescript) define the project’s development, CI/CD, and code quality processes.

##### Relationships and Interactions
- The Frontend application interacts with the API endpoints (including the tRPC router) to perform typesafe data fetching and mutations.
- The API layer uses the Authentication and Database packages. For instance, authentication middleware in the frontend might call next-auth logic in the “packages/auth” and then secure endpoints in “packages/api”.
- The Database package is a shared service that the API calls into for data persistence. Along with that, transactions and notifications are handled via the “transactional” package.
- The UI package is a shared library that the frontend directly consumes, ensuring consistent styling and component behavior across the portfolio application.
- Validators are used across both frontend forms and backend data handling to ensure data integrity.

##### Architectural Patterns and Design Principles
- Modular Monorepo Structure: Separation of concerns is achieved by isolating each domain (API, auth, db, transactional, UI, validators) into its own package.
- Full-stack Integration: The Next.js app bridges server-side rendered UI with API routes, while sharing components and business logic via reusable packages.
- Typesafety and Code Reuse: Leveraging modern TypeScript practices (shared tsconfigs in tooling) and validators ensure robust interactions between components.
- CI/CD and Tooling Integration: Configuration folders (.github, tooling) indicate automated linting, testing, and deployment quality studies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["apps/web (Next.js, React, Tailwind, MDX)"]:::frontend
        UI["packages/ui (shadcn-ui Components)"]:::shared
        VAL["packages/validators (Zod Validators)"]:::shared
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["packages/api (tRPC API)"]:::backend
        AUTH["packages/auth (NextAuth)"]:::backend
        DB["packages/db (Drizzle & Supabase)"]:::database
        TS["packages/transactional (Email/SMS Services)"]:::backend
    end

    %% Tooling & Configurations
    subgraph "Tooling & Configurations"
        TOOL_G[".github (CI/CD, Workflows)"]:::tooling
        TOOL_CONF["tooling (ESLint, Prettier, TSConfig)"]:::tooling
    end

    %% Connections between Frontend and Backend
    FE -->|"calls"| API
    FE -->|"uses"| UI
    FE -->|"validates"| VAL
    API -->|"integrates"| AUTH
    API -->|"persist-data"| DB
    API -->|"triggers"| TS
    API -->|"validates"| VAL

    %% Dashed connections for Tooling affecting components
    TOOL_G --- FE
    TOOL_G --- API
    TOOL_G --- AUTH
    TOOL_G --- DB
    TOOL_G --- TS
    TOOL_G --- UI
    TOOL_G --- VAL

    TOOL_CONF --- FE
    TOOL_CONF --- API
    TOOL_CONF --- AUTH
    TOOL_CONF --- DB
    TOOL_CONF --- TS
    TOOL_CONF --- UI
    TOOL_CONF --- VAL

    %% Styles: Colors and shapes
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#FAD7A0,stroke:#B03A2E,stroke-width:2px;
    classDef database fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef shared fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef tooling fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;

    %% Click Events for Component Mapping
    click FE "https://github.com/fazers/portfolio/tree/main/apps/web"
    click API "https://github.com/fazers/portfolio/tree/main/packages/api"
    click AUTH "https://github.com/fazers/portfolio/tree/main/packages/auth"
    click DB "https://github.com/fazers/portfolio/tree/main/packages/db"
    click TS "https://github.com/fazers/portfolio/tree/main/packages/transactional"
    click UI "https://github.com/fazers/portfolio/tree/main/packages/ui"
    click VAL "https://github.com/fazers/portfolio/tree/main/packages/validators"
    click TOOL_G "https://github.com/fazers/portfolio/blob/main/.github"
    click TOOL_CONF "https://github.com/fazers/portfolio/tree/main/tooling"
```
