OpenCodeHub
OpenCodeHub is a fully self-hosted, open-source Git platform designed as a modern alternative to GitHub and GitLab. It combines Git repository hosting, pull requests, stacked PRs, merge queues, CI/CD pipelines, AI-powered code review, issue tracking, organizations, webhooks, automation, REST and GraphQL APIs, and a dedicated CLI into a single deployable platform. The platform is built as a modular monolith with optional background workers and CI runners, allowing it to run on a single machine while remaining architected for horizontal scaling. It supports Git operations over both HTTP Smart Protocol and SSH, pluggable local/S3-compatible storage, multiple database backends, Docker-based CI execution, Redis-backed queues, and integrations with multiple AI providers.
- architecture
- Modular Monolith
- database tables
- 38+
- rest api routes
- 140+
- cli command groups
- 20+
- ai providers
- 10+
- deployment models
- Single-node + Horizontally Scalable
OpenCodeHub is an open-source developer platform that gives teams complete control over their source code and development infrastructure without vendor lock-in or per-seat pricing. It consolidates Git hosting, pull requests, CI/CD, code review, automation, and developer workflows into a single self-hosted platform.
The modular architecture operates as a single application for lightweight setups or scales horizontally using shared PostgreSQL, Redis, external object storage, workers, and runner pools.
Core Capabilities
Git Hosting
- Protocols: HTTP Smart Git protocol, Git over SSH
- Repository Management: Public and private repositories, forks, mirroring, deploy keys, granular permissions
- Storage & Processing: Native Git process execution, Git LFS (Large File Storage) support
Pull Requests & Collaboration
- Review Workflows: Inline comments, approvals, suggested changes, draft pull requests, required reviews
- Branch Management: Branch protection, required status checks, stacked pull requests
- Automation: Merge queue with speculative builds, developer productivity metrics
CI/CD
OpenCodeHub includes a GitHub Actions-compatible workflow engine. Workflows are queued through Redis/BullMQ and executed by Docker-based runners with resource and capability restrictions.
- Triggers:
- Push events
- Pull requests
- Scheduled jobs
- Manual dispatch
AI Code Review
Integrates AI-powered code review rules and results directly into the pull request workflow across multiple providers:
- OpenAI
- Anthropic
- Google Gemini
- Groq
- Ollama
- OpenRouter
- Mistral
Issues & Project Management
- Tracking: Issues, labels, milestones
- Views: Project boards, Kanban workflows, custom project fields
- Documentation: Built-in wiki with complete revision history
Authentication & Security
- Authentication: JWT-based auth, 2FA/TOTP, SSO/SAML, OAuth (GitHub, Google, GitLab)
- Access Control: Role-Based Access Control (RBAC), team permissions, personal access tokens, deploy keys
- Security & Auditing: Audit logs, rate limiting, secret scanning, encrypted workflow and AI credentials
API & Extensibility
- APIs: REST APIs, GraphQL API, OpenAPI specification
- Integrations: Webhooks, rule-based automations, SDK packages, CLI, pluggable storage adapters
CLI (och)
OpenCodeHub provides the och command-line client to streamline developer workflows:
och auth login
och stack create feature/auth-step-1
och stack submit
och stack sync
och queue list
och queue add <pr-number>
och focus
Architecture
OpenCodeHub follows a modular-monolith architecture. The main application handles the web UI, APIs, Git HTTP operations, and core business logic, while optional SSH, worker, and runner processes allow workloads to be separated as deployments scale.
Clients
├── Web Browser
├── Git CLI over HTTP
├── Git CLI over SSH
└── OpenCodeHub CLI
↓
OpenCodeHub Platform
├── Astro + React Web UI
├── REST API
├── GraphQL API
├── Git Smart HTTP Server
├── SSH Git Server
├── CI/CD Runner
└── Background Workers
↓
Infrastructure
├── PostgreSQL / SQLite / Turso
├── Redis / BullMQ
└── Local / S3-compatible Storage
Technical Stack & Implementation
The codebase is organized around dedicated modules for authentication, repositories, pull requests, stacked PRs, merge queues, permissions, webhooks, automation, AI review, pipelines, storage, and validation.
| Component | Technology |
|---|---|
| Frontend UI | Astro SSR, React, Tailwind CSS, Radix UI |
| Database & ORM | Drizzle ORM (Multi-driver: PostgreSQL, SQLite, Turso/LibSQL) |
| Async & Queueing | Redis, BullMQ |
| CI/CD Execution | Docker containers |
| Git Operations | Native Git processes |
| Storage Layer | Pluggable drivers (Local filesystem, S3-compatible object storage) |
The hard part
Technical Challenges
Building a Git Platform from the Protocol Layer
One of the most significant engineering challenges was implementing a complete Git hosting platform rather than simply providing a web interface around repositories. OpenCodeHub directly supports Git Smart HTTP and Git-over-SSH protocols, requiring deep integration with Git internals.
Key challenges included:
- Implementing Git Smart HTTP request/response flows
- Supporting Git clone, fetch, push, and pull operations
- Managing repository authorization and access control
- Executing Git processes securely and efficiently
- Handling packfile generation and transfer
- Implementing SSH public-key authentication
- Enforcing repository-level permissions
- Maintaining compatibility with standard Git clients and tooling
This foundation allows developers to use OpenCodeHub with existing Git workflows without requiring custom clients or plugins.
Designing a Scalable Self-Hosted Architecture
OpenCodeHub was designed to serve both individual developers and larger organizations while remaining simple to deploy and maintain.
The architecture follows a modular monolith approach with optional distributed components, providing a balance between simplicity and scalability.
Major architectural challenges included:
- Supporting single-server deployments and larger distributed installations
- Designing stateless application services
- Coordinating background workers and CI runners
- Managing shared infrastructure components
- Supporting horizontal scaling
- Maintaining operational simplicity for self-hosted environments
The resulting architecture enables users to start with a minimal deployment and scale incrementally as requirements grow.
Implementing Stacked Pull Requests
Traditional pull request systems assume that every pull request targets a single base branch independently. Stacked pull requests introduce branch dependencies that require additional coordination and synchronization.
OpenCodeHub includes native support for stacked development workflows, which required building:
- Branch dependency tracking
- Pull request stack relationships
- Automatic stack synchronization
- Stack-aware merge operations
- Dependency validation mechanisms
- Dedicated CLI workflows for managing stacks
These capabilities allow developers to break large features into smaller reviewable units while preserving development velocity.
Building a Merge Queue with CI Integration
The merge queue system needed to safely merge changes while respecting pull request dependencies and ensuring code quality.
A major challenge was implementing speculative CI execution, where queued pull requests are validated in the order they are expected to merge before they actually reach the target branch.
Core challenges included:
- Queue management and prioritization
- Dependency-aware merge ordering
- Automatic queue rebalancing
- CI status tracking
- Speculative merge validation
- Failure recovery and rollback handling
- Concurrent queue processing
This ensures that only validated changes are merged while minimizing integration conflicts and reducing broken main branches.
Creating a Self-Hosted CI/CD Engine
Rather than depending entirely on external CI providers, OpenCodeHub includes a built-in CI/CD engine compatible with GitHub Actions workflows.
Developing this subsystem required building:
- Workflow definition parsing
- Job scheduling and orchestration
- Distributed execution queues using Redis and BullMQ
- Docker-based isolated execution environments
- Workflow logs and artifact handling
- Real-time execution monitoring
- Result streaming back to the platform
The CI/CD engine enables organizations to maintain full control over their build infrastructure while remaining compatible with familiar workflow definitions.
Supporting Multiple Infrastructure Providers
OpenCodeHub is designed to be infrastructure-agnostic, allowing organizations to choose technologies that best fit their environment.
To achieve this flexibility, the platform uses adapter-based abstractions for storage and persistence layers.
Supported providers include:
Databases
- PostgreSQL
- SQLite
- Turso
- Other SQL-compatible databases
Object Storage
- MinIO
- Cloudflare R2
- AWS S3
- S3-Compatible Providers
- Local Filesystem Storage
Key challenges included:
- Designing provider-independent interfaces
- Maintaining consistent behavior across providers
- Supporting migrations and portability
- Optimizing performance for different backends
- Minimizing vendor lock-in
This approach allows users to deploy OpenCodeHub using local infrastructure, cloud providers, or hybrid environments.
Security
Because OpenCodeHub directly manages source code, repositories, CI workloads, deployment credentials, and AI provider integrations, security is a foundational design requirement.
The platform implements multiple layers of defense to protect users, repositories, and infrastructure.
Authentication & Authorization
- Role-Based Access Control (RBAC)
- JWT Authentication
- Personal Access Tokens (PATs)
- Repository-level permissions
- Organization and team permissions
- SSH public-key authentication
Application Security
- CSRF protection
- Rate limiting
- Request validation
- Session management
- API security controls
Secrets Management
- Encrypted secret storage
- Secure credential handling
- Environment isolation
- Secret access controls
Repository Security
- Secret scanning
- Repository access auditing
- Protected branches
- Merge restrictions
- Commit verification support
Infrastructure Security
- Docker container isolation
- CI runner sandboxing
- Secure process execution
- Resource usage controls
Auditing & Compliance
- Audit logging
- Authentication event tracking
- Repository activity monitoring
- Administrative action history
These security mechanisms work together to provide enterprise-grade protection while maintaining a developer-friendly experience for self-hosted environments.
Outcome
Final Outcome
OpenCodeHub evolved from an idea for source-code hosting into a comprehensive self-hosted developer platform designed to provide organizations and individual developers with complete ownership of their software development infrastructure.
Rather than focusing solely on Git repository management, the platform integrates source control, collaboration, automation, CI/CD, and developer tooling into a unified system.
Core Platform Capabilities
OpenCodeHub provides a full suite of development workflow features, including:
- Full Git repository hosting
- Git over HTTP and SSH
- Pull requests and code review
- Stacked pull request workflows
- Stack-aware merge queues
- GitHub Actions-compatible CI/CD
- Docker-based isolated runners
- AI-assisted code review
- Issues and project management
- Organizations and Role-Based Access Control (RBAC)
- Webhooks and workflow automation
- REST APIs
- GraphQL APIs
- OpenAPI support
- Dedicated developer CLI
- Pluggable object storage
- Multiple database backends
- Self-hosted deployment options
These capabilities allow development teams to manage the entire software delivery lifecycle from a single platform while maintaining full control over infrastructure and data.
Deployment Flexibility
A primary design goal of OpenCodeHub was to support a wide range of deployment scenarios, from individual developers running the platform on a single server to organizations operating larger distributed environments.
The platform architecture supports:
Single-Server Deployments
Ideal for:
- Individual developers
- Small teams
- Internal projects
- Homelab environments
- Startups
Components can run on a single machine with minimal operational overhead while still providing the complete platform experience.
Distributed Deployments
For larger organizations, OpenCodeHub can scale horizontally using shared infrastructure services, including:
- PostgreSQL for centralized persistence
- Redis for queues and distributed coordination
- External object storage for repositories and artifacts
- Dedicated worker processes
- Distributed CI/CD runner pools
- Independent service scaling
This approach enables organizations to expand capacity without redesigning their deployment architecture.
Architectural Vision
The final architecture combines simplicity and scalability through a modular monolith design with optional distributed components.
Key architectural principles include:
- Self-hosted first
- Open standards and interoperability
- Infrastructure flexibility
- Horizontal scalability
- Secure-by-default design
- Developer-centric workflows
- Git-native operations
- Cloud and on-premise compatibility
By balancing operational simplicity with enterprise-grade capabilities, OpenCodeHub provides a practical alternative to proprietary developer platforms while remaining accessible to both individuals and organizations.
Conclusion
OpenCodeHub ultimately became much more than a Git hosting service. It evolved into a complete developer platform that unifies source control, collaboration, automation, CI/CD, AI-assisted workflows, and infrastructure flexibility within a fully self-hosted ecosystem.
The platform delivers a modern developer experience while giving teams complete ownership of their code, workflows, infrastructure, and deployment strategy.
What I'd do differently
Lessons Learned
Building OpenCodeHub provided valuable insights into the challenges of creating a modern developer platform. The project involved far more than implementing features; it required solving problems across Git internals, distributed systems, CI/CD orchestration, security, scalability, and developer experience.
Git Is More Complex Than It Appears
At the beginning of the project, Git hosting seemed primarily like repository storage and a web interface. In practice, supporting Git as a hosting platform required understanding protocol-level behavior, packfile transfers, authentication mechanisms, repository permissions, and client compatibility.
Key lesson:
Building a Git platform means building around Git protocols, not just repositories.
Developer Experience Is as Important as Features
Many technically correct solutions created unnecessary friction for users. Features such as stacked pull requests, merge queues, CI/CD workflows, and repository management had to be designed around how developers actually work.
Key lesson:
The best feature is the one developers can use without reading documentation.
Simplicity Enables Adoption
A highly distributed microservices architecture initially appeared attractive, but it would have significantly increased deployment and operational complexity.
The modular monolith approach provided most of the benefits while keeping installation, debugging, and maintenance straightforward.
Key lesson:
Architecture should optimize for maintainability before scalability.
Self-Hosting Requires Different Design Decisions
Many cloud-native assumptions do not apply to self-hosted environments. Users may deploy on a single VPS, homelab server, private cloud, or enterprise infrastructure.
This required:
- Flexible deployment models
- Minimal infrastructure requirements
- Portable storage solutions
- Database flexibility
- Clear upgrade paths
Key lesson:
Self-hosted software succeeds when deployment is simple and infrastructure choices remain optional.
CI/CD Systems Are Distributed Systems
Building a workflow engine revealed that CI/CD is fundamentally a distributed systems problem.
Challenges included:
- Job scheduling
- Queue management
- Worker coordination
- Failure recovery
- Execution isolation
- Log streaming
- Resource allocation
Key lesson:
A reliable CI/CD platform depends more on orchestration and fault tolerance than on workflow execution itself.
Security Must Be Built In From Day One
As the platform evolved to handle repositories, secrets, SSH keys, CI workloads, and AI integrations, security became a core architectural concern rather than an afterthought.
Important areas included:
- Authentication
- Authorization
- Secret management
- Audit logging
- Secure execution environments
- Repository protection
Key lesson:
Security is easiest to implement at the architecture stage and hardest to retrofit later.
Abstraction Prevents Vendor Lock-In
Supporting multiple databases and storage providers required creating clean interfaces between platform logic and infrastructure services.
This approach provided:
- Easier testing
- Greater deployment flexibility
- Reduced vendor dependency
- Future extensibility
Key lesson:
Well-designed abstractions increase long-term platform flexibility without significantly increasing complexity.
AI Features Need Context, Not Just Models
Adding AI-assisted code review demonstrated that model quality alone does not guarantee useful results.
Effective AI workflows require:
- Repository context
- Pull request context
- File-level understanding
- Permission controls
- Developer feedback loops
Key lesson:
Context quality often matters more than model size.
Observability Saves Time
Many production issues became easier to diagnose when logs, metrics, audit trails, and execution traces were available.
Investing in observability early reduced debugging time and improved operational confidence.
Key lesson:
If a system cannot be observed, it cannot be reliably operated.
Scalability Should Be Earned
Premature optimization can slow development and increase complexity. Many scaling concerns were solved more effectively after real-world usage patterns emerged.
The platform benefited from focusing first on correctness, reliability, and maintainability before introducing more advanced scaling mechanisms.
Key lesson:
Build for today's requirements, but leave room for tomorrow's growth.
Final Reflection
The most important lesson from OpenCodeHub was that building a developer platform is not simply about creating features. It is about designing reliable systems, intuitive workflows, secure infrastructure, and flexible deployment models that developers can trust every day.
OpenCodeHub ultimately demonstrated that a self-hosted platform can provide modern collaboration, automation, CI/CD, and AI-powered development workflows while remaining portable, extensible, and fully under the control of its users.