# xxixiio/portfolio architecture

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

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

## Overview

##### Project Type and Purpose
- This project is a personal portfolio built with Astro Build. It integrates multiple features including a blog (with MDX posts), CMS support via TinaCMS for creating blog posts locally, multilingual support via astro-i18next, and external integrations such as a command menu (kbar) and Spotify data via API endpoints.
- The project is essentially a full-stack static site with dynamic API endpoints and an integrated CMS – though the content is pre-generated and served statically, there are runtime features (like fetching now-playing info from Spotify) and local editing capabilities.

##### Analyzing the File Structure
- Top-Level Overview:
- Configuration and environment files: .env.template, astro.config.mjs, astro-i18next.config.mjs, tsconfig.json, etc.
- Content: The “content” folder holds markdown (MDX) blog posts.
- Public assets: The “public” folder contains static assets (images, fonts, locales for translations, etc.). Notice separate directories for “admin”, “fonts”, “img”, and localization JSON files.
- Source code (src): This directory contains all the components, layouts, pages, sections, style sheets, and utility functions.
- CMS Integration: A “tina” directory contains TinaCMS configuration indicating local integration for editing blog posts.
- Architectural Reflection in the Directory:
- The “src/pages” directory organizes the application’s routing, with distinct routes for the blog, freelance, music pages, as well as a dedicated “api” folder (e.g., get-now-playing.js) that handles backend requests.
- The “src/components” directory includes presentational components (e.g., Bento components, SEO, LanguageSelector) that form the site’s UI.
- The multilingual content is safeguarded by having distinct pages for default and Spanish (“es” subfolder), and the public/locales structure complements this.

##### Reading the README for Additional Insights
- The README makes clear that the project is powered by Astro Build and employs useful external tools:
- Environment variables are required for Spotify integration.
- TinaCMS is used for in-browser post creation (running on /admin).
- External libraries like kbar (command menu) and astro-i18next (multilanguage support) are integrated.

a. Main Components:
- Static Site Generator (Astro Engine) – the core of the project generating static HTML from components, layouts, and pages.
- Content Layer – includes MDX files (blog posts) and assets from the “content” and “public” folders.
- CMS Integration – TinaCMS module running locally at “/admin” for post management.
- API Layer – Under src/pages/api, for example, the /api/get-now-playing endpoint which fetches data from Spotify.
- External Services – Spotify for now-playing information and possibly additional services used by kbar or i18next.
- Multilingual Support – Astro-i18next integration with translation JSON files in “public/locales” and separate language-specific pages.
b. Relationships and Interactions:
- The static site generator reads components, layouts, and MDX content to build pages.
- The API endpoints interface with external data sources (e.g., Spotify) and supply dynamic content.
- TinaCMS provides a local editing interface that updates the underlying content (tracked in Git) stored in the “content” folder.
- The frontend uses components to integrate with external libraries like kbar and displays multilingual content based on the routing and locale configuration.
c. Architectural Patterns and Principles:
- Separation of concerns: distinct directories for content, UI components, API endpoints, and styles.
- Directory-based routing and component grouping (e.g., “pages” vs “components”).
- Integration of third-party services (CMS, translations, external API calls) in a modular fashion.
d. Relevant Technologies:
- Astro Build, TinaCMS, astro-i18next, kbar, and standard web technologies (React components, MDX).
- Utility functions (e.g., for formatting dates, slugifying URLs) – emphasize code reusability.

- “Astro Build (Static Site Generator)”
- “Content & MDX (Blog posts & Assets)”
- “API Endpoints (Now-Playing, etc.)”
- “TinaCMS (Local CMS Admin)”
- “External Services (Spotify, etc.)”
- “Multilingual Layer (astro-i18next and locale files)”
- Data flow from API endpoints to frontend components.
- Updates from the CMS to content storage.
- How the Static Site Generator consumes both content and component code.

- For instance, mention that the “src/pages/api” endpoints call external APIs (Spotify) and that TinaCMS resides in the “tina” directory with its own configuration.
- That the “public/locales” support internationalization.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Content Layer"
        MDXPosts["MDX Posts"]:::content
        PublicAssets["Public Assets"]:::content
    end

    subgraph "CMS"
        TinaCMSConfig["TinaCMS Config"]:::cms
        AdminPanel["Admin Panel"]:::cms
    end

    subgraph "Multilingual Layer"
        i18nConfig["i18next Config"]:::multilingual
        LocaleFiles["Locale Files"]:::multilingual
        LanguagePages["Language-Specific Pages"]:::multilingual
    end

    AstroBuild["Astro Build (Static Site Generator)"]:::build
    API["API Endpoints (Now-Playing)"]:::api

    subgraph "External Services"
        SpotifyUtils["Spotify API Utils"]:::external
        EnvVars["Env Variables"]:::external
    end

    TinaCMSConfig --> MDXPosts
    AdminPanel --> MDXPosts
    MDXPosts --> AstroBuild
    PublicAssets --> AstroBuild
    i18nConfig --> AstroBuild
    LocaleFiles --> AstroBuild
    LanguagePages --> AstroBuild
    AstroBuild --> API
    API --> SpotifyUtils
    SpotifyUtils --> EnvVars

    click AstroBuild "https://github.com/xxixiio/portfolio/blob/main/astro.config.mjs"
    click MDXPosts "https://github.com/xxixiio/portfolio/tree/main/content/"
    click PublicAssets "https://github.com/xxixiio/portfolio/tree/main/public/"
    click API "https://github.com/xxixiio/portfolio/blob/main/src/pages/api/get-now-playing.js"
    click TinaCMSConfig "https://github.com/xxixiio/portfolio/tree/main/tina/"
    click AdminPanel "https://github.com/xxixiio/portfolio/tree/main/public/admin/"
    click SpotifyUtils "https://github.com/xxixiio/portfolio/tree/main/src/utils/spotify/"
    click EnvVars "https://github.com/xxixiio/portfolio/blob/main/.env.template"
    click i18nConfig "https://github.com/xxixiio/portfolio/blob/main/astro-i18next.config.mjs"
    click LocaleFiles "https://github.com/xxixiio/portfolio/tree/main/public/locales/"
    click LanguagePages "https://github.com/xxixiio/portfolio/tree/main/src/pages/es/"

    classDef cms fill:#d1f2eb,stroke:#1abc9c,stroke-width:2px;
    classDef content fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef build fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef api fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef external fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef multilingual fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
```
