Skip to content

Vitality Architecture Overview

Hรฉla Ben Khalfallah edited this page Mar 3, 2025 · 15 revisions

Vitality is a modular system designed for scalability, maintainability, and seamless code auditing. It ensures a single source of truth for all code quality, performance, and security assessments.

๐Ÿง  Architecture Diagram

Architecture Diagram

๐Ÿ“‚ Directory Structure

v6y-apps
โ”œโ”€โ”€ front                # Main user interface (IHM)
โ”œโ”€โ”€ front-bo             # Back-office interface (BO)
โ”œโ”€โ”€ bff                  # Backend for Frontend (GraphQL, Node.js)
โ”œโ”€โ”€ bfb-main-analyzer    # Central code analysis orchestrator
โ”œโ”€โ”€ bfb-static-auditor   # Static code analysis module
โ”œโ”€โ”€ bfb-devops-auditor   # DevOps metrics analyzer
โ”œโ”€โ”€ bfb-url-dynamic-auditor # URL-based dynamic analysis (e.g., Lighthouse)

v6y-libs
โ”œโ”€โ”€ core-logic           # Reusable backend logic
โ””โ”€โ”€ ui-kit               # Common UI components and hooks

ui-guide                 # Storybook documentation for ui-kit

persistence              # Database layer (PostgreSQL)

๐Ÿงฎ Component Descriptions

๐Ÿ“Œ Frontend (IHM)

  • Purpose: User-facing interface for audit visualization, project tracking, and reporting.
  • Technologies: React, Next.js, GraphQL
  • Guidelines:
    • Use only components from ui-kit.
    • No direct usage of UI librariesโ€”contribute missing components to ui-kit.
    • No direct usage of CSS, inline styles, or any other type of style should be used. All needed styles should be implemented inside components exposed by ui-kit.
    • All new components must include tests and Storybook documentation (ui-guide).

๐Ÿ“Œ Frontend (BO)

  • Purpose: Admin and configuration interface for managing applications and audit settings.
  • Technologies: React, Next.js, Refine, GraphQL
  • Guidelines:
    • Use only components from ui-kit.
    • No direct usage of UI librariesโ€”contribute missing components to ui-kit.
    • No direct usage of CSS, inline styles, or any other type of style should be used. All needed styles should be implemented inside components exposed by ui-kit.
    • All new components must include tests and Storybook documentation (ui-guide).

๐Ÿ“Œ Backend for Frontend (BFF)

  • Role: Orchestrates frontend-backend communication via GraphQL.
  • Technologies: Node.js, GraphQL
  • Responsibilities:
    • Data aggregation and transformation.
    • Authentication and authorization.
    • Rate limiting and caching.

๐Ÿ“Œ BFB Main Analyzer

  • Role: Single source of truthโ€”orchestrates auditing processes.
  • Functionality:
    • Fetches applications configured in BO.
    • Manages scheduled execution (every midnight).
    • Determines which BFB Auditors to trigger.

๐Ÿ“Œ BFB Auditors

  • Purpose: Specialized analysis modules using various tools.
  • Existing Auditors:
    • bfb-static-code-auditor:
      • Code complexity, duplication, modularity.
      • Security vulnerabilities, dependency analysis.
    • bfb-devops-auditor:
      • DevOps DORA metrics, CI/CD health.
    • bfb-url-dynamic-auditor:
      • Lighthouse audits (Performance, SEO, Accessibility).

๐Ÿ“Œ Persistence Layer

  • Database: PostgreSQL
  • Responsibilities:
    • Stores audit results and historical data.
    • Ensures data consistency and integrity.

๐Ÿšฆ Auditing Workflow

Scheduled Scan (Triggered at Midnight)
โ”‚
โ””โ”€โ”€โ–ถ BFB Main Analyzer (Scheduler)
    โ”‚
    โ”œโ”€โ”€ Fetches Applications List (from BO Configuration)
    โ”‚   โ”œโ”€โ”€ Each application is linked to:
    โ”‚   โ”‚   โ”œโ”€โ”€ Git Repository (GitHub/GitLab)
    โ”‚   โ”‚   โ””โ”€โ”€ Production URL
    โ”‚
    โ”œโ”€โ”€ Ensures Single Source of Truth:
    โ”‚   โ”œโ”€โ”€ Avoids multiple redundant checks on the same source code
    โ”‚   โ”œโ”€โ”€ Centralized orchestration of auditing tasks
    โ”‚
    โ”œโ”€โ”€ Triggers BFB Auditors (Child Analyzers)
    โ”‚   โ”œโ”€โ”€ Verifies if each child auditor is available before execution
    โ”‚   โ”œโ”€โ”€ Dispatches application analysis tasks
    โ”‚
    โ”œโ”€โ”€ Child Auditors Execution
    โ”‚   โ”œโ”€โ”€ Static Code Analysis:
    โ”‚   โ”‚   โ”œโ”€โ”€ Linting & Style Checks
    โ”‚   โ”‚   โ”œโ”€โ”€ Code Quality & Security
    โ”‚   โ”‚   โ”œโ”€โ”€ Dependencies Vulnerability Analysis
    โ”‚   โ”‚
    โ”‚   โ”œโ”€โ”€ Dynamic Analysis:
    โ”‚   โ”‚   โ”œโ”€โ”€ Lighthouse โ†’ Performance, SEO, Accessibility
    โ”‚   โ”‚   โ”œโ”€โ”€ API Security Audit โ†’ OWASP Compliance
    โ”‚   โ”‚
    โ”‚   โ”œโ”€โ”€ DevOps Metrics:
    โ”‚   โ”‚   โ”œโ”€โ”€ DORA Metrics โ†’ Deployment Frequency, Lead Time, etc.
    โ”‚   โ”‚   โ”œโ”€โ”€ CI/CD Pipeline Health Monitoring
    โ”‚
    โ”œโ”€โ”€ Reporting & Data Persistence
    โ”‚   โ”œโ”€โ”€ Aggregates results from all auditors
    โ”‚   โ”œโ”€โ”€ Generates structured reports
    โ”‚   โ”œโ”€โ”€ Stores analysis data in PostgreSQL (Historical Tracking)
    โ”‚
    โ””โ”€โ”€โ–ถ Frontend Display (IHM & BO)
        โ”‚
        โ”œโ”€โ”€ IHM (Developer Insights)
        โ”‚   โ”œโ”€โ”€ Displays audit results per application
        โ”‚   โ”œโ”€โ”€ Provides interactive filtering & search
        โ”‚   โ”œโ”€โ”€ Allows issue tracking & resolution workflows
        โ”‚
        โ”œโ”€โ”€ BO (Admin & Configuration)
        โ”‚   โ”œโ”€โ”€ Manages applications & linked repositories
        โ”‚   โ”œโ”€โ”€ Configures audit rules & thresholds
        โ”‚   โ”œโ”€โ”€ Monitors scheduled execution & overall system health
        โ”‚
        โ””โ”€โ”€โ–ถ Users can view reports, export data, and track historical trends 

โœ… Best Practices

Avoid Duplication

  • Shared logic goes to core-logic (backend) or ui-kit (frontend).

Component Development

  • All UI components should be documented in ui-guide using Storybook.
  • Contributions should follow the design system principles established in ui-kit.

Testing

  • Each module requires unit and integration tests.
  • Use Storybook for visual testing of UI components.

Vitality is designed to provide scalable, efficient, and automated code auditing. By ensuring a clean, modular architecture, we maintain audit integrity, structured reporting, and developer-friendly visualization.

This system guarantees that code quality, security, and performance insights are accessible, actionable, and reliable. ๐ŸŽฏ