# tsugiproject/tsugi architecture

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

- Interactive diagram: https://gitdiagram.com/tsugiproject/tsugi
- Repository: https://github.com/tsugiproject/tsugi

## Overview

##### Main Components

a) Core Infrastructure Layer:
- Database System (MySQL)
- Web Server (PHP-based)
- Docker Container Environment
- Static Content Server

b) Application Layers:
- Admin Console
- LTI Tools Management
- Authentication System
- API Services
- Tool Store/Repository

c) Integration Components:
- LTI Integration Services
- External Tool Connectors
- Learning Management System (LMS) Bridges

##### Infrastructure Layer
- Docker container boundaries
- Static content delivery

##### Core Services Layer
- Authentication services (/login.php, /logout.php)
- LTI services (/lti directory)
- API endpoints (/api directory)
- Admin services (/admin directory)

##### Tool Management Layer
- Tool installation system
- Module management
- Configuration management

##### Integration Layer
- LTI Protocol handlers
- External system connectors
- API interfaces

##### Specific Design Elements

Use these visual elements:
- Blue rectangles for core services
- Green rectangles for external integrations
- Yellow rectangles for administrative components
- Red rectangles for security boundaries

##### Key Relationships to Highlight

- Multi-tenant architecture
- Tool installation workflow
- Demonstrate the LTI authentication flow
- Database interaction patterns
- Admin console's relationship to other components

##### Important Subsystems

Detail these critical subsystems:
- Tool Store (/store directory)
- Admin Console (/admin directory)
- API Services (/api directory)
- Settings Management (/settings directory)
- Badge System (/badges directory)

##### Integration Points

External connections:
- LMS Integration
- Google Classroom Integration (/gclass directory)
- External Tool Connections
- Static Content Delivery

##### Security Boundaries

Clearly mark:
- Authentication boundaries
- Admin access restrictions
- API access controls
- Tool isolation

##### Integration points with external systems

- Core Tsugi components (blue)
- External integrations (green)
- Security boundaries (red)
- Administrative functions (yellow)

- All component types
- Connection types
- Security boundaries
- Special symbols

Keep the abstraction level high enough to be understandable but detailed enough to show the key architectural decisions and components that make Tsugi unique as a learning tool framework.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Core Component]:::core
        L2[External Integration]:::external
        L3[Admin Component]:::admin
        L4[Security Boundary]:::security
        L5[("Database")]:::database
    end

    subgraph "Infrastructure Layer"
        DB[("MySQL Database")]:::database
        WS["Web Server (PHP)"]:::core
        Docker["Docker Environment"]:::core
        Static["Static Content Server"]:::core
    end

    subgraph "Core Services Layer"
        Auth["Authentication System"]:::security
        LTICore["LTI Core Services"]:::core
        APICore["API Services"]:::core
        AdminCore["Admin Services"]:::admin
    end

    subgraph "Tool Management Layer"
        ToolStore["Tool Store"]:::core
        ModuleSystem["Module Management"]:::core
        ConfigMgmt["Configuration Management"]:::core
    end

    subgraph "Integration Layer"
        LTIProtocol["LTI Protocol Handler"]:::external
        ExtConnectors["External Connectors"]:::external
        APIInterface["API Interface"]:::external
        GClass["Google Classroom"]:::external
    end

    %% Connections
    DB --> Auth
    DB --> LTICore
    DB --> APICore
    DB --> AdminCore
    
    Auth --> LTICore
    Auth --> AdminCore
    Auth --> APICore
    
    LTICore --> ToolStore
    LTICore --> ModuleSystem
    
    APICore --> ExtConnectors
    APICore --> APIInterface
    
    ModuleSystem --> ConfigMgmt
    ToolStore --> ConfigMgmt
    
    LTIProtocol --> LTICore
    ExtConnectors --> GClass

    %% Click Events
    click Docker "https://github.com/tsugiproject/tsugi/tree/master/Dockerfile"
    click DB "https://github.com/tsugiproject/tsugi/blob/master/admin/install/database.php"
    click Auth "https://github.com/tsugiproject/tsugi/blob/master/login.php"
    click LTICore "https://github.com/tsugiproject/tsugi/tree/master/lti/"
    click APICore "https://github.com/tsugiproject/tsugi/tree/master/api/"
    click AdminCore "https://github.com/tsugiproject/tsugi/tree/master/admin/"
    click ToolStore "https://github.com/tsugiproject/tsugi/tree/master/store/"
    click ModuleSystem "https://github.com/tsugiproject/tsugi/tree/master/mod/"
    click ConfigMgmt "https://github.com/tsugiproject/tsugi/tree/master/settings/"
    click GClass "https://github.com/tsugiproject/tsugi/tree/master/gclass/"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef external fill:#2ecc71,stroke:#27ae60,color:white
    classDef admin fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
```
