How substratusai/sandboxai works
Main Components
• Containerized Execution Engine: This is the heart of SandboxAI. It manages sandboxed environments where the code and shell commands run in isolation. This is represented by components in both the Python (python/boxd and python/sandboxai) and Go sections (go/sandboxaid).
• API Layer: The RESTful interface is defined (api/v1.yaml) and is implemented in the Go API and Python API submodules. This is the external face of SandboxAI, handling incoming requests and dispatching them to the appropriate backend logic.
• Client SDKs: There are dedicated client implementations in both Python (python/sandboxai/client) and Go (go/client). These provide simple integration for end-users (for example, by pip installing sandboxai-client).
• Supporting Tools and Tests: The repository includes tools (under go/tools) and extensive end-to-end (e2e) tests (in test and go/test/e2e directories) that ensure reliability and proper integration.
• How clients (both Python and Go SDKs) interact with the API layer through RESTful endpoints.
• API’s role in sending execution commands to the underlying sandbox engine, which in turn spins up Docker containers and manages isolated environments.
• Communication flows: from the client SDKs (initiating commands), to the API service, to the container orchestration layer (Docker/Kubernetes), and back (results/results flows).
Architectural Patterns and Design Principles
• Separation of concerns: The clear division between client libraries, API endpoints, and container management indicates a modular design.
• Use of containerization to ensure process isolation (Docker and the forthcoming Kubernetes deployment).
• SDK abstraction: The single SDK commands abstract the underlying API complexities from the user.
• Multi-language support: The parallel Python and Go implementations underline the focus on developer flexibility and cross-language compatibility.
Incorporate Specific Technologies and Frameworks
• Kubernetes (not yet fully implemented but mentioned as a future multi-node backend).
• RESTful API protocols (with the API defined in api/v1.yaml).
• Python and Go standard libraries & ecosystems.
• GitHub workflows for CI/CD (via .github/workflows) and dependency management files such as go.mod, pyproject.toml, and requirements.txt.