# jefmonjor/portfolio architecture

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

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

## Overview

#### Purpose and Runtime
A trilingual personal portfolio and CV delivery system for Jefferson Montesdeoca. It runs on Next.js 16 App Router with TypeScript, deployed primarily to Vercel; GitHub Actions also supports Docker/SSH deployment to a VPS. Core routes live in `app/[locale]/page.tsx`, `app/[locale]/layout.tsx`, and `app/api/`.

#### Localized Portfolio Shell
Locale-prefixed pages render the portfolio, metadata, and localized navigation through next-intl. Translation catalogs and routing configuration form the language boundary for Spanish, English, and Catalan.
- `app/[locale]/layout.tsx`
- `app/[locale]/page.tsx`
- `i18n/routing.ts`
- `messages/en.json`

#### Portfolio Presentation Layer
The UI is assembled as portfolio sections with shared providers, shadcn primitives, theme support, animation, and optional progressive 3D presentation. Interactive features—including command palette, terminal, project dialogs, and assistant—remain client-facing components, while profile facts are centralized rather than duplicated in views.
- `components/portfolio/hero.tsx`
- `components/portfolio/projects.tsx`
- `components/portfolio/terminal/terminal.tsx`
- `components/background-provider.tsx`

#### Canonical Profile and Content Boundary
Structured profile data is the common source for the web portfolio, assistant dossier, machine-readable CV outputs, and PDF rendering. This boundary prevents generated or UI-specific copies from becoming authoritative.
- `lib/profile.ts`
- `types/profile.ts`
- `types/cv.ts`
- `lib/assistant/dossier.ts`

#### AI Assistant and Consumption Controls
The assistant API accepts bounded conversation input, grounds responses in a closed public dossier, and calls OpenAI’s Responses API when `OPENAI_API_KEY` is configured. A shared IP minute/day limiter and global daily budget govern AI endpoints; without a key, the portfolio remains operational with a fallback contact path.
- `app/api/assistant/route.ts`
- `lib/assistant/messages.ts`
- `lib/assistant/dossier.ts`
- `lib/assistant/rate-limit.ts`

#### CV Generation and Tailoring Pipeline
CV endpoints expose synchronized Markdown, MAC JSON, and on-demand PDFs. The tailoring endpoint accepts a job offer but constrains OpenAI Structured Outputs to canonical terms and projects; server code validates selections, constructs verified content, and renders the PDF without trusting model-authored browser content.
- `app/api/cv-tailor/route.ts`
- `app/cv.pdf/route.tsx`
- `server/cv/tailoring.ts`
- `server/cv/render.tsx`

#### Public Discovery and Service Interfaces
Route handlers publish machine-readable CV representations and crawler-oriented content, while localized metadata and structured data support SEO/GEO. tRPC is available as a typed server boundary, currently rooted around health functionality.
- `app/cv.md/route.ts`
- `app/cv.json/route.ts`
- `app/llms.txt/route.ts`
- `app/api/trpc/[trpc]/route.ts`
- `server/root.ts`

#### Infrastructure and External Dependencies
OpenAI is the only required external runtime integration for AI features. PDFs are server-rendered with `@react-pdf/renderer`; optional Three.js/WebGL is loaded only after compatible interaction. Deployment configuration is split between Vercel-oriented application deployment and a Docker image plus SSH workflow for VPS delivery.
- `Dockerfile`
- `.github/workflows/ci.yml`
- `.github/workflows/deploy.yml`
- `next.config.mjs`

