# dhimanabhi/policy-reporter-ui architecture

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

- Interactive diagram: https://gitdiagram.com/dhimanabhi/policy-reporter-ui
- Repository: https://github.com/dhimanabhi/policy-reporter-ui

## Overview

##### Main Components
- Frontend: Built with Vue/Nuxt, it handles user interaction, visualization (charts, graphs, dashboards), and routing between different pages for policies, resources, sources, and targets.
- Backend: Written in Go, it serves API endpoints, handles authentication (OAuth2/OpenID Connect), interacts with underlying data sources (possibly through Kubernetes integration), and manages configuration, logging, and reporting.
- External Services: Although not directly visible, external dependencies are implied by authentication (‘backend/pkg/auth’) and Kubernetes integrations. There is also an integration point with the underlying “Policy Reporter” data source.
- Build & Deployment Pipeline: GitHub workflows (in the .github directory and Makefile) that indicate CI/CD operations and dependency management.

##### Project Architecture & Relationships
- The frontend communicates with the backend APIs via HTTP calls. The “frontend/modules/core/api.ts” and corresponding composables show where calls are made to the backend.
- The backend is structured into several packages (api, auth, config, kubernetes, reports, server, service, and utils) to clearly separate concerns:
- The “backend/pkg/api” folder handles API interactions including client/proxy handling.
- The “backend/pkg/auth” package manages authentication logic (sessions, middleware, and permissions).
- The “backend/pkg/server” likely sets up the HTTP server and REST endpoints.
- The “backend/pkg/reports” handles report generation and processing.
- The configuration files (e.g., config.example.yaml in the backend and various environment examples in the frontend) indicate environment-driven setups.
- The GitHub workflows and Makefile indicate a structured build/deployment process.

##### Important Architectural Patterns & Design Principles
- Separation of concerns is evident by distinct modules (frontend vs. backend) and even within the backend where you see segregation by responsibilities (authentication, configuration, API handling).
- The frontend likely employs a component-based architecture leveraging Vue’s composition API (with composables and plugins).
- In the backend, modularization via packages promotes clean code practices and easier maintenance.
- Use of middleware for authentication suggests a layered approach to managing requests.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Section
    subgraph "Frontend (Nuxt/Vue)"
        FE["Frontend Application"]:::frontendStyle
        FE_Pages["Pages (Policies,Resources,Sources,Targets)"]:::frontendStyle
        FE_API["API Communication"]:::frontendStyle
        FE_Components["Components (Dashboards,Graphs,Charts)"]:::frontendStyle
        FE_Composables["Composables (Reusable Logic)"]:::frontendStyle
    end

    %% Backend Section
    subgraph "Backend (Go)"
        BE_Server["HTTP Server & Routing"]:::backendStyle
        BE_API["API Endpoints"]:::backendStyle
        BE_Auth["Authentication Module"]:::backendStyle
        BE_Service["Business Logic/Service Layer"]:::backendStyle
        BE_Report["Report Processing & Generation"]:::backendStyle
        BE_Config["Configuration & Environment"]:::backendStyle
        BE_Kube["Kubernetes Integration"]:::backendStyle
        BE_Logging["Logging Utility"]:::backendStyle
    end

    %% CI/CD Pipeline Node
    CI["CI/CD & Build Pipeline"]:::cicdStyle

    %% Frontend Internal Connections
    FE_Pages --> FE
    FE_Composables --> FE
    FE_Components --> FE
    FE_API --> FE

    %% Frontend to Backend Communication
    FE_API -->|"APIRequest"| BE_Server

    %% Backend Internal Connections
    BE_Server -->|"Handles"| BE_API
    BE_Server -->|"AuthCheck"| BE_Auth
    BE_API -->|"Delegates"| BE_Service
    BE_Auth -->|"Verifies"| BE_Service
    BE_Service -->|"Generates"| BE_Report
    BE_Service -->|"Reads"| BE_Config
    BE_Service -->|"Integrates"| BE_Kube
    BE_Service -->|"Logs"| BE_Logging

    %% CI/CD Pipeline to Frontend & Backend
    CI --> FE
    CI --> BE_Server

    %% Click Events for Frontend Components
    click FE "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/frontend/"
    click FE_Pages "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/frontend/pages/"
    click FE_API "https://github.com/dhimanabhi/policy-reporter-ui/blob/main/frontend/modules/core/api.ts"
    click FE_Components "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/frontend/components/"
    click FE_Composables "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/frontend/composables/"

    %% Click Events for Backend Components
    click BE_API "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/api/"
    click BE_Auth "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/auth/"
    click BE_Server "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/server/"
    click BE_Report "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/reports/"
    click BE_Config "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/config/"
    click BE_Kube "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/kubernetes/"
    click BE_Logging "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/logging/"
    click BE_Service "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/backend/pkg/service/"

    %% Click Event for CI/CD Pipeline
    click CI "https://github.com/dhimanabhi/policy-reporter-ui/tree/main/.github/"

    %% Styling definitions
    classDef frontendStyle fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef backendStyle fill:#e6ffe6,stroke:#008000,stroke-width:2px;
    classDef cicdStyle fill:#e6e6ff,stroke:#0000cc,stroke-width:2px;
```
