# arian81/portfolio architecture

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

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

## Overview

##### Project Overview & Type
- The project is a personal website built with the T3 Stack (primarily Next.js, TypeScript, and TailwindCSS). It integrates components for displaying a blog, projects, and a resume.
- Additionally, the project uses Sanity as a headless CMS (visible in the sanity directory with schemas and client configuration) and includes a dedicated resume generation system (with LaTeX and resume sections).

##### Key Components
a. Client/Browser:
- Represents the end users visiting the website (arian.gg).
- Initiates requests which flow to the Next.js frontend.

b. Next.js Frontend:
- Pages & Routing: Located in the src/pages directory and hosting pages like index, blog, resume, projects, etc. Also includes API endpoints under src/pages/api.
- Components & UI: The src/components folder holds the React components (e.g., Header, Footer, Layout, blog & resume components) which make up the visual interface.
- Styling: TailwindCSS and additional CSS files in src/styles.

c. API / Serverless Functions:
- Found under src/pages/api (e.g., lc.tsx and og.tsx) providing backend utilities for dynamic content or image generation.
- Acts as a serverless layer within the Next.js environment.

d. Sanity CMS Integration:
- Managed in the sanity directory (sanity.config.ts, sanity.cli.ts, schemas). Contains schemas for blog posts, projects, technologies, etc.
- Responsible for storing and serving dynamic content that is consumed by the frontend.
- The sanity/lib contains client and image-handling utilities, demonstrating abstraction for external data retrieval.

e. Resume Generation System:
- The resume directory holds LaTeX source files, styling, and built PDFs.
- The scripts folder (scripts/generate-resume-data.ts) indicates a build/automation process for generating or updating resume data. It suggests the resume information might be dynamically extracted and rendered.

f. Public Assets & External Resources:
- The public folder holds static assets (images, site manifest, and other media files) delivered directly to the client.
- External visual assets and logos are used throughout the components (found in src/logos and src/lotties for animations).

##### Relationships and Data Flow
- Users (Browsers) request the website, and the Next.js frontend responds with static and server-rendered pages.
- The frontend communicates with the Sanity CMS to retrieve content via the configured client in the sanity/lib.
- API routes in the Next.js application (serverless functions) handle auxiliary tasks such as dynamic image generation or other data fetching.
- The resume generation system uses static LaTeX files and custom scripts to output a downloadable PDF resume, which is then served as part of the website’s content.
- Deployment is managed via Vercel (as evidenced by the vercel.json), which orchestrates build commands, API endpoint execution, and frontend rendering.

##### Architectural Patterns & Design Principles
- Separation of Concerns: The project divides its functionality between user interface (Next.js pages and React components), content management (Sanity CMS), and specialized resume processing (LaTeX and custom scripts).
- Component-driven Design: The extensive use of React components under src/components indicates a reusable, modular UI architecture.
- Serverless Pattern: Next.js API routes implement serverless functions enhancing scalability and reducing the need for a dedicated backend server.

##### Additional Elements
- Configuration and Deployment: Briefly include blocks representing the build/deployment process (notably PNPM commands, Vercel deployment, and configuration files like next.config.mjs, tsconfig.json, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    client["Client/Browser (Users)"]:::frontend

    %% Next.js Frontend Subgraph
    subgraph "Next.js Frontend"
        pages["Pages & Routing: Next.js Pages"]:::frontend
        comp["Components & UI: React Components"]:::frontend
        styling["TailwindCSS & CSS Styling"]:::frontend
    end

    %% API / Serverless Functions
    api["API / Serverless Functions"]:::backend

    %% Sanity CMS Integration Subgraph
    subgraph "Sanity CMS Integration"
        sanConfig["Sanity Config/CLI"]:::cms
        sanClient["Sanity Client Utilities"]:::cms
        sanImage["Sanity Image Utilities"]:::cms
        sanSchemas["Sanity Schemas"]:::cms
    end

    %% Resume Generation System Subgraph
    subgraph "Resume Generation System"
        resumeLatex["Resume LaTeX Sources"]:::resume
        resumeScript["Resume Automation Script"]:::resume
    end

    %% Public & External Assets Subgraph
    subgraph "Public & External Assets"
        static["Static Assets"]:::assets
        logos["Logos"]:::assets
        lotties["Animations"]:::assets
    end

    %% Deployment Node
    deploy["Deployment (Vercel)"]:::deployment

    %% Connections / Data Flow
    client --> pages
    pages -->|"calls"| api
    pages -->|"retrievesContent"| sanClient
    pages -->|"displayResume"| resumeLatex
    pages -->|"loadsAssets"| static
    styling --> comp
    api --> pages
    deploy -->|"buildDeploy"| pages
    resumeScript -->|"generatesPDF"| resumeLatex
    sanConfig --> sanClient
    sanConfig --> sanSchemas
    sanImage --> sanClient
    sanClient -->|"sendsContent"| comp
    logos -->|"renderLogo"| comp
    lotties -->|"renderAnimation"| comp

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef cms fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef resume fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef assets fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events
    click client "https://github.com/arian81/portfolio/tree/main/public/"
    click pages "https://github.com/arian81/portfolio/tree/main/src/pages"
    click comp "https://github.com/arian81/portfolio/tree/main/src/components"
    click styling "https://github.com/arian81/portfolio/tree/main/src/styles"
    click api "https://github.com/arian81/portfolio/tree/main/src/pages/api"
    click sanConfig "https://github.com/arian81/portfolio/blob/main/sanity.config.ts"
    click sanClient "https://github.com/arian81/portfolio/blob/main/sanity/lib/client.ts"
    click sanImage "https://github.com/arian81/portfolio/blob/main/sanity/lib/image.ts"
    click sanSchemas "https://github.com/arian81/portfolio/tree/main/sanity/schemas"
    click resumeLatex "https://github.com/arian81/portfolio/tree/main/resume"
    click resumeScript "https://github.com/arian81/portfolio/blob/main/scripts/generate-resume-data.ts"
    click static "https://github.com/arian81/portfolio/tree/main/public/"
    click logos "https://github.com/arian81/portfolio/tree/main/src/logos"
    click lotties "https://github.com/arian81/portfolio/tree/main/src/lotties"
```