Main entry points: [`lib/profile.ts`](https://github.com/jefmonjor/portfolio/blob/main/lib/profile.ts) (Canonical profile), [`server/cv/tailoring.ts`](https://github.com/jefmonjor/portfolio/blob/main/server/cv/tailoring.ts) (Verified tailoring), [`app/[locale]/layout.tsx`](https://github.com/jefmonjor/portfolio/blob/main/app/%5Blocale%5D/layout.tsx) (Locale layout), [`app/api/assistant/route.ts`](https://github.com/jefmonjor/portfolio/blob/main/app/api/assistant/route.ts) (Assistant endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Localized web"]
  node_locale_layout["Locale layout<br/>Next.js layout<br/>[layout.tsx]"]
  node_portfolio_page["Portfolio page<br/>Next.js page<br/>[page.tsx]"]
  node_i18n_routing["Locale routing<br/>next-intl config<br/>[routing.ts]"]
  node_translations["Translation catalog<br/>i18n messages<br/>[en.json]"]
  node_portfolio_ui["Portfolio UI<br/>client components<br/>[hero.tsx]"]
  node_background_provider["Presentation provider<br/>UI provider"]
end

subgraph group_content["Canonical content"]
  node_profile[("Canonical profile<br/>structured data<br/>[profile.ts]")]
  node_profile_types["Profile schemas<br/>TypeScript types<br/>[profile.ts]"]
end

subgraph group_ai["AI services"]
  node_assistant_api["Assistant endpoint<br/>Next.js API route<br/>[route.ts]"]
  node_assistant_dossier["Public dossier<br/>grounding data<br/>[dossier.ts]"]
  node_rate_limiter[("AI consumption limits<br/>rate limiter<br/>[rate-limit.ts]")]
  node_openai{{"OpenAI Responses API<br/>external AI"}}
end

subgraph group_cv["CV pipeline"]
  node_cv_tailor["CV tailoring endpoint<br/>Next.js API route<br/>[route.ts]"]
  node_tailoring["Verified tailoring<br/>server service<br/>[tailoring.ts]"]
  node_pdf_route["PDF CV endpoint<br/>Next.js route<br/>[route.tsx]"]
  node_cv_renderer["PDF renderer<br/>server renderer<br/>[render.tsx]"]
  node_public_cv["Public CV formats<br/>route handlers<br/>[route.ts]"]
  node_trpc["tRPC server boundary<br/>typed API<br/>[route.ts]"]
end

subgraph group_delivery["Delivery"]
  node_deployment["Vercel and VPS delivery<br/>deployment pipeline"]
end

node_i18n_routing -->|"selects locale"| node_locale_layout
node_translations -->|"localizes"| node_locale_layout
node_locale_layout -->|"wraps"| node_portfolio_page
node_portfolio_page -->|"renders"| node_portfolio_ui
node_background_provider -->|"provides presentation"| node_portfolio_ui
node_profile_types -->|"types"| node_profile
node_profile -->|"supplies facts"| node_portfolio_ui
node_profile -->|"derives public context"| node_assistant_dossier
node_assistant_dossier -->|"grounds replies"| node_assistant_api
node_rate_limiter -->|"governs requests"| node_assistant_api
node_assistant_api -->|"calls when configured"| node_openai
node_profile -->|"supplies canonical terms"| node_tailoring
node_cv_tailor -->|"requests verified content"| node_tailoring
node_tailoring -->|"uses structured outputs"| node_openai
node_tailoring -->|"builds trusted CV"| node_cv_renderer
node_pdf_route -->|"renders PDF"| node_cv_renderer
node_profile -->|"serializes"| node_public_cv
node_deployment -.->|"deploys application"| node_locale_layout

click node_locale_layout "https://github.com/jefmonjor/portfolio/blob/main/app/%5Blocale%5D/layout.tsx"
click node_portfolio_page "https://github.com/jefmonjor/portfolio/blob/main/app/%5Blocale%5D/page.tsx"
click node_i18n_routing "https://github.com/jefmonjor/portfolio/blob/main/i18n/routing.ts"
click node_translations "https://github.com/jefmonjor/portfolio/blob/main/messages/en.json"
click node_portfolio_ui "https://github.com/jefmonjor/portfolio/blob/main/components/portfolio/hero.tsx"
click node_background_provider "https://github.com/jefmonjor/portfolio/blob/main/components/background-provider.tsx"
click node_profile "https://github.com/jefmonjor/portfolio/blob/main/lib/profile.ts"
click node_profile_types "https://github.com/jefmonjor/portfolio/blob/main/types/profile.ts"
click node_assistant_api "https://github.com/jefmonjor/portfolio/blob/main/app/api/assistant/route.ts"
click node_assistant_dossier "https://github.com/jefmonjor/portfolio/blob/main/lib/assistant/dossier.ts"
click node_rate_limiter "https://github.com/jefmonjor/portfolio/blob/main/lib/assistant/rate-limit.ts"
click node_cv_tailor "https://github.com/jefmonjor/portfolio/blob/main/app/api/cv-tailor/route.ts"
click node_tailoring "https://github.com/jefmonjor/portfolio/blob/main/server/cv/tailoring.ts"
click node_pdf_route "https://github.com/jefmonjor/portfolio/blob/main/app/cv.pdf/route.tsx"
click node_cv_renderer "https://github.com/jefmonjor/portfolio/blob/main/server/cv/render.tsx"
click node_public_cv "https://github.com/jefmonjor/portfolio/blob/main/app/cv.md/route.ts"
click node_trpc "https://github.com/jefmonjor/portfolio/blob/main/app/api/trpc/%5Btrpc%5D/route.ts"
click node_deployment "https://github.com/jefmonjor/portfolio/blob/main/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_locale_layout,node_portfolio_page,node_i18n_routing,node_translations,node_portfolio_ui,node_background_provider toneBlue
class node_profile,node_profile_types toneAmber
class node_assistant_api,node_assistant_dossier,node_rate_limiter,node_openai toneMint
class node_cv_tailor,node_tailoring,node_pdf_route,node_cv_renderer,node_public_cv,node_trpc toneRose
class node_deployment toneIndigo
```

## Components

### Localized web

- [Locale layout](https://github.com/jefmonjor/portfolio/blob/main/app/%5Blocale%5D/layout.tsx): Next.js layout · Provides localized metadata and navigation. · `app/[locale]/layout.tsx`
- [Portfolio page](https://github.com/jefmonjor/portfolio/blob/main/app/%5Blocale%5D/page.tsx): Next.js page · `app/[locale]/page.tsx`
- [Locale routing](https://github.com/jefmonjor/portfolio/blob/main/i18n/routing.ts): next-intl config · Defines Spanish, English, and Catalan routing. · `i18n/routing.ts`
- [Translation catalog](https://github.com/jefmonjor/portfolio/blob/main/messages/en.json): i18n messages · `messages/en.json`
- [Portfolio UI](https://github.com/jefmonjor/portfolio/blob/main/components/portfolio/hero.tsx): client components · Sections and interactive portfolio experiences. · `components/portfolio/hero.tsx`
- [Presentation provider](https://github.com/jefmonjor/portfolio/blob/main/components/background-provider.tsx): UI provider · Supplies theme, animation, and progressive background presentation. · `components/background-provider.tsx`

### Canonical content

- [Canonical profile](https://github.com/jefmonjor/portfolio/blob/main/lib/profile.ts): structured data · Single source for portfolio, CV, and assistant facts. · `lib/profile.ts`
- [Profile schemas](https://github.com/jefmonjor/portfolio/blob/main/types/profile.ts): TypeScript types · `types/profile.ts`

### AI services

- [Assistant endpoint](https://github.com/jefmonjor/portfolio/blob/main/app/api/assistant/route.ts): Next.js API route · Accepts bounded conversations and offers fallback contact without AI. · `app/api/assistant/route.ts`
- [Public dossier](https://github.com/jefmonjor/portfolio/blob/main/lib/assistant/dossier.ts): grounding data · Closed assistant context derived from public profile facts. · `lib/assistant/dossier.ts`
- [AI consumption limits](https://github.com/jefmonjor/portfolio/blob/main/lib/assistant/rate-limit.ts): rate limiter · Enforces per-IP minute/day limits and a global daily budget. · `lib/assistant/rate-limit.ts`
- **OpenAI Responses API**: external AI

### CV pipeline

- [CV tailoring endpoint](https://github.com/jefmonjor/portfolio/blob/main/app/api/cv-tailor/route.ts): Next.js API route · Constrains and validates job-specific CV selections. · `app/api/cv-tailor/route.ts`
- [Verified tailoring](https://github.com/jefmonjor/portfolio/blob/main/server/cv/tailoring.ts): server service · Builds CV content only from canonical terms and projects. · `server/cv/tailoring.ts`
- [PDF CV endpoint](https://github.com/jefmonjor/portfolio/blob/main/app/cv.pdf/route.tsx): Next.js route · `app/cv.pdf/route.tsx`
- [PDF renderer](https://github.com/jefmonjor/portfolio/blob/main/server/cv/render.tsx): server renderer · Renders trusted CV content with @react-pdf/renderer. · `server/cv/render.tsx`
- [Public CV formats](https://github.com/jefmonjor/portfolio/blob/main/app/cv.md/route.ts): route handlers · Publishes Markdown, JSON, and crawler-oriented CV content. · `app/cv.md/route.ts`
- [tRPC server boundary](https://github.com/jefmonjor/portfolio/blob/main/app/api/trpc/%5Btrpc%5D/route.ts): typed API · Typed interface currently rooted in health functionality. · `app/api/trpc/[trpc]/route.ts`

### Delivery

- [Vercel and VPS delivery](https://github.com/jefmonjor/portfolio/blob/main/Dockerfile): deployment pipeline · Vercel deployment plus Docker/SSH VPS workflow. · `Dockerfile`

## Connections

- Locale routing → Locale layout: selects locale
- Translation catalog → Locale layout: localizes
- Locale layout → Portfolio page: wraps
- Portfolio page → Portfolio UI: renders
- Presentation provider → Portfolio UI: provides presentation
- Profile schemas → Canonical profile: types
- Canonical profile → Portfolio UI: supplies facts
- Canonical profile → Public dossier: derives public context
- Public dossier → Assistant endpoint: grounds replies
- AI consumption limits → Assistant endpoint: governs requests
- Assistant endpoint → OpenAI Responses API: calls when configured
- Canonical profile → Verified tailoring: supplies canonical terms
- CV tailoring endpoint → Verified tailoring: requests verified content
- Verified tailoring → OpenAI Responses API: uses structured outputs
- Verified tailoring → PDF renderer: builds trusted CV
- PDF CV endpoint → PDF renderer: renders PDF
- Canonical profile → Public CV formats: serializes
- Vercel and VPS delivery → Locale layout: deploys application
