# benjanavarro/portfolio-fresh architecture

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

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

## Overview

##### Project Type and Purpose
- This is a Fresh-based web application running on the Deno runtime.
- The app is essentially a personal/portfolio website featuring multiple interactive “islands” (components that hydrate on the client).
- It uses server-side rendering for initial page loads and client hydration for specific interactive parts. There is a small API route (`/api/joke`) but no heavy back-end service or external database.

##### File Structure Analysis
Top-level:
- `main.ts` – entry point where the Fresh server is started.
- `fresh.config.ts` & `deno.json` – configuration for Fresh and Deno tasks.
- `routes/` – page definitions and API endpoints.
- `islands/` – interactive UI components that hydrate on the client.
- `context/`, `hooks/`, `utils/`, `types.d.ts` – application logic, state management (languageContext), validation, dictionaries.
- `static/` – static assets (CSS, PDF resume).
- `tailwind.config.ts` – styling framework configuration.
- CI/CD: `.github/workflows/deploy.yml` defines automated deploy.

##### Key Architectural Insights
- Fresh on Deno provides built-in routing, server-side rendering (SSR), and island-based hydration.
- Separation of concerns:
– Server layer: routing, SSR, API endpoints.
– Presentation layer: `routes` for full-page rendering, `components` for pure UI, `islands` for client interactivity.
– Shared logic: `context`, `hooks`, `utils` covering internationalization, event handling, validation.
- Deployment is likely to an edge environment (Deno Deploy or similar) using GitHub Actions.

a. Main Components
1. Deno Runtime & Fresh Framework
2. Router & SSR Engine (`routes/` folder)
3. Page Components (e.g. `routes/index.tsx`, `_app.tsx`, `_404.tsx`)
4. Island Components (interactive parts in `islands/`)
5. Shared Component Library (`components/`)
6. Context & Hooks (`context/`, `hooks/`)
7. Utilities (`utils/`, `types.d.ts`)
8. Static Assets (`static/`)
9. API Endpoint (`routes/api/joke.ts`)
10. Tailwind/Styling layer

b. Relationships and Data Flow
- Client Browser → HTTP Request → Deno/Fresh Router
– Router matches path → SSR renders Page Component tree (pulling in `components`, `utils`, `context`).
– Islands are marked for client hydration but rendered server side first.
- Deno → sends HTML + CSS link + client JS bundle → Browser
- Browser → hydrates specified Island Components asynchronously
- Island Components can call back to API Endpoint (`/api/joke`) or use hooks/contexts for state
- Static Assets served directly by Fresh under `/static/`

c. Architectural Patterns
- Island Architecture: SSR with selective hydration
- Component-based UI library (React-style / Preact)
- Context API for global state (language selection)
- Utility modules for JSON dictionaries, form validation, skill data

