# jaeggerjose/ai_centre_admin architecture

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

- Interactive diagram: https://gitdiagram.com/jaeggerjose/ai_centre_admin
- Repository: https://github.com/jaeggerjose/ai_centre_admin

## Overview

##### Main Components
- Account Manager:
- Backend: The Django application (found under AI_LDAP_admin with its internal structure including settings, URL routing, views, and APIs). This component implements authentication and user management.
- API Subsystem: The “api” directory within the AI_LDAP_admin folder handles business logic (models, serializers, migrations, and tests). Show this as a core REST API provider.
- Frontend:
- React Application: The top-level “frontend” folder (with package.json, src components, tailwind configuration) represents the user interface that interacts with the Account Manager.
- Secondary UI Elements: There’s also a “frontend” submodule within AI_LDAP_admin; verify its role, but it likely provides admin or complementary UI elements.
- Resource Manager:
- Go-based Controller: The “QNAPController” folder, with its Dockerfile, go.mod, main.go, and Kubernetes deployment YAML, implements monitoring of Jupyter Notebook pods through the Kubernetes Metrics API.
- Dex Connector:
- YAML configurations (e.g., in dex_connector/dex-config.yaml and other YAML files for Kubernetes RBAC) that integrate OpenLDAP-based authentication with Dex as an OpenID Connect provider.
- Auxiliary Kubernetes Components:
- Various YAML configuration files (cluster-role, role, binding, full-stack-deployment.yaml, etc.) that define roles, service deployments, and other K8s-specific resources.
- External AI Toolkits:
- Although not represented as source code, the README mentions integrations with Jupyter Notebook, Jupyter Lab, and Remote Desktop Docker images. Include these as external services or dependencies that interact with your Resource Manager and the Kubernetes environment.

##### Depicting the Relationships and Interactions
- The Frontend interacts with the Django-powered Account Manager via API calls (HTTP/REST) to perform user operations like authentication, data export/import, and overview displays.
- The Account Manager performs OpenLDAP-supported authentication (with Dex acting as intermediary for OpenID Connect token validation) and manages hierarchical user roles (admin, group manager, user).
- The Resource Manager (Go controller) continuously monitors the Jupyter Notebook pods by querying the Kubernetes Metrics API. Its decisions (e.g., shutting down idle notebooks) lead to actions that free resources.
- The Kubernetes cluster runs all containerized components using Dockerfiles provided in each subdirectory, and RBAC is enforced using the provided role and cluster-role YAML files.
- Data Persistence: SQLite databases (present in several locations within the API and possibly frontend directories) indicate where user data and other state are maintained (for development/testing or lightweight production use).

##### Important Architectural Patterns and Design Principles
- Microservices/Modular Services: Each major function (user management, resource monitoring, and UI analytics) is encapsulated into individual services.
- Separation of Concerns: The system is clearly divided between presentation (React frontend), business logic (Django backend), and operational control (Go-based resource manager).
- Kubernetes Native Deployment: Emphasize how deployments, RBAC policies, and resource controllers (using YAML manifests) are central to the platform’s operation.
- Authentication Flow: The integration of OpenLDAP with Dex and the usage of OpenID Connect within Kubernetes exemplifies modern, secure authentication practices.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Kubernetes Cluster"
        K8sConfig["K8s Config & Deployments"]:::cluster
        KM["K8s Metrics API"]:::cluster
        subgraph "Account Manager"
            AM1["Django Backend"]:::account
            AM2["API Subsystem"]:::account
            AM3["Admin UI (Secondary Frontend)"]:::account
        end
        FE["React Frontend"]:::frontend
        RM["Go-based Resource Manager"]:::controller
        DC["Dex Connector"]:::auth
        EA["External AI Tools (Jupyter Notebook, Jupyter Lab, Remote Desktop)"]:::external
    end

    %% Relationships
    FE -->|"REST_API"| AM2
    AM2 -->|"auth_request"| DC
    AM1 -->|"auth_validate"| DC
    KM -->|"metrics_data"| RM
    RM -->|"cleanup_action"| K8sConfig
    RM -->|"monitoring"| EA

    %% Click Events
    click K8sConfig "https://github.com/jaeggerjose/ai_centre_admin/blob/main/AI_LDAP_admin/full-stack-deployment.yaml"
    click AM1 "https://github.com/jaeggerjose/ai_centre_admin/tree/main/AI_LDAP_admin/AI_LDAP_admin/"
    click AM2 "https://github.com/jaeggerjose/ai_centre_admin/tree/main/AI_LDAP_admin/api/"
    click AM3 "https://github.com/jaeggerjose/ai_centre_admin/tree/main/AI_LDAP_admin/frontend/"
    click FE "https://github.com/jaeggerjose/ai_centre_admin/tree/main/frontend/"
    click RM "https://github.com/jaeggerjose/ai_centre_admin/tree/main/QNAPController/"
    click DC "https://github.com/jaeggerjose/ai_centre_admin/blob/main/dex_connector/dex-config.yaml"

    %% Styles
    classDef cluster fill:#a2d9ff,stroke:#1f618d,stroke-width:2px;
    classDef account fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef frontend fill:#a9dfbf,stroke:#239b56,stroke-width:2px;
    classDef controller fill:#d2b4de,stroke:#7d3c98,stroke-width:2px;
    classDef auth fill:#f5cba7,stroke:#d35400,stroke-width:2px;
    classDef external fill:#e8daef,stroke:#8e44ad,stroke-width:2px;
```
