# Archipelago Development Rules **Mission**: Build a production-ready, open-source Bitcoin Node OS that's secure, minimal, and user-friendly from day one. **Philosophy**: Code in development should mirror production quality. Write it right the first time. --- ## Table of Contents 1. [Project Structure & Location](#project-structure--location) 2. [Open Source & Licensing](#open-source--licensing) 3. [Production-Ready Development](#production-ready-development) 4. [Architecture & System Design](#architecture--system-design) 5. [Backend Development (Rust)](#backend-development-rust) 6. [Frontend Development (Vue.js)](#frontend-development-vuejs) 7. [Container & Security](#container--security) 8. [Code Quality & Testing](#code-quality--testing) 9. [Documentation](#documentation) 10. [Common Mistakes](#common-mistakes) --- ## Project Structure & Location ### CRITICAL: Workspace-Relative Paths Only - ❌ **NEVER** reference absolute user paths (`/Users/username/...`) in code, scripts, or documentation - ✅ **ALWAYS** use workspace-relative paths: `./`, `../`, or environment variables - ✅ All files must be created in the workspace, never in external directories - ✅ When copying from external sources, copy TO workspace, then update all references ### File Creation Rules - ✅ Create files directly in the workspace using relative paths - ❌ Never assume files exist elsewhere - check first, create if missing - ✅ Use environment variables for paths that change between environments - ✅ Document all path dependencies in README or setup guides --- ## Open Source & Licensing ### License Compliance - ✅ Project is **open source** under [specify license: MIT/Apache 2.0/GPL] - ✅ All dependencies must be compatible with our license - ✅ Check license compatibility before adding dependencies - ✅ Document all third-party licenses in `LICENSES.md` or `THIRD_PARTY_NOTICES.md` ### Third-Party Code - ✅ Use permissive licenses (MIT, Apache 2.0, BSD) when possible - ⚠️ Be cautious with GPL/AGPL dependencies (viral licensing) - ✅ Always include license headers in source files - ✅ Document attribution for copied/adapted code ### Community Standards - ✅ Follow [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct - ✅ Provide clear CONTRIBUTING.md with guidelines - ✅ Use semantic versioning (SemVer) for releases - ✅ Maintain comprehensive changelog (CHANGELOG.md) - ✅ Accept community contributions via pull requests - ✅ Respond to issues and PRs within reasonable timeframes ### Open Source Best Practices - ✅ Never commit secrets, API keys, or credentials - ✅ Use `.gitignore` to exclude sensitive/generated files - ✅ Keep commit messages clear and descriptive - ✅ Write documentation as if explaining to new contributors - ✅ Include setup/installation scripts for easy onboarding --- ## Production-Ready Development ### Development = Production Mindset - 🎯 **CRITICAL**: Write production-quality code from the start - ✅ No "TODO: Fix before production" comments - fix it now - ✅ No hardcoded values - use configuration from day one - ✅ No "works on my machine" - test in clean environments - ✅ Security is NOT optional - implement it in development ### Configuration Management - ✅ Use `.env` files for environment-specific configuration - ✅ Provide `.env.example` with all required variables - ✅ Never commit `.env` files to git - ✅ Validate configuration at startup with clear error messages - ✅ Support multiple environments: dev, staging, production ### Infrastructure as Code - ✅ All infrastructure should be reproducible from code - ✅ Container definitions = production-ready from first commit - ✅ Scripts should work on fresh systems (document prerequisites) - ✅ Use Alpine Linux base for containers (production-ready minimal OS) - ✅ Test multi-arch builds early (ARM64, x86_64) ### Development Environments - ✅ Provide dev containers or Docker Compose setups - ✅ Mock external services for local development - ✅ Minimize differences between dev and production - ✅ Document all system prerequisites clearly - ✅ Use version managers for language runtimes (rustup, nvm) ### Continuous Integration Preparation - ✅ Write code that can be automatically tested - ✅ Keep builds fast (parallelize, cache dependencies) - ✅ Lint and format code automatically - ✅ Run security checks on dependencies - ✅ Test on multiple platforms (Linux, macOS, ARM64) --- ## Design System & Styling ### Tailwind CSS Rules - ✅ **ALWAYS** create global utility classes in `neode-ui/src/style.css` or a dedicated `tailwind.css` - ❌ **NEVER** use inline Tailwind classes directly in components - ✅ Create semantic class names: `.glass-card`, `.glass-button`, `.nav-tab-active` - ✅ Use CSS variables for design tokens: `--color-primary`, `--spacing-base` ### Design Standards (From Memory) - **Font**: Avenir Next font family (preferred) - **Padding**: 4px grid system, 16px default padding - **Containers**: iOS-style glassmorphism - Background: `rgba(255,255,255,0.15)` - Backdrop blur: `20px` - Subtle white borders - **Backgrounds**: Persistent background images (not dark themes) - **Animations**: Smooth 2s splash screens with logo draw/glitch animations ### Example Global Classes ```css .glass-card { background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 16px; padding: 16px; /* 4px grid */ } .glass-button { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.15); transition: all 0.2s ease; } .glass-button:hover { background: rgba(255, 255, 255, 0.2); } ``` --- ## Architecture & System Design ### Docker & Podman Architecture - ✅ **Development**: Use Docker Compose with official Docker images - ✅ **Production**: Use Podman with same Docker images on Alpine Linux - ✅ **ALWAYS** use standard Docker Hub images (never proprietary formats) - ✅ Use our own container orchestration (`core/container/`) - ✅ Use our own security modules (`core/security/`) - ✅ Use our own performance modules (`core/performance/`) ### Backend Architecture - ✅ Use `archipelago-container` crate for container management - ✅ Use our RPC endpoints in `core/archipelago/src/` - ✅ For development: Use mock backend for UI work when possible - ✅ All new features must use our modules (`archipelago-*` crates) - ✅ Build Archipelago-native implementations, not wrappers ### System Architecture Principles - ✅ **Alpine Linux Base**: 130MB minimal, secure, multi-arch - ✅ **Podman Only**: Rootless containers, no Docker dependencies - ✅ **Manifest-Driven**: All apps defined by YAML manifests - ✅ **Security First**: Read-only filesystems, capability dropping, network isolation - ✅ **Dependency Resolution**: Automatic dependency management between apps - ✅ **Health Monitoring**: Built-in health checks and auto-restart ### Multi-Architecture Support - ✅ Support both ARM64 (Raspberry Pi) and x86_64 from day one - ✅ Test builds on both architectures regularly - ✅ Use multi-arch container images - ✅ Document architecture-specific differences ### Modular Design - ✅ Each crate in `core/` should be independent and reusable - ✅ Minimize coupling between modules - ✅ Define clear interfaces between components - ✅ Use traits for abstraction and testability --- ## Container & Security ### App Manifest Rules (Production Standards) - ✅ **ALWAYS** create manifests in `apps/{app-id}/manifest.yml` - ✅ Follow the manifest specification in `docs/app-manifest-spec.md` - ✅ Use semantic versioning: `MAJOR.MINOR.PATCH` - ✅ Include security policies, resource limits, health checks - ✅ Define explicit dependencies with version constraints - ✅ Include license information and attribution - ✅ Document configuration options clearly - ✅ Provide default values that are secure ### Container Orchestration - ✅ Use `archipelago_container::PodmanClient` for all container operations - ✅ Use `archipelago_container::AppManifest` for manifest parsing - ✅ Use `archipelago_container::DependencyResolver` for dependency management - ❌ Never use Docker directly - always use Podman via our client - ✅ Implement graceful shutdown (handle SIGTERM) - ✅ Set resource limits (CPU, memory, disk) - ✅ Monitor container health continuously ### Security First (CRITICAL - Production Requirement) - 🔒 **Security is NOT optional** - every container must be hardened #### Container Security - ✅ **ALWAYS** set `readonly_root: true` unless explicitly needed - ✅ **ALWAYS** drop all capabilities, add only required ones - ✅ **ALWAYS** use isolated networks (never `host` network unless required) - ✅ **ALWAYS** run as non-root user (UID > 1000) - ✅ **ALWAYS** set `no-new-privileges: true` - ✅ Use AppArmor/SELinux profiles from `core/security/` - ✅ Implement seccomp profiles to restrict syscalls #### Image Security - ✅ **ALWAYS** verify container images with Cosign signatures - ✅ Use official base images from trusted registries - ✅ Pin image versions (never use `latest` tag) - ✅ Scan images for vulnerabilities (Trivy, Grype) - ✅ Rebuild images regularly for security updates - ✅ Generate and publish SBOM (Software Bill of Materials) #### Secrets Management - ✅ **NEVER** hardcode secrets in code or config files - ✅ Use encrypted secrets storage (`core/security/secrets_manager.rs`) - ✅ Inject secrets at runtime only (environment variables or mounted files) - ✅ Rotate secrets regularly - ✅ Use minimal secret scopes (principle of least privilege) - ✅ Clear secrets from memory after use - ✅ Log secret access for audit trails (without logging values) #### Network Security - ✅ Use isolated bridge networks per app - ✅ Implement firewall rules (iptables/nftables) - ✅ Rate limit API endpoints - ✅ Use TLS for all external communication - ✅ Support Tor for privacy-sensitive apps - ✅ Implement intrusion detection (fail2ban) #### Data Security - ✅ Encrypt sensitive data at rest - ✅ Use encrypted volumes for secrets - ✅ Implement secure backup/restore - ✅ Sanitize logs (no secrets in logs) - ✅ Implement data retention policies - ✅ Support secure data deletion --- ## Frontend Development (Vue.js) ### Vue.js Component Rules - ✅ Use Composition API (`