# shashank-sharma/nenspace architecture

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

- Interactive diagram: https://gitdiagram.com/shashank-sharma/nenspace
- Repository: https://github.com/shashank-sharma/nenspace

## Overview

##### Project Type and Purpose
- This project is a personal dashboard application that aggregates data generated on a machine and displays it on a unified interface.
- The README explains that the backend is built with Go using Pocketbase as the framework (to extend API features) and the frontend is a static Svelte app built with Bun and using shadcn-svelte components.
- Additional supporting systems (e.g., Grafana, Prometheus, migrations, and internal services) indicate that the application is designed to not only serve data via its dashboard but also monitor, process, and interact with various data sources.

##### File Structure to Identify Major Components
- Top-Level Components:
– Backend: Contains the command-line entry point (cmd/dashboard), internal services (services, routes, models, middleware, etc.), migrations, and configuration files.
– Frontend: A Svelte application with a rich set of components (UI, features, routes) that handles the visualization and interaction aspects.
– Grafana & Prometheus: These directories show that the project includes monitoring and metric collection capabilities.
– Docker, GitHub workflows, and orchestration files like docker-compose.yaml and container-dev.yaml indicate containerization and CI/CD processes.
- Key Architectural Patterns:
– The backend uses a modular Go architecture with clearly separated layers (API routes, services, internal models, and database interaction) resembling MVC or a service-oriented design.
– The frontend follows a component-based architecture (with routes and UI libraries) seen in modern Svelte applications.
– The integration of internal services (workflow engines, AI services, calendar, container management, etc.) highlights a microservice-esque internal design, albeit contained within a monorepo.

– Frontend: Represent the Svelte-based static site.
- Subcomponents such as UI components, routing (indicating pages like dashboard, auth, settings), and library usage of shadcn-svelte.
– Backend Service: Represent the Go-based API server (command found in cmd/dashboard).
- That it extends Pocketbase APIs.
- Subcomponents from the internal directory (models, routes, services, middleware, cronjobs, and stores).
– Monitoring & Metrics: Represent Grafana and Prometheus as separate external monitoring components.
– Database/Persistent Storage: Though not explicitly a separate folder, note that Pocketbase typically provides a built-in database or persistent layer.
– External Integrations: Identify connections to external systems (e.g., Mail services, Workflow connectors, AI services, and container-related operations) from the internal/services directories.
– CI/CD and Deployment: Optionally include deployment pipelines (GitHub workflows, Dockerfile, docker-compose) as part of the overall ecosystem.

b. Relationships and Interactions:
– Show how the backend interacts with internal services (e.g., for authentication, mail, tasks, workflow, and notifications).
– Indicate flows between internal modules: for example, the data flow from models to routes through middleware and services.
– Optionally, include CI/CD pipelines feeding into deployment containers.

c. Architectural Patterns & Design Principles:
– Emphasize separation of concerns: clear demarcation between frontend and backend.
– Highlight modularity in backend architecture via discrete “internal” modules (services, routes, models).
– Indicate the use of API abstractions as the central communication mechanism between frontend and backend.
– If applicable, show use of container orchestration (Docker) and how CI/CD is configured via GitHub Actions.

d. Relevant Technologies, Frameworks, or Libraries:
– Frontend: Svelte, Bun, shadcn-svelte, Node v20.11.1.
– Backend: Go, Pocketbase (extended through custom API development), with additional standard Go modules.
– Monitoring: Grafana, Prometheus.
– Infrastructure: Docker, docker-compose, GitHub Actions for deployment.

##### Instructing the Principal Software Engineer
– Use clear labels for each block such as “Frontend (Svelte App)”, “Backend API Server (Go + Pocketbase)”, “Internal Services”, “Monitoring (Grafana/Prometheus)”, and “Deployment Pipeline”.
– Keep in mind that simplicity is key—don’t overcomplicate but ensure that all critical components and their interactions are captured.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend (Svelte App)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BE["Backend API Server (Go + Pocketbase)"]:::backend
        %% Core Modules within Backend
        subgraph "Core Modules"
            M["Models"]:::module
            R["Routes"]:::module
            MW["Middleware"]:::module
        end
        %% Internal Services within Backend
        subgraph "Internal Services"
            MS["Mail Service"]:::module
            WS["Workflow Service"]:::module
            CM["Container Management"]:::module
            NS["Notifications"]:::module
            AI["AI Service"]:::module
        end
        MIG["Migrations"]:::backend
    end

    %% Monitoring & Metrics
    subgraph "Monitoring & Metrics"
        MP["Prometheus"]:::monitoring
        GF["Grafana"]:::monitoring
    end

    %% CI/CD and Deployment Pipeline
    subgraph "CI/CD Pipeline"
        CW["GitHub Workflows"]:::cicd
        DF["Dockerfile"]:::cicd
        DCY["docker-compose.yaml"]:::cicd
        CDY["container-dev.yaml"]:::cicd
    end

    %% Connections
    FE -->|"APIcalls"| BE
    BE --> M
    BE --> R
    BE --> MW
    BE --> MS
    BE --> WS
    BE --> CM
    BE --> NS
    BE --> AI
    BE -->|"migrate"| MIG
    BE -->|"sendsMetrics"| MP
    MP -->|"visualizes"| GF
    CW -->|"deploys_to"| FE
    CW -->|"deploys_to"| BE
    DF -->|"builds"| BE
    DCY -->|"orchestrates"| BE
    CDY -->|"orchestrates"| BE

    %% Click Events
    click FE "https://github.com/shashank-sharma/nenspace/tree/main/frontend/"
    click BE "https://github.com/shashank-sharma/nenspace/tree/main/cmd/dashboard/"
    click BE "https://github.com/shashank-sharma/nenspace/tree/main/internal/"
    click GF "https://github.com/shashank-sharma/nenspace/tree/main/grafana/"
    click MP "https://github.com/shashank-sharma/nenspace/tree/main/prometheus/"
    click MIG "https://github.com/shashank-sharma/nenspace/tree/main/migrations/"
    click CW "https://github.com/shashank-sharma/nenspace/tree/main/.github/workflows/"
    click DF "https://github.com/shashank-sharma/nenspace/tree/main/Dockerfile"
    click DCY "https://github.com/shashank-sharma/nenspace/blob/main/docker-compose.yaml"
    click CDY "https://github.com/shashank-sharma/nenspace/blob/main/container-dev.yaml"

    %% Styles
    classDef frontend fill:#f8b400,stroke:#333,stroke-width:2px;
    classDef backend fill:#1e90ff,stroke:#333,stroke-width:2px;
    classDef module fill:#90ee90,stroke:#333,stroke-width:1px;
    classDef monitoring fill:#ff7f7f,stroke:#333,stroke-width:2px;
    classDef cicd fill:#d3d3d3,stroke:#333,stroke-width:2px;
```
