# shivang-agarwal11/dana-tool architecture

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

- Interactive diagram: https://gitdiagram.com/shivang-agarwal11/dana-tool
- Repository: https://github.com/shivang-agarwal11/dana-tool

## Overview

##### Project Type and Purpose
- DANA is a full-stack, microservices-style DevOps automation platform.
- It provides a React-based UI for low-code pipeline creation and observability, a Node.js/Express backend with MongoDB persistence, and a Python-based AI Agent service for intelligent CI/CD troubleshooting and automation.

##### Main Components
a. Frontend (dana-app-ui)
- React single-page application
- Components for dashboards, charts, forms, authentication flows
b. Backend/API Server (dana-main-server)
- Node.js • Express
- RESTful endpoints for user management, Jenkins, GitHub, SonarQube, and pipeline analysis
- Middleware for authentication
- MongoDB database
c. AI Agent Service (jenkinsAgenticAI)
- Python (Flask or FastAPI) app.py and rag_deep.py
- Uses Ollama and DeepSeek models for agentic AI tasks
d. External Systems
- Jenkins CI/CD servers
- GitHub (repos, PRs, issues)
- SonarQube server
- MongoDB Atlas or self-hosted
e. DevOps / CI Pipeline
- GitHub Actions (.github/workflows/build.yml)
- SonarQube scanner (sonar-project.properties)

##### Component Relationships & Data Flows
- The React UI issues AJAX/Fetch requests to the Backend API over HTTPS.
- The Backend:
- Reads/Writes from MongoDB for user data and historical stats.
- Calls Jenkins REST APIs to fetch jobs, build history, logs.
- Calls GitHub REST APIs for commits, PR analysis, and issue creation.
- Calls SonarQube REST APIs for code-quality metrics.
- When AI functionality is invoked (e.g., “Analyze Pipeline”), the Backend forwards requests to the AI Agent Service.
- The AI Agent Service:
- Receives HTTP requests from the Backend.
- Loads and queries large-language models via Ollama/DeepSeek.
- Returns analysis or remediation suggestions.
- DevOps: GitHub Actions pipeline triggers on code commits, runs tests, builds Docker images, and publishes to environments. SonarQube scanner runs as part of the CI to feed quality metrics into the Backend.

##### Architectural Patterns & Principles
- Client-Server (React SPA + REST API)
- Microservices (separate Python AI service)
- Layered Architecture in Backend: Routes → Controllers → Middleware → Database
- Single Source of Truth in MongoDB
- External Integration Adapters for Jenkins, GitHub, SonarQube
- Low-code/No-code UI separating business logic from presentation

##### Technologies & Frameworks
- Frontend: React, React Router, Chart.js (BarChart, LineChart, PieChart), CSS
- Backend: Node.js, Express.js, Mongoose (MongoDB), JWT Auth
- AI Agent: Python, Flask (or FastAPI), Ollama, DeepSeek, Transformers
- External: Jenkins REST API, GitHub REST API, SonarQube REST API
- DevOps: GitHub Actions, sonar-project.properties

##### Essential Details to Capture
- Authentication flow (login endpoint → JWT issuance → ProtectedRoute on UI).
- AI analysis workflow (UI “Analyze” button → POST /analyze/pipeline → AI Agent Service → results displayed).
- Database interactions for user profiles, settings, historical logs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React UI)"
        direction TB
        UI["React SPA"]:::frontend
        UI --> UIcomponents["Components"]:::frontend
        UI --> UIScenes["Scenes"]:::frontend
        UI --> UIApi["API Service Layer"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Node.js/Express)"
        direction TB
        API["Express API Server"]:::backend
        API --> AuthMw["Authentication Middleware"]:::backend
        API --> Router["User Router"]:::backend
        API --> Models["User Model"]:::backend
        API --> DBconn["Database Connection"]:::backend
        API --> UtilsGH["GitHub Integration"]:::backend
        API --> UtilsSQ["SonarQube Integration"]:::backend
    end

    %% AI Agent Service
    subgraph "AI Agent Service (Python)"
        direction TB
        AI["AI Service Endpoint"]:::ai
        AI --> Rag["RAG / DeepSeek Logic"]:::ai
        AI --> Requirements["Dependencies"]:::ai
    end

    %% Database
    DB[(MongoDB)]:::database

    %% External Systems
    subgraph "External Systems"
        direction TB
        Jenkins[("Jenkins CI/CD")]:::external
        GitHub[("GitHub API")]:::external
        Sonar[("SonarQube API")]:::external
    end

    %% DevOps CI Pipeline
    DevOps["CI Pipeline (GitHub Actions)"]:::external

    %% Data Flows
    UI -->|"HTTPS / AJAX"| API
    API -->|"Read/Write"| DB
    API -->|"Jenkins REST API"| Jenkins
    API -->|"GitHub REST API"| GitHub
    API -->|"SonarQube REST API"| Sonar
    API -->|"Invoke AI Analysis"| AI
    DevOps -.->|"Triggers CI/CD"| API

    %% Click Events - Frontend
    click UI "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-app-ui/src/index.js"
    click UIcomponents "https://github.com/shivang-agarwal11/dana-tool/tree/main/dana-app-ui/src/components/"
    click UIScenes "https://github.com/shivang-agarwal11/dana-tool/tree/main/dana-app-ui/src/scenes/"
    click UIApi "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-app-ui/src/services/apiServices.js"

    %% Click Events - Backend
    click API "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/index.js"
    click DBconn "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/database/connect.js"
    click Models "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/models/User.model.js"
    click Router "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/router/user.router.js"
    click AuthMw "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/middleware/userAuth.js"
    click UtilsGH "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/utils/fetchGithubStats.js"
    click UtilsSQ "https://github.com/shivang-agarwal11/dana-tool/blob/main/dana-main-server/src/utils/fetchSonarQubeStats.js"

    %% Click Events - AI Service
    click AI "https://github.com/shivang-agarwal11/dana-tool/blob/main/jenkinsAgenticAI/app.py"
    click Rag "https://github.com/shivang-agarwal11/dana-tool/blob/main/jenkinsAgenticAI/rag_deep.py"
    click Requirements "https://github.com/shivang-agarwal11/dana-tool/blob/main/jenkinsAgenticAI/requirements.txt"

    %% Click Events - DevOps / CI
    click DevOps "https://github.com/shivang-agarwal11/dana-tool/blob/main/.github/workflows/build.yml"
    click Sonar "https://github.com/shivang-agarwal11/dana-tool/blob/main/sonar-project.properties"

    %% Styling
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef backend fill:#DFF2E1,stroke:#28a745,stroke-width:1px;
    classDef ai fill:#E8D0FF,stroke:#6f42c1,stroke-width:1px;
    classDef database fill:#FFE8D0,stroke:#d97504,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#6c757d,stroke-width:1px;
```
