# boycany/draggable-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/boycany/draggable-dashboard
- Repository: https://github.com/boycany/draggable-dashboard

## Overview

##### Project type and purpose
- This is a single-page web application (SPA) written in Angular (v18.2.0) that provides a customizable dashboard interface.
- The README confirms it’s purely a front-end project generated by the Angular CLI, meant to run in the browser at localhost:4200, with no local backend code included.

##### File structure
Top-level files and folders:
- angular.json, tsconfig*.json, package.json – build and configuration
- src/index.html, src/main.ts – application entry point
- src/styles.scss – global styles
- src/app/app.module.ts (implicitly) – root module
- src/app/app.routes.ts – routing definitions
- src/app/app.config.ts – application-wide configuration
- src/app/components/widget & widget-options – reusable presentational components
- src/app/pages/dashboard – smart/container component for the dashboard page
- src/app/pages/dashboard/widgets – five distinct “widget” feature components (analytics, revenue, subscribers, views, watch-time)
- src/app/services/dashboard.service.ts – service responsible for fetching dashboard data
- src/app/models/dashboard.ts – TypeScript interfaces/models for dashboard data

##### README
- Confirms standard Angular development workflow (serve, build, test).

a. Main components to include
- Browser/Client (User’s web browser)
- Angular AppModule (root)
- Router (app.routes.ts) & Router-Outlet
- Container (DashboardComponent)
- Presentational components (WidgetsPanelComponent, WidgetComponent, WidgetOptionsComponent, individual widget components)
- DashboardService (data access layer)
- Dashboard models (interfaces)
- External REST API or data source (e.g., https://api.example.com/dashboard)

b. Relationships and interactions
- The browser loads index.html → bootstraps AppModule → renders AppComponent
- Router directs to DashboardComponent via configured routes
- DashboardComponent injects DashboardService
- DashboardService issues HTTP calls to the external API (using HttpClient)
- DashboardService returns typed model objects (defined in dashboard.ts)
- DashboardComponent distributes data to child components (WidgetsPanel → Widget → specific widget types)
- WidgetOptionsComponent emits events (e.g., sorting or filtering) back to its parent widget

c. Architectural patterns and design principles
- Component-Based Architecture: UI is broken into container (smart) vs. presentational (dumb) components
- Dependency Injection: Services injected into components for data access
- Single Source of Truth: DashboardService holds the data model and state
- Routing Module: Separation of navigation logic (app.routes.ts) from UI components
- Module Encapsulation: AppModule (and potentially feature modules) group related components, services, and routes

d. Relevant technologies, frameworks, libraries
- Angular (CLI, Router, HttpClient, NgModule, Component)
- TypeScript interfaces for models (src/app/models)
- SCSS for component styles
- Karma/Jasmine for unit tests

2. Inside the AppModule boundary, place Router→Router-Outlet → link to DashboardComponent
5. WidgetComponent using a specific child (analytics, revenue, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    subgraph "Client"
        Browser["User's Browser"]:::external
    end

    subgraph "AppModule"
        AppComponent["AppComponent"]:::component
        Router["Router"]:::component
        RouterOutlet["<RouterOutlet>"]:::component
    end

    subgraph "Dashboard Feature Module"
        DashboardComponent["DashboardComponent"]:::component
        WidgetsPanelComponent["WidgetsPanelComponent"]:::component
        WidgetComponent["WidgetComponent"]:::component
        WidgetOptionsComponent["WidgetOptionsComponent"]:::component

        subgraph "Widget Types"
            AnalyticsComponent["AnalyticsComponent"]:::component
            RevenueComponent["RevenueComponent"]:::component
            SubscribersComponent["SubscribersComponent"]:::component
            ViewsComponent["ViewsComponent"]:::component
            WatchTimeComponent["WatchTimeComponent"]:::component
        end
    end

    subgraph "Services & Models"
        DashboardService["DashboardService"]:::service
        DashboardModel["Dashboard Models"]:::model
    end

    subgraph "External API"
        ExternalAPI["External REST API\n(api.example.com/dashboard)"]:::api
    end

    %% Connections
    Browser -->|loads index.html| AppComponent
    AppComponent -->|initializes| Router
    Router -->|renders into| RouterOutlet
    RouterOutlet -->|route '/dashboard'| DashboardComponent
    DashboardComponent -->|contains| WidgetsPanelComponent
    WidgetsPanelComponent -->|renders| WidgetComponent
    WidgetComponent -->|uses| AnalyticsComponent
    WidgetComponent -->|uses| RevenueComponent
    WidgetComponent -->|uses| SubscribersComponent
    WidgetComponent -->|uses| ViewsComponent
    WidgetComponent -->|uses| WatchTimeComponent
    WidgetComponent -.->|emits events| WidgetOptionsComponent
    DashboardComponent <-->|injects| DashboardService
    DashboardService -->|HTTP GET| ExternalAPI
    DashboardService -->|returns typed data| DashboardModel
    DashboardComponent -->|receives data| DashboardModel

    %% Click Events
    click AppComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/app.component.ts"
    click Router "https://github.com/boycany/draggable-dashboard/blob/main/src/app/app.routes.ts"
    click WidgetComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/components/widget/widget.component.ts"
    click WidgetOptionsComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/components/widget/widget-options/widget-options.component.ts"
    click DashboardComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/dashboard.component.ts"
    click WidgetsPanelComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets-panel/widgets-panel.component.ts"
    click AnalyticsComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets/analytics/analytics.component.ts"
    click RevenueComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets/revenue/revenue.component.ts"
    click SubscribersComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets/subscribers/subscribers.component.ts"
    click ViewsComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets/views/views.component.ts"
    click WatchTimeComponent "https://github.com/boycany/draggable-dashboard/blob/main/src/app/pages/dashboard/widgets/watch-time/watch-time.component.ts"
    click DashboardService "https://github.com/boycany/draggable-dashboard/blob/main/src/app/services/dashboard.service.ts"
    click DashboardModel "https://github.com/boycany/draggable-dashboard/blob/main/src/app/models/dashboard.ts"

    %% Styles
    classDef component fill:#cce5ff,stroke:#4da3ff
    classDef service fill:#d4edda,stroke:#28a745
    classDef api fill:#fff3cd,stroke:#ffc107
    classDef model fill:#e2e3e5,stroke:#6c757d
    classDef external fill:#f8d7da,stroke:#dc3545,stroke-dasharray: 5 5
```