d. Key Technologies/Frameworks
- Deno (runtime)
- Fresh (framework)
- Preact (underlying UI)
- TailwindCSS (styling)
- TypeScript
- GitHub Actions (CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Server-Side Layer
    subgraph "Server-Side" 
        direction TB
        Deno["Deno Runtime & Fresh Framework"]:::server
        Router["Router & SSR Engine\n(routes/)"]:::server
    end

    %% Page Components
    subgraph "Page Components" 
        direction TB
        Index["index.tsx"]:::server
        AppFile["_app.tsx"]:::server
        NotFound["_404.tsx"]:::server
    end

    %% API Endpoint
    API["API Endpoint\n/api/joke"]:::server

    %% Shared Logic
    subgraph "Shared Logic" 
        direction TB
        Components["components/"]:::shared
        Context["context/\nhooks/"]:::shared
        Utils["utils/ & types.d.ts"]:::shared
    end

    %% Client-Hydrated Islands
    subgraph "Client-Hydrated Islands" 
        direction TB
        Island404["404Button.tsx"]:::client
        IslandAbout["About.tsx"]:::client
        IslandContact["Contact.tsx"]:::client
        IslandExperience["Experience.tsx"]:::client
        IslandMainLand["MainLand.tsx"]:::client
        IslandNavbar["Navbar.tsx"]:::client
        IslandStart["Start.tsx"]:::client
    end

    %% Static Assets & Styling
    subgraph "Assets & Styling" 
        direction TB
        Static["static/"]:::assets
        Tailwind["tailwind.config.ts"]:::assets
    end

    %% CI/CD
    CI["GitHub Actions\n.deploy.yml"]:::ci

    %% Data Flows
    ClientBrowser["Client Browser"]:::client
    ClientBrowser -->|"HTTP Request"| Router
    Router -->|"SSR Render"| Index
    Router --> AppFile
    Router --> NotFound
    Index --> Components
    Index --> Context
    Index --> Utils
    AppFile --> Components
    NotFound --> Components
    Router --> API
    Router --> Static
    Static -->|"Serve CSS/PDF"| ClientBrowser
    Tailwind -->|"Used by SSR & Client"| Components

    Index -->|"includes Islands"| Island404
    Index --> IslandAbout
    Index --> IslandContact
    Index --> IslandExperience
    Index --> IslandMainLand
    Index --> IslandNavbar
    Index --> IslandStart

    ClientBrowser -->|"hydrates"| Island404
    ClientBrowser --> IslandAbout
    ClientBrowser --> IslandContact
    ClientBrowser --> IslandExperience
    ClientBrowser --> IslandMainLand
    ClientBrowser --> IslandNavbar
    ClientBrowser --> IslandStart

    Island404 -->|"fetch /api/joke"| API
    IslandAbout --> API
    IslandContact --> API
    IslandExperience --> API
    IslandMainLand --> API
    IslandNavbar --> API
    IslandStart --> API

    Deno --> Router
    CI --> Deno

    %% Click Events
    click Deno "https://github.com/benjanavarro/portfolio-fresh/blob/master/main.ts"
    click Deno "https://github.com/benjanavarro/portfolio-fresh/blob/master/fresh.config.ts"
    click Deno "https://github.com/benjanavarro/portfolio-fresh/blob/master/deno.json"
    click Router "https://github.com/benjanavarro/portfolio-fresh/tree/master/routes/"
    click Index "https://github.com/benjanavarro/portfolio-fresh/blob/master/routes/index.tsx"
    click AppFile "https://github.com/benjanavarro/portfolio-fresh/blob/master/routes/_app.tsx"
    click NotFound "https://github.com/benjanavarro/portfolio-fresh/blob/master/routes/_404.tsx"
    click API "https://github.com/benjanavarro/portfolio-fresh/blob/master/routes/api/joke.ts"
    click Island404 "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/404Button.tsx"
    click IslandAbout "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/About.tsx"
    click IslandContact "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/Contact.tsx"
    click IslandExperience "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/Experience.tsx"
    click IslandMainLand "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/MainLand.tsx"
    click IslandNavbar "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/Navbar.tsx"
    click IslandStart "https://github.com/benjanavarro/portfolio-fresh/blob/master/islands/Start.tsx"
    click Components "https://github.com/benjanavarro/portfolio-fresh/tree/master/components/"
    click Context "https://github.com/benjanavarro/portfolio-fresh/blob/master/context/languageContext.tsx"
    click Context "https://github.com/benjanavarro/portfolio-fresh/blob/master/hooks/handleClickOutside.tsx"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/Alerts.tsx"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/dictionaries.ts"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/en.json"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/es.json"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/formValidationChema.ts"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/utils/skillsSet.ts"
    click Utils "https://github.com/benjanavarro/portfolio-fresh/blob/master/types.d.ts"
    click Static "https://github.com/benjanavarro/portfolio-fresh/blob/master/static/styles.css"
    click Static "https://github.com/benjanavarro/portfolio-fresh/blob/master/static/resume.pdf"
    click Tailwind "https://github.com/benjanavarro/portfolio-fresh/blob/master/tailwind.config.ts"
    click CI "https://github.com/benjanavarro/portfolio-fresh/blob/master/.github/workflows/deploy.yml"

    %% Styles
    classDef server fill:#D0E6FF,stroke:#333,stroke-width:1px
    classDef shared fill:#E0E0E0,stroke:#333,stroke-width:1px
    classDef client fill:#D0F0D8,stroke:#333,stroke-width:1px
    classDef assets fill:#FFD8A8,stroke:#333,stroke-width:1px
    classDef ci fill:#FFE0F0,stroke:#333,stroke-width:1px
```
