# sinux-l5d/studentbox architecture

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

- Interactive diagram: https://gitdiagram.com/sinux-l5d/studentbox
- Repository: https://github.com/sinux-l5d/studentbox

## Overview

##### Main Components

a) CLI Layer
- Entry point through cmd/studentbox
- User interface for spawning containers
- Command handling and parameter processing

b) Core Management Layer
- Container management system (internal/containers)
- Runtime environment handling (internal/runtimes)
- Configuration generation (internal/generate)

c) Runtime Environments
- LAMP stack implementation (as shown in runtimes/lamp)
- Multiple container orchestration (Apache, MySQL, PHP)

d) Infrastructure Layer
- Podman integration
- AWS deployment support (optional component)

##### Optional AWS Infrastructure wrapper

**[User Input] → [CLI Layer (studentbox)] →**
- [Container Manager] ←→ [Runtime Manager]
- ↓
- [Generate Layer]
- ↓
- [Runtime Configurations] →
- [Podman Engine]
- ↓
- [Container Instances]

##### Important Details to Highlight

- Multi-container nature of runtimes (especially LAMP stack)
- Configuration flow from runtime definitions to container instances
- Separation between the management layer and actual container execution
- AWS deployment option as an alternative infrastructure layer

##### Implementation Notes

- Version indicators for critical dependencies (Podman 4.0.0+)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI
        CLI["CLI Interface"]:::cli
        click CLI "https://github.com/sinux-l5d/studentbox/blob/main/cmd/studentbox/main.go"
    end

    subgraph CoreManagement
        ContainerMgr["Container Manager"]:::core
        RuntimeMgr["Runtime Manager"]:::core
        ErrorHandler["Error Handler"]:::core
        ContainerDef["Container Definition"]:::core

        click ContainerMgr "https://github.com/sinux-l5d/studentbox/blob/main/internal/containers/manager.go"
        click ErrorHandler "https://github.com/sinux-l5d/studentbox/blob/main/internal/containers/errors.go"
        click ContainerDef "https://github.com/sinux-l5d/studentbox/blob/main/internal/containers/container.go"
        click RuntimeMgr "https://github.com/sinux-l5d/studentbox/blob/main/internal/runtimes/runtime.go"
    end

    subgraph ConfigGen
        Generator["Generator Core"]:::config
        DockerGen["Dockerfile Generator"]:::config
        EnvVars["Environment Variables"]:::config
        RuntimeGen["Runtime Generator"]:::config

        click Generator "https://github.com/sinux-l5d/studentbox/blob/main/internal/generate/generate.go"
        click DockerGen "https://github.com/sinux-l5d/studentbox/blob/main/internal/generate/dockerfiles.go"
        click EnvVars "https://github.com/sinux-l5d/studentbox/blob/main/internal/runtimes/envvar.go"
        click RuntimeGen "https://github.com/sinux-l5d/studentbox/blob/main/internal/runtimes/generated.go"
    end

    subgraph LAMPRuntime
        Apache["Apache Server"]:::runtime
        MySQL["MySQL Database"]:::runtime
        PHP["PHP Runtime"]:::runtime
        WebConfig["Web Server Config"]:::config
        PHPConfig["PHP Apache Config"]:::config

        click Apache "https://github.com/sinux-l5d/studentbox/blob/main/runtimes/lamp/apache.containerfile"
        click MySQL "https://github.com/sinux-l5d/studentbox/blob/main/runtimes/lamp/mysql.containerfile"
        click PHP "https://github.com/sinux-l5d/studentbox/blob/main/runtimes/lamp/php.containerfile"
        click WebConfig "https://github.com/sinux-l5d/studentbox/blob/main/runtimes/lamp/httpd.conf"
        click PHPConfig "https://github.com/sinux-l5d/studentbox/blob/main/runtimes/lamp/to-php.apache.conf"
    end

    subgraph Infrastructure
        Podman[(Podman Engine)]:::external
        AWS["AWS Deployment"]:::external
        LaunchScript["Launch Script"]:::external

        click AWS "https://github.com/sinux-l5d/studentbox/blob/main/aws/vpc.yaml"
        click LaunchScript "https://github.com/sinux-l5d/studentbox/blob/main/aws/launch.sh"
    end

    subgraph BuildSystem
        CLIBuild["CLI Build"]:::build
        RuntimeBuild["Runtime Build"]:::build
        RuntimeVerify["Runtime Verify"]:::build

        click CLIBuild "https://github.com/sinux-l5d/studentbox/blob/main/.github/workflows/build-cli.yaml"
        click RuntimeBuild "https://github.com/sinux-l5d/studentbox/blob/main/.github/workflows/build-runtime-containers.yaml"
        click RuntimeVerify "https://github.com/sinux-l5d/studentbox/blob/main/.github/workflows/check-runtimes.yaml"
    end

    User(("User")):::user --> CLI
    CLI --> ContainerMgr
    ContainerMgr <--> RuntimeMgr
    ContainerMgr --> ErrorHandler
    ContainerMgr --> ContainerDef
    
    RuntimeMgr --> Generator
    Generator --> DockerGen
    RuntimeMgr --> EnvVars
    RuntimeMgr --> RuntimeGen
    
    DockerGen --> LAMPRuntime
    Apache --> WebConfig
    PHP --> PHPConfig
    
    RuntimeGen --> Podman
    Podman -.-> AWS
    AWS --> LaunchScript
    
    BuildSystem --> RuntimeMgr

    classDef user fill:#f9f,stroke:#333,stroke-width:2px
    classDef cli fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#e67e22,stroke:#d35400,color:white
    classDef runtime fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef build fill:#e74c3c,stroke:#c0392b,color:white
```
