# mvazquezmartin/portfolio_vsc architecture

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

- Interactive diagram: https://gitdiagram.com/mvazquezmartin/portfolio_vsc
- Repository: https://github.com/mvazquezmartin/portfolio_vsc

## Overview

##### Main Components Identification
- Client-Side (Frontend):
- HTML/CSS/SASS Layout: The root HTML file, SASS styles, and assets (CSS files like dracula.css, main styles, PDFs, audio, fonts, etc.).
- JavaScript Components: Numerous custom components under src/public/js/components (account management, chat, bookmarks, GitHub, playground, file explorer, responsive scripts, etc.). These modules interact with UI elements and make API calls to the backend.
- Server-Side (Backend):
- API Server: The Express app defined in src/index.js that wires together controllers, middleware (e.g., for authentication and file uploads), and routers (in src/router/index.js).
- Controllers: Located in src/controller – handling requests for chat, CRUD, GitHub, messages, and more.
- Service Layer: In src/service, including cache.service.js and item/message services to implement business logic.
- Data Access Objects (DAO): Multiple DAO implementations (e.g., file system, localStorage, MongoDB) in src/dao to support the Strategy Pattern for CRUD operations. This includes caching submodules (file-based JSON caches for Github and YouTube) and the strategy pattern implementation (e.g., src/dao/crud.stratagy.js).
- Configuration: In src/config, various config files for API keys (e.g., apiGoogle.js), application settings, DB configuration, and Socket settings.
- Middleware: e.g., authenticateAPI.middleware.js and upload.middleware.js to regulate API access and file uploads.

##### Relationships and Interactions
- The Frontend makes HTTP (and possibly WebSocket) calls to the backend API endpoints.
- Controllers map incoming HTTP requests to the corresponding service logic.
- The Service layer orchestrates business logic, handling tasks like caching (via cache.service.js) and executing CRUD operations.
- The DAO layer, organized using the Strategy Pattern, facilitates switching between different data persistence mechanisms (file system, localStorage, and MongoDB) during runtime.
- External APIs (GitHub and YouTube) are integrated via dedicated controllers and are optimized by caching responses in JSON files (located under src/dao/cache/file).
- Socket configurations indicate the project accommodates real-time communication (e.g., for chat features).

##### Architectural Patterns and Technical Stack
- MVC-Like Approach: Controllers (handling HTTP requests), Services (business logic), and DAOs (data persistence) suggest a clean separation of concerns.
- Strategy Pattern: Used in the CRUD operations, allowing runtime interchangeability of data persistence methods.
- Caching Mechanism: Implemented to overcome external API call limitations, using file-based JSON cache stores that update periodically.
- Frontend Component-Based Architecture: Even though this project avoids frameworks like React, it manually implements modular components that are organized by feature in the file structure.

##### Relevant Technologies and Frameworks
- Node.js and Express for server-side logic.
- Mongoose (and MongoDB) for one of the persistence layers.
- Socket.io for real-time communications.
- SASS and vanilla JavaScript (with custom components and helper libraries like SweetAlert2, HighlightJs, and MarkedJs) on the client side.
- External API integrations (GitHub and YouTube Data V3).

##### Elements
- Components and Modules:
- Frontend: UI layer, JS components (e.g., chat, bookmarks, GitHub), assets (CSS, fonts, images).
- Backend: Express server, Router, Controllers, Middleware, Service Layer, DAO Layer (with caches and persistence strategies), Config modules.
- External Services: GitHub API, YouTube API.
- Data Flows:
- Caching flows and how cached data is served (e.g., from file-based JSON caches).
- Bidirectional data flow for WebSocket communications.
- Labels:
- Clearly name each component (like “Chat Controller”, “Cache Service”, “MongoDB DAO”, “Express Router”, etc.) along with brief descriptions if necessary.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Subgraph
    subgraph "Frontend"
        FL["HTML/CSS/SASS Layout"]:::frontend
        JC["JavaScript Components"]:::frontend
        Chat["Chat Component"]:::frontend
        BM["Bookmarks Component"]:::frontend
        GH["GitHub Integration Component"]:::frontend
        CP["Code Playground Component"]:::frontend
        FE["Simulated File Explorer Component"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend"
        EA["Express API Server"]:::backend
        AR["API Router"]:::backend
        CT["Controllers"]:::backend
        SV["Service Layer"]:::backend
        DA["DAO Layer"]:::backend
        CF["Configuration"]:::backend
        MW["Middleware"]:::backend
        WS["WebSocket Server"]:::backend
    end

    %% External APIs Subgraph
    subgraph "External APIs"
        GHA["GitHub API"]:::external
        YTA["YouTube API"]:::external
    end

    %% Connections from Frontend to Backend
    FL -->|"loads"| JC
    JC -->|"HTTP/WebSocket requests"| EA
    EA -->|"routes"| AR
    AR -->|"calls"| CT
    CT -->|"invokes"| SV
    SV -->|"performs CRUD"| DA
    EA -->|"uses"| MW
    EA -->|"loads"| CF
    WS <-->|"real-time comms"| JC

    %% Controllers interacting with External APIs
    CT -->|"fetches"| GHA
    CT -->|"fetches"| YTA

    %% Styles
    classDef frontend fill:#A6CEE3,stroke:#1F78B4,stroke-width:2px;
    classDef backend fill:#B2DF8A,stroke:#33A02C,stroke-width:2px;
    classDef external fill:#FB9A99,stroke:#E31A1C,stroke-width:2px;

    %% Click Events for Frontend Components
    click FL "https://github.com/mvazquezmartin/portfolio_vsc/blob/main/src/public/index.html"
    click JC "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components"
    click Chat "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components/chat"
    click BM "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components/bookmarks"
    click GH "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components/github"
    click CP "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components/playground"
    click FE "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/public/js/components/explorerSideBar"

    %% Click Events for Backend Components
    click EA "https://github.com/mvazquezmartin/portfolio_vsc/blob/main/src/index.js"
    click AR "https://github.com/mvazquezmartin/portfolio_vsc/blob/main/src/router/index.js"
    click CT "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/controller"
    click SV "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/service"
    click DA "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/dao"
    click CF "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/config"
    click MW "https://github.com/mvazquezmartin/portfolio_vsc/tree/main/src/middlewares"
```
