# OpenCodeHub
A modern, self-hosted Git platform for teams that want speed, control, and clean workflows.
--- ## Table of Contents - [Why OpenCodeHub](#why-opencodehub) - [Features](#features) - [Quick Start](#quick-start) - [Architecture](#architecture) - [Documentation](#documentation) - [CLI](#cli) - [API](#api) - [Security](#security) - [Deployment](#deployment) - [Contributing](#contributing) - [License](#license) --- ## Why OpenCodeHub Most teams eventually hit the same pain points: - **PRs are too large to review quickly** — Stacked PRs let you break changes into reviewable pieces - **Tooling is split across many services** — One platform for Git, PRs, CI/CD, issues, and wiki - **Data residency and security requirements** — Self-hosted by default, you control everything - **Merge queue complexity** — Stack-aware merge queue with speculative builds - **Slow review cycles** — AI-powered code review catches issues before human review OpenCodeHub is built for that reality. --- ## Features ### Core Platform | Feature | Status | Description | |---------|--------|-------------| | **Git Hosting** | Ready | HTTP (Smart Protocol) + SSH git push/pull | | **Pull Requests** | Ready | Comments, reviews, drafts, approvals, suggested changes | | **Issues** | Ready | Labels, milestones, project boards | | **Wiki** | Ready | Repository wiki with revision history | | **Organizations** | Ready | Teams, collaborators, repository settings | | **Branch Protection** | Ready | Required reviews, status checks, push restrictions | ### Delivery Workflows | Feature | Status | Description | |---------|--------|-------------| | **Stacked PRs** | Ready | Graphite-style stack workflows in web + CLI | | **Merge Queue** | Ready | Stack-aware queue with speculative builds and priority lanes | | **CI/CD Pipelines** | Ready | GitHub Actions-compatible engine + Docker-based runner | | **Webhooks** | Ready | Outbound webhooks with event filtering | | **Automations** | Ready | Workflow automation rules | ### Security & Governance | Feature | Status | Description | |---------|--------|-------------| | **Authentication** | Ready | JWT sessions, OAuth (GitHub, Google, GitLab), 2FA/TOTP | | **Authorization** | Ready | RBAC with roles, team permissions, collaborator levels | | **Rate Limiting** | Ready | Redis-backed per-endpoint rate limiting | | **CSRF Protection** | Ready | Double-submit cookie pattern | | **Secret Scanning** | Ready | Detect secrets in commits | | **Audit Logging** | Ready | Track all administrative actions | ### Extensibility | Feature | Status | Description | |---------|--------|-------------| | **REST API** | Ready | 140+ API routes | | **GraphQL** | Ready | Full GraphQL endpoint | | **OpenAPI** | Ready | Auto-generated OpenAPI spec | | **CLI** | Ready | 20+ command groups (`opencodehub-cli`) | | **Storage Adapters** | Ready | 8+ backends (S3, GCS, Azure, Google Drive, etc.) | --- ## Quick Start ### Prerequisites - Node.js >= 20 - npm or bun - git - PostgreSQL 14+ (recommended) or SQLite (dev) ### Docker (Fastest) ```bash # 1. Clone git clone https://github.com/swadhinbiswas/OpencodeHub.git cd OpenCodeHub # 2. Configure cp .env.example .env # Edit .env with your settings # 3. Start docker-compose up -d # 4. Create admin user docker-compose exec app bun run scripts/seed-admin.ts # 5. Open open http://localhost:4321 ``` ### NAS & Edge Deployment (Cloudflare / Tailscale) Deploying on a home server or NAS? Use the provided `docker-compose.nas.yml` which includes `cloudflared` and `tailscale` configurations for seamless zero-trust exposure without port forwarding. ```bash # Expose via Cloudflare Tunnel TUNNEL_TOKEN=your_token docker-compose -f docker-compose.nas.yml --profile cloudflare up -d # OR Expose via Tailscale TS_AUTHKEY=your_key docker-compose -f docker-compose.nas.yml --profile tailscale up -d ``` See the [NAS Deployment Guide](docs/administration/deploy-nas.md) and [Exposing NAS Guide](docs/administration/expose-nas.md) for full details. ### Manual Setup ```bash # 1. Install dependencies npm install # 2. Configure environment cp .env.example .env # Edit .env (SQLite defaults work for dev) # 3. Initialize database npm run db:push # 4. Create admin user bun run scripts/seed-admin.ts # 5. Start development server npm run dev ``` App URL: `http://localhost:3000` (dev) or `http://localhost:4321` (Docker) --- ## Architecture ``` Clients (Browser / Git CLI / och CLI) | v OpenCodeHub Platform (Astro SSR + React) |-- Web UI |-- REST API (140+ routes) |-- GraphQL Endpoint |-- Git HTTP Server |-- SSH Git Server (port 2222) | v Persistence Layer |-- PostgreSQL / SQLite / Turso (Drizzle ORM) |-- Redis (sessions, queues, caching) |-- Pluggable Storage (S3, GCS, Azure, local, etc.) ``` ### Runtime Processes | Process | Command | Purpose | |---------|---------|---------| | Main App | `npm run dev` | Web UI + API + Git HTTP | | SSH Git | `npm run git:start` | SSH git push/pull | | Worker | `npm run worker:start` | Background jobs | | Runner | `npm run runner:start` | CI/CD pipeline execution | ### Tech Stack | Layer | Technology | |-------|-----------| | Framework | Astro 4.x (SSR, Node standalone) | | UI | React 18 + Tailwind CSS + Radix UI | | Database | Drizzle ORM (PostgreSQL, SQLite, Turso) | | Auth | JWT (jose) + bcryptjs + TOTP (otplib) + OAuth (arctic) | | Git | Native git CLI + simple-git + isomorphic-git | | SSH | ssh2 library | | CI/CD | Dockerode (Docker API) | | Storage | Abstract adapter pattern (8+ backends) | | Queue | BullMQ + Redis | | CLI | Commander.js + Inquirer + simple-git | --- ## Documentation Comprehensive documentation is available in the `docs/` directory: - **[Getting Started](docs/getting-started/installation.md)** — Installation and setup - **[Features](docs/features/)** — Stacked PRs, AI review, merge queue, CI/CD - **[Guides](docs/guides/)** — Team workflows, branch protection, webhooks - **[API Reference](docs/api/rest-api.md)** — REST API documentation - **[Administration](docs/administration/)** — Deployment, security, monitoring - **[Development](docs/development/)** — Architecture, contributing, testing - **[Tutorials](docs/tutorials/)** — Hands-on guides --- ## CLI The companion CLI is published as `opencodehub-cli`: ```bash # Install npm install -g opencodehub-cli # Authenticate och auth login --url http://localhost:4321 # Stack workflow och stack create feature/auth-step-1 och stack submit och stack sync # Merge queue och queue list och queue add
Ready to get started?
Install OpenCodeHub |
Quick Start |
Learn Stacked PRs