Skip to content

Commit bff01b3

Browse files
andypostclaude
andcommitted
Add comprehensive architectural documentation and developer guidelines
- Add CLAUDE.md with project overview and key commands for AI assistance - Create docs/architecture/ with detailed architectural analysis: * ARCHITECTURAL_PATTERNS.md: 16 design patterns, anti-patterns, and 15 improvement suggestions * LOGGING_ARCHITECTURE.md: Analysis of sophisticated dual logging system (Log() vs Term()) * PLUGIN_SYSTEM.md: Complete plugin architecture guide with examples * SERVICE_SYSTEM.md: Service-oriented design and dependency injection documentation - Add comprehensive DEVELOPER_GUIDELINES.md covering: * Code style and conventions * Architecture guidelines and best practices * Logging guidelines for dual system usage * Plugin and service development guides * Testing, error handling, and performance considerations - Update docs/README.md with improved organization and navigation Total: 1,915 lines of comprehensive documentation covering system architecture, development practices, and contribution guidelines. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 221e137 commit bff01b3

File tree

8 files changed

+1915
-6
lines changed

8 files changed

+1915
-6
lines changed

CLAUDE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Build and Development
8+
- `make` - Build the launchr binary to `bin/launchr`
9+
- `make DEBUG=1` - Build with debug symbols for use with dlv debugger
10+
- `make deps` - Fetch go dependencies
11+
- `make test` - Run all tests
12+
- `make lint` - Run golangci-lint with fixes
13+
- `make install` - Install globally to `$GOPATH/bin`
14+
- `go generate ./...` - Generate code (runs as part of build)
15+
16+
### Usage
17+
- `bin/launchr --help` - Show help
18+
- `bin/launchr --version` - Show version
19+
- `bin/launchr build` - Build custom launchr with plugins
20+
21+
## Architecture Overview
22+
23+
Launchr is a CLI action runner that executes tasks defined in YAML files across multiple runtimes (containers, shell, plugins). The architecture is built around several core patterns:
24+
25+
### Core Systems
26+
27+
**Plugin Architecture**: Weight-based plugin system where plugins register via `init()` functions and implement lifecycle interfaces like `OnAppInitPlugin`, `CobraPlugin`, `DiscoveryPlugin`. Plugins are registered globally through `launchr.RegisterPlugin()`.
28+
29+
**Service-Oriented Design**: Core services (Config, Manager, PluginManager) are registered and retrieved through dependency injection via `App.AddService()` and `App.GetService()`. All services implement the `Service` interface.
30+
31+
**Runtime Strategy Pattern**: Multiple runtime implementations (shell, container, plugin) that implement the `Runtime` interface with `Init()`, `Execute()`, `Close()`, `Clone()` methods.
32+
33+
### Key Components
34+
35+
- **Action System** (`pkg/action/`): Core action entity with manager handling lifecycle, discovery, validation, and execution
36+
- **Runtime System**: Shell, Container (Docker/K8s), and Plugin runtime implementations
37+
- **Discovery System**: YAML and embedded filesystem action discovery with extensible discovery plugins
38+
- **Configuration System**: YAML-based config with dot-notation access and reflection-based caching
39+
- **Plugin System** (`plugins/`): Core plugins for naming, CLI integration, discovery, value processing, and verbosity
40+
41+
### Important Interfaces
42+
43+
- `App`: Global application state management
44+
- `Plugin`: Base plugin interface with `PluginInfo()` and lifecycle hooks
45+
- `Service`: Dependency injection with `ServiceInfo()`
46+
- `Runtime`: Action execution environment abstraction
47+
- `Manager`: Action management and orchestration
48+
49+
### Key Files
50+
51+
- `app.go`: Main application implementation with plugin and service management
52+
- `types.go`: Type aliases to reduce external dependencies
53+
- `pkg/action/manager.go`: Action lifecycle management
54+
- `pkg/action/action.go`: Core action entity
55+
- `internal/launchr/config.go`: Configuration system
56+
- `plugins/default.go`: Plugin registration
57+
58+
### Development Patterns
59+
60+
- Type aliases in `types.go` for clean interfaces
61+
- Error handling with custom types and `errors.Is()` support
62+
- Go template integration for dynamic action configuration
63+
- Mutex-protected operations for concurrency safety
64+
- `fs.FS` interface for filesystem abstraction
65+
- JSON Schema validation for inputs and configuration
66+
67+
### Execution Flow
68+
69+
1. Plugin registration and service initialization
70+
2. Action discovery through registered discovery plugins
71+
3. Cobra command generation from discovered actions
72+
4. Multi-stage input validation (runtime flags, persistent flags, action parameters)
73+
5. Runtime-specific execution with cleanup
74+
6. Support for async action execution with status tracking
75+
76+
### Environment Variables
77+
78+
- `LAUNCHR_ACTIONS_PATH`: Path for action discovery (default: current directory)

0 commit comments

Comments
 (0)