# is-nao/portfolio-nuxt architecture

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

- Interactive diagram: https://gitdiagram.com/is-nao/portfolio-nuxt
- Repository: https://github.com/is-nao/portfolio-nuxt

## Overview

##### Project type and purpose
- This is a full-stack, edge-deployed Nuxt 3 application scaffolded for NuxtHub on Cloudflare (or any edge platform).
- Purpose:
- Frontend SPA/SSR using app/ (Nuxt 3’s app directory).
- Backend HTTP APIs and server middleware under server/ for images, messages, redirects.
- Integrates with NuxtHub storage primitives (hubBlob, hubDatabase, hubKV) and cachedEventHandler.

##### File structure
- Top-level directories:
- app/ – Vue single-file components (pages and reusable components).
- server/ – API handlers (server/api) and route handlers (server/routes), plus middleware.
- docker/ & compose.yaml – containerization.
- Key config files:
- nuxt.config.ts – NuxtHub and module config.
- .github/workflows – CI/CD for nuxthub deploy.
- docker/nuxt.Dockerfile & compose.yaml – local/container dev.
- Patterns:
- Nuxt 3 file-based routing (app/pages, server/api).
- Separation of concerns: UI, API, storage, caching.

##### Extract insights from README
- Uses hubBlob() for image uploads.
- Uses hubDatabase() for persisting chat messages.
- Uses hubKV() for storing redirect mappings.
- Uses cachedEventHandler() to cache arbitrary API responses.
- Deploys as edge functions on Cloudflare via nuxthub.

##### Main components
a. Frontend
- Nuxt 3 SSR entry point (app/pages/index.vue).
- Components: ImageGallery.vue, MessagesPanel.vue, RedirectsPanel.vue.
b. Backend/API layer
- server/api/images, server/api/messages, server/api/redirects endpoints.
- server/middleware/redirects.ts to intercept and redirect routes.
c. Storage services
- Blob store (hubBlob) for image binaries.
- Database (hubDatabase) for chat messages.
- Key-Value store (hubKV) for redirect rules.
- In-memory/cache layer via cachedEventHandler.
d. Deployment/runtime
- Edge runtime (Cloudflare Workers or similar).
- CDN/static assets (public/).
- Docker local dev environment.

##### Relationships and data flows
- Client browser ↔ Edge-deployed Nuxt 3 server (SSR + API).
- Frontend calls REST-ish APIs under /api:
- GET/POST /api/images → hubBlob
- GET/POST /api/messages → hubDatabase
- GET/PUT /api/redirects → hubKV
- server/middleware reads KV on every request to apply redirects.
- cachedEventHandler wraps selected API calls for in-edge caching.

##### Highlighted architectural patterns and principles
- File-based routing for pages and serverless functions.
- Single repo monorepo style: UI and backend in one codebase.
- Edge-first architecture: SSR and APIs run at CDN edge.
- Separation of concerns:
- UI components under app/
- API handlers under server/api/
- Domain logic for caching and middleware under server/.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Client
    subgraph "Browser / Client"
        direction TB
        Browser["Browser"]:::client
    end

    %% Edge Runtime
    subgraph "Edge Runtime (Nuxt 3)"
        direction TB

        subgraph "Frontend (Vue Components)"
            direction TB
            IndexPage["index.vue"]:::frontend
            ImageGallery["ImageGallery.vue"]:::frontend
            MessagesPanel["MessagesPanel.vue"]:::frontend
            RedirectsPanel["RedirectsPanel.vue"]:::frontend
        end

        subgraph "API Handlers (server/api)"
            direction TB
            Cached["cached.get.ts"]:::api
            ImagesList["GET /api/images"]:::api
            ImagesUpload["POST /api/images/upload"]:::api
            ImagesDelete["DELETE /api/images/:pathname"]:::api
            MessagesList["GET /api/messages"]:::api
            MessagesPost["POST /api/messages"]:::api
            RedirectsGet["GET /api/redirects"]:::api
            RedirectsPut["PUT /api/redirects"]:::api
        end

        subgraph "Middleware & Routes"
            direction TB
            RedirectMiddleware["redirects.ts"]:::api
            StaticImageRoute["[...pathname].get.ts"]:::api
        end

    end

    %% Storage Services
    subgraph "Storage Services"
        direction TB
        BlobStore["hubBlob"]:::storage
        Database["hubDatabase"]:::storage
        KVStore["hubKV"]:::storage
        Cache["cachedEventHandler"]:::storage
    end

    %% DevOps & Deployment
    subgraph "DevOps & Deployment"
        direction TB
        Config["nuxt.config.ts"]:::devops
        PublicAssets["public/"]:::devops
        Dockerfile["nuxt.Dockerfile"]:::devops
        Compose["compose.yaml"]:::devops
        CICD["nuxthub.yml"]:::devops
    end

    %% Connections
    Browser -->|requests SSR| IndexPage
    IndexPage -->|imports| ImageGallery
    IndexPage -->|imports| MessagesPanel
    IndexPage -->|imports| RedirectsPanel

    Browser -->|calls API| ImagesList
    Browser -->|calls API| ImagesUpload
    Browser -->|calls API| ImagesDelete
    Browser -->|calls API| MessagesList
    Browser -->|calls API| MessagesPost
    Browser -->|calls API| RedirectsGet
    Browser -->|calls API| RedirectsPut

    ImagesList -->|wraps with cache| Cached
    ImagesUpload --> Cached
    MessagesList --> Cached
    MessagesPost --> Cached
    RedirectsGet --> Cached
    RedirectsPut --> Cached

    Cached -->|blob ops| BlobStore
    Cached -->|db ops| Database
    Cached -->|kv ops| KVStore

    RedirectMiddleware -->|reads rules| KVStore
    StaticImageRoute -->|serves static| PublicAssets

    Config --> Edge_Runtime((Edge Runtime))
    Dockerfile -->|builds| Edge_Runtime
    Compose -->|orchestrates| Dockerfile
    CICD -->|deploys to| Edge_Runtime

    %% Click Events
    click IndexPage "https://github.com/is-nao/portfolio-nuxt/blob/main/app/pages/index.vue"
    click ImageGallery "https://github.com/is-nao/portfolio-nuxt/blob/main/app/components/ImageGallery.vue"
    click MessagesPanel "https://github.com/is-nao/portfolio-nuxt/blob/main/app/components/MessagesPanel.vue"
    click RedirectsPanel "https://github.com/is-nao/portfolio-nuxt/blob/main/app/components/RedirectsPanel.vue"
    click Cached "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/cached.get.ts"
    click ImagesList "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/images/index.get.ts"
    click ImagesUpload "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/images/upload.post.ts"
    click ImagesDelete "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/images/[pathname].delete.ts"
    click MessagesList "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/messages/index.get.ts"
    click MessagesPost "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/messages/index.post.ts"
    click RedirectsGet "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/redirects/index.get.ts"
    click RedirectsPut "https://github.com/is-nao/portfolio-nuxt/blob/main/server/api/redirects/index.put.ts"
    click RedirectMiddleware "https://github.com/is-nao/portfolio-nuxt/blob/main/server/middleware/redirects.ts"
    click StaticImageRoute "https://github.com/is-nao/portfolio-nuxt/blob/main/server/routes/images/[...pathname].get.ts"
    click Config "https://github.com/is-nao/portfolio-nuxt/blob/main/nuxt.config.ts"
    click PublicAssets "https://github.com/is-nao/portfolio-nuxt/tree/main/public/"
    click Dockerfile "https://github.com/is-nao/portfolio-nuxt/blob/main/docker/nuxt.Dockerfile"
    click Compose "https://github.com/is-nao/portfolio-nuxt/blob/main/compose.yaml"
    click CICD "https://github.com/is-nao/portfolio-nuxt/blob/main/.github/workflows/nuxthub.yml"

    %% Styles
    classDef frontend fill:#D6EAFE,stroke:#0366D6,color:#0366D6
    classDef api fill:#E6FFE6,stroke:#008000,color:#006400
    classDef storage fill:#FFE6C7,stroke:#FF8C00,color:#A0522D
    classDef devops fill:#F0F0F0,stroke:#A9A9A9,color:#696969
    classDef client fill:#F5F5F5,stroke:#808080,color:#000000
```
