· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
Architecture Overview

System Design
This document provides a high-level overview of Astral's architecture. Understanding these layers will help you contribute to the project or integrate Astral into your tooling.
Architectural Layers
Astral is organized into well-defined layers, each with specific responsibilities:
Layer Details
CLI Layer
The CLI layer handles user interaction:
- Argument parsing: Flag processing, subcommand routing
- Configuration loading: Reading from config files and environment
- Output formatting: Pretty printing, JSON output, terminal colors
- Error presentation: User-friendly error messages
// cmd/asl/main.go
func main() {
cli.Run(os.Args)
}
Command Layer
High-level commands that compose core operations:
- Save: Snapshot working tree changes to a new commit
- Merge: Three-way merge with conflict handling
- Stack: Navigate and manipulate commit stacks
- Branch: Create, delete, and switch branches
Core Layer
The heart of Astral's functionality:
- Repository: Overall repository state and operations
- Refs: Branch and tag management
- Working Tree: File status, diff computation
- Commit Graph: History traversal and analysis
Object Store
The content-addressable storage layer:
- Blobs: Raw file content storage
- Trees: Directory structure representation
- Commits: Snapshot metadata
Directory Structure
The .asl directory contains all repository data:
.asl/
Key Design Decisions
Astral uses optimistic concurrency. Most operations can proceed without locks, with conflict detection at write time.
Status checks, diff computation, and object hashing leverage all available CPU cores.
Astral has no runtime dependencies. A single static binary works everywhere.
Clear layer boundaries enable unit testing at each level with minimal mocking.