Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ First off, thank you for considering contributing! It's people like you that mak
- [Code of Conduct](#code-of-conduct)
- [How Can I Contribute?](#how-can-i-contribute)
- [Development Setup](#development-setup)
- [Architecture Overview](#architecture-overview)
- [Adding New Technology Stacks](#adding-new-technology-stacks)
- [Git Workflow and Pull Requests](#git-workflow-and-pull-requests)
- [Coding Style and Principles](#coding-style-and-principles)
- [Commit Message Guidelines](#commit-message-guidelines)
- [Testing](#testing)

## Architecture Overview

Before contributing, please familiarize yourself with the project architecture:

- **[๐Ÿ“ Architecture Guide](docs/ARCHITECTURE.md)** - Complete overview of the monorepo structure, design principles, and component interactions
- **[๐Ÿ›๏ธ ADRs](docs/adr/)** - Architectural decision records explaining key design choices
- **[๐Ÿ› ๏ธ Technology Stacks](docs/STACKS.md)** - Supported frameworks and project templates

Understanding the architecture will help you:
- Choose the right package for your changes
- Follow established patterns and conventions
- Understand cross-package dependencies
- Write better tests and documentation

## Code of Conduct

This project is governed by our [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
Expand Down Expand Up @@ -371,3 +386,9 @@ docs(readme): ๐Ÿ“ update installation instructions
Our CI pipeline will run these tests automatically on your PR.

Thank you again for your interest in contributing!

---

## Documentation
- [Architecture Guide](docs/ARCHITECTURE.md)
- [Self-Hosting Guide](docs/SELF_HOSTING_GUIDE.md)
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,28 @@ This is the best approach for ensuring everyone on a project uses the exact same
npx stc commit
```

## ๐Ÿ“š Documentation

For detailed information about the project:

- **[๐Ÿ“ Architecture Guide](docs/ARCHITECTURE.md)** - Understand the project structure, design principles, and component interactions
- **[๐Ÿค Contributing Guide](docs/CONTRIBUTING.md)** - Development workflow, coding standards, and how to contribute
- **[๐Ÿ› ๏ธ Technology Stacks](docs/STACKS.md)** - Complete list of supported frameworks and project templates
- **[๐Ÿš€ Self-Hosting Guide](docs/SELF_HOSTING_GUIDE.md)** - Deploy and customize StackCode for your organization
- **[๐Ÿ›๏ธ ADRs](docs/adr/)** - Architectural decision records documenting key design choices

### ๐ŸŒ Documentation in Other Languages

- **[๐Ÿ‡ง๐Ÿ‡ท Portuguรชs (Brasil)](docs/pt-BR/)** - Documentaรงรฃo em portuguรชs *(em desenvolvimento)*
- **[๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol](docs/es/)** - Documentaciรณn en espaรฑol *(en desarrollo)*

*Want to help translate the documentation? Check our [contribution guide](docs/CONTRIBUTING.md#internationalization)!*

## ๐Ÿค Want to Contribute?

Awesome! StackCode is an open-source project, and we welcome contributions.

To get started, please read our **[Contribution Guide](CONTRIBUTING.md)**. It has everything you need to know about our workflow, code standards, and how to submit your pull requests.
To get started, please read our **[Contribution Guide](docs/CONTRIBUTING.md)**. It has everything you need to know about our workflow, code standards, and how to submit your pull requests.

## ๐Ÿ“ License

Expand Down
294 changes: 294 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
# StackCode Architecture

StackCode is a comprehensive DevOps toolkit designed as a monorepo with multiple interconnected packages. This document outlines the project's architecture, design principles, and component interactions.

## ๐Ÿ—๏ธ High-Level Architecture

StackCode follows a **modular monorepo architecture** with clear separation of concerns across different packages. The project is structured to maximize code reuse, maintainability, and extensibility.

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ StackCode Ecosystem โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ CLI Package โ”‚ VS Code Extension โ”‚
โ”‚ (@stackcode/cli) โ”‚ (stackcode-vscode) โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Command Layer โ”‚ โ”‚ โ”‚ Extension Commands โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ init โ”‚ โ”‚ โ”‚ โ”œโ”€ Dashboard Provider โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ generate โ”‚ โ”‚ โ”‚ โ”œโ”€ File/Git Monitors โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ commit โ”‚ โ”‚ โ”‚ โ”œโ”€ Notification Manager โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ git โ”‚ โ”‚ โ”‚ โ””โ”€ Webview UI โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ release โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”œโ”€ validate โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€ config โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Shared Foundation โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Core Package โ”‚ i18n Package โ”‚
โ”‚ (@stackcode/core) โ”‚ (@stackcode/i18n) โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Business Logic โ”‚ โ”‚ โ”‚ Internationalization โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ Generators โ”‚ โ”‚ โ”‚ โ”œโ”€ Locale Management โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ Validators โ”‚ โ”‚ โ”‚ โ”œโ”€ Translation System โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ GitHub API โ”‚ โ”‚ โ”‚ โ””โ”€ Language Detection โ”‚ โ”‚
โ”‚ โ”‚ โ”œโ”€ Release Mgmt โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ โ”‚ โ”œโ”€ Scaffolding โ”‚ โ”‚ โ”‚
โ”‚ โ”‚ โ””โ”€ Templates โ”‚ โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
```

## ๐Ÿ“ฆ Package Structure

### 1. **@stackcode/cli** - Command Line Interface
**Purpose:** Primary user interface for StackCode functionality.

**Key Components:**
- **Command Layer:** Entry points for all CLI operations
- **Command Handlers:** Individual command implementations
- **Interactive Prompts:** User guidance and input collection
- **Error Handling:** Consistent error reporting and recovery

**Architecture:**
```typescript
cli/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ index.ts # Main CLI entry point
โ”‚ โ”œโ”€โ”€ commands/ # Command implementations
โ”‚ โ”‚ โ”œโ”€โ”€ init.ts # Project scaffolding
โ”‚ โ”‚ โ”œโ”€โ”€ generate.ts # File generation
โ”‚ โ”‚ โ”œโ”€โ”€ commit.ts # Conventional commits
โ”‚ โ”‚ โ”œโ”€โ”€ git.ts # Git workflow management
โ”‚ โ”‚ โ”œโ”€โ”€ release.ts # Version management
โ”‚ โ”‚ โ”œโ”€โ”€ validate.ts # Commit validation
โ”‚ โ”‚ โ””โ”€โ”€ config.ts # Configuration management
โ”‚ โ””โ”€โ”€ types/ # CLI-specific type definitions
โ””โ”€โ”€ test/ # Command tests
```

### 2. **@stackcode/core** - Business Logic Engine
**Purpose:** Contains all business logic, utilities, and templates.

**Key Components:**
- **Generators:** Project and file generation logic
- **Validators:** Commit message and project validation
- **GitHub Integration:** API interactions and automation
- **Release Management:** Semantic versioning and changelog generation
- **Template System:** Configurable project templates

**Architecture:**
```typescript
core/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ index.ts # Core exports
โ”‚ โ”œโ”€โ”€ generators.ts # Project/file generators
โ”‚ โ”œโ”€โ”€ validator.ts # Validation logic
โ”‚ โ”œโ”€โ”€ github.ts # GitHub API integration
โ”‚ โ”œโ”€โ”€ release.ts # Version management
โ”‚ โ”œโ”€โ”€ scaffold.ts # Project scaffolding
โ”‚ โ”œโ”€โ”€ utils.ts # Shared utilities
โ”‚ โ”œโ”€โ”€ types.ts # Core type definitions
โ”‚ โ””โ”€โ”€ templates/ # Project templates
โ”‚ โ”œโ”€โ”€ common/ # Shared template files
โ”‚ โ”œโ”€โ”€ node-js/ # Node.js templates
โ”‚ โ”œโ”€โ”€ react/ # React templates
โ”‚ โ”œโ”€โ”€ vue/ # Vue.js templates
โ”‚ โ”œโ”€โ”€ python/ # Python templates
โ”‚ โ”œโ”€โ”€ java/ # Java templates
โ”‚ โ”œโ”€โ”€ go/ # Go templates
โ”‚ โ”œโ”€โ”€ php/ # PHP templates
โ”‚ โ”œโ”€โ”€ gitignore/ # .gitignore templates
โ”‚ โ””โ”€โ”€ readme/ # README templates
โ””โ”€โ”€ test/ # Core logic tests
```

### 3. **@stackcode/i18n** - Internationalization
**Purpose:** Manages multi-language support across all packages.

**Features:**
- Dynamic locale detection
- Translation loading and caching
- Language switching
- Fallback mechanisms

**Architecture:**
```typescript
i18n/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ index.ts # i18n exports
โ”‚ โ””โ”€โ”€ locales/ # Translation files
โ”‚ โ”œโ”€โ”€ en.json # English translations
โ”‚ โ””โ”€โ”€ pt.json # Portuguese translations
```

### 4. **stackcode-vscode** - VS Code Extension
**Purpose:** Integrates StackCode functionality directly into VS Code.

**Key Components:**
- **Extension Commands:** VS Code command palette integration
- **File Monitors:** Real-time file change detection
- **Git Monitors:** Git state monitoring
- **Dashboard Provider:** Interactive project dashboard
- **Webview UI:** Rich user interface components
- **Notification System:** Proactive user guidance

**Architecture:**
```typescript
vscode-extension/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ extension.ts # Extension entry point
โ”‚ โ”œโ”€โ”€ commands/ # VS Code commands
โ”‚ โ”œโ”€โ”€ config/ # Configuration management
โ”‚ โ”œโ”€โ”€ monitors/ # File and Git monitoring
โ”‚ โ”œโ”€โ”€ notifications/ # Notification system
โ”‚ โ”œโ”€โ”€ providers/ # VS Code providers
โ”‚ โ”œโ”€โ”€ services/ # Extension services
โ”‚ โ””โ”€โ”€ webview-ui/ # React-based UI
โ””โ”€โ”€ test/ # Extension tests
```

## ๐Ÿ”„ Data Flow and Interactions

### Command Execution Flow
1. **User Input:** CLI command or VS Code action
2. **Command Parsing:** Yargs (CLI) or VS Code API
3. **Core Logic:** Business logic execution in `@stackcode/core`
4. **i18n Processing:** Localized messages via `@stackcode/i18n`
5. **Output:** Results displayed to user

### Cross-Package Dependencies
```mermaid
graph TD
A[CLI Package] --> C[Core Package]
A --> D[i18n Package]
B[VS Code Extension] --> C
B --> D
C --> D
```

## ๐ŸŽฏ Design Principles

### 1. **Separation of Concerns**
- **CLI Package:** User interface and command handling
- **Core Package:** Business logic and utilities
- **i18n Package:** Internationalization concerns
- **VS Code Extension:** IDE integration

### 2. **Dependency Inversion**
- Higher-level modules don't depend on lower-level modules
- Both depend on abstractions (interfaces)
- External dependencies are injected, not hardcoded

### 3. **Single Responsibility**
- Each package has a clearly defined purpose
- Functions and classes have single, well-defined responsibilities
- Templates are modular and composable

### 4. **Open/Closed Principle**
- System is open for extension (new templates, commands)
- Closed for modification (core logic remains stable)

## ๐Ÿ› ๏ธ Technology Stack

### Core Technologies
- **TypeScript:** Type safety and modern JavaScript features
- **Node.js:** Runtime environment
- **ESM:** Modern module system

### CLI-Specific
- **Yargs:** Command-line argument parsing
- **Inquirer:** Interactive command-line prompts

### VS Code Extension-Specific
- **VS Code API:** Extension development framework
- **React:** Webview UI components
- **Vite:** Build tool for webview assets

### Development Tools
- **Vitest/Jest:** Testing frameworks
- **ESLint:** Code linting
- **Prettier:** Code formatting
- **GitHub Actions:** CI/CD pipeline

## ๐Ÿ“ File Organization Strategy

### Monorepo Structure
```
StackCode/
โ”œโ”€โ”€ packages/ # All packages
โ”‚ โ”œโ”€โ”€ cli/ # CLI package
โ”‚ โ”œโ”€โ”€ core/ # Core business logic
โ”‚ โ”œโ”€โ”€ i18n/ # Internationalization
โ”‚ โ””โ”€โ”€ vscode-extension/ # VS Code extension
โ”œโ”€โ”€ docs/ # Project documentation
โ”œโ”€โ”€ scripts/ # Build and utility scripts
โ””โ”€โ”€ types/ # Shared type definitions
```

### Package Structure Conventions
Each package follows consistent patterns:
- `src/` - Source code
- `test/` - Test files
- `dist/` - Compiled output
- `package.json` - Package configuration
- `tsconfig.json` - TypeScript configuration
- `README.md` - Package documentation
- `CHANGELOG.md` - Version history

## ๐Ÿ”ง Build System

### TypeScript Compilation
- **Monorepo Build:** `tsc --build` for cross-package dependencies
- **Asset Copying:** Templates and locales copied to `dist/`
- **Executable Permissions:** CLI entry point marked as executable

### VS Code Extension Build
- **Extension Compilation:** TypeScript to JavaScript
- **Webview Build:** Vite for React components
- **Package Generation:** `.vsix` file creation

## ๐Ÿงช Testing Strategy

### Unit Testing
- **Core Logic:** Comprehensive tests for business logic
- **CLI Commands:** Command execution and error handling
- **Validators:** Input validation and error cases

### Integration Testing
- **Cross-Package:** Ensure packages work together
- **Template Generation:** Verify output correctness
- **GitHub Integration:** API interaction testing

## ๐Ÿš€ Deployment and Distribution

### NPM Packages
- **@stackcode/cli:** Published to NPM for global installation
- **@stackcode/core:** Internal package, not published separately
- **@stackcode/i18n:** Internal package, not published separately

### VS Code Extension
- **Marketplace:** Published to VS Code Marketplace
- **VSIX:** Direct installation package available

## ๐Ÿ”ฎ Extensibility Points

### Template System
- **Custom Templates:** Easy addition of new project types
- **Template Composition:** Combining multiple template sources
- **Dynamic Configuration:** Runtime template customization

### Command System
- **Plugin Architecture:** Future support for custom commands
- **Middleware Support:** Pre/post command hooks
- **Configuration Extension:** Custom validation and generation rules

## ๐Ÿ“š Additional Resources

- **[Contributing Guide](../CONTRIBUTING.md):** Development workflow and standards
- **[Stacks Documentation](STACKS.md):** Supported technology stacks
- **[Self-Hosting Guide](SELF_HOSTING_GUIDE.md):** Deployment options
- **[ADR Directory](adr/):** Architectural decision records
Loading
Loading