| 1 | <h1 align="center"> |
| 2 | Ghost |
| 3 | </h1> |
| 4 | |
| 5 | <p align="center">A git hosting platform</p> |
| 6 | |
| 7 |  |
| 8 | |
| 9 | > [!Note] |
| 10 | > This is just an engineering reproduction and should not be trusted with actual data(yet). |
| 11 | |
| 12 | Self-hosted git. Push over HTTP or SSH, browse the code, open pull requests, |
| 13 | review the diff, merge. Object storage holds the truth, local disk is a cache. |
| 14 | |
| 15 | ## Screens |
| 16 | |
| 17 | Repository listing. Directories first, last commit per row, branch switcher. |
| 18 | |
| 19 |  |
| 20 | |
| 21 | File view with syntax highlighting and a raw download. |
| 22 | |
| 23 |  |
| 24 | |
| 25 | Commit history for any branch. |
| 26 | |
| 27 |  |
| 28 | |
| 29 | Pull request list, filtered by state. Open count sits on the tab. |
| 30 | |
| 31 |  |
| 32 | |
| 33 | Pull request overview: markdown description, comments, live merge state. Author |
| 34 | or anyone with write access can edit the title and description in place. |
| 35 | |
| 36 |  |
| 37 | |
| 38 | Split diff, computed from the merge base rather than the branch tips. |
| 39 | |
| 40 |  |
| 41 | |
| 42 | ## Features |
| 43 | |
| 44 | - Push and pull over HTTP, authenticated with a personal access token |
| 45 | - Push and pull over SSH, authenticated with a key on the account, with no shell behind it |
| 46 | - Trees, blobs, raw files, branch switching, commit history |
| 47 | - Forks, stars, public and private repositories |
| 48 | - Pull requests across branches and across forks, with a real merge commit |
| 49 | - Comments with markdown, editable title and description |
| 50 | - Issues with comments, timeline events, labels, assignees, search and filters |
| 51 | - GPG-signed commits shown as verified, against keys an account uploads |
| 52 | - Accounts, sessions, organizations, API keys (better-auth) |
| 53 | |
| 54 | Not built yet: webhooks, CI. |
| 55 | |
| 56 | ## Stack |
| 57 | |
| 58 | | Layer | Choice | |
| 59 | | -------- | ----------------------------------------------------- | |
| 60 | | Web | Next.js 16, React 19, Tailwind, shadcn/ui | |
| 61 | | API | NestJS 12, OpenAPI client generated for the web | |
| 62 | | Database | Postgres, Drizzle | |
| 63 | | Storage | S3-compatible bucket (RustFS locally) | |
| 64 | | Runtime | Bun, Turborepo workspace | |
| 65 | |
| 66 | ## Running it |
| 67 | |
| 68 | Needs Bun and Docker. |
| 69 | |
| 70 | ```sh |
| 71 | docker compose up -d # Postgres, RustFS, and the ghost bucket |
| 72 | bun install |
| 73 | cp .env.example .env # set BETTER_AUTH_SECRET, the rest matches compose |
| 74 | bun run db:migrate |
| 75 | bun run dev |
| 76 | ``` |
| 77 | |
| 78 | Web on `http://localhost:3000`, API on `http://localhost:3001`, RustFS console |
| 79 | on `http://localhost:9001`. |
| 80 | |
| 81 | Push an existing repository. The password is a personal access token from |
| 82 | account settings, not the login password. |
| 83 | |
| 84 | ```sh |
| 85 | git remote add origin http://localhost:3001/<username>/<repo>.git |
| 86 | git push -u origin main |
| 87 | ``` |
| 88 | |
| 89 | For SSH, give the API a host key and add your public key under |
| 90 | **Settings → Security**: |
| 91 | |
| 92 | ```sh |
| 93 | ssh-keygen -t ed25519 -N '' -f ghost_host_key |
| 94 | echo "GIT_SSH_HOST_KEY=$(base64 -i ghost_host_key)" >> .env |
| 95 | git remote set-url origin ssh://git@localhost:1031/<username>/<repo>.git |
| 96 | ``` |
| 97 | |
| 98 | Without `GIT_SSH_HOST_KEY` the listener never starts and git speaks HTTP only. |
| 99 | |
| 100 | ## Layout |
| 101 | |
| 102 | ``` |
| 103 | apps/api NestJS API and the git HTTP transport |
| 104 | apps/web Next.js frontend |
| 105 | apps/docs Fumadocs user guide, e.g. how to sign commits (port 3003) |
| 106 | packages/db Drizzle schema and migrations |
| 107 | docs/ Design decisions, one file each |
| 108 | ``` |
| 109 | |
| 110 | ## User guide |
| 111 | |
| 112 | [`apps/docs`](apps/docs) is the guide for people using an instance: how to |
| 113 | generate an SSH key and connect with it, what the Verified badge on a commit |
| 114 | means, how to generate a GPG key, add it to an account, configure git to sign, |
| 115 | and what each failure message means. Run it |
| 116 | with `bun run dev` alongside everything else, or on its own: |
| 117 | |
| 118 | ```bash |
| 119 | bun run --filter @ghost/docs dev |
| 120 | ``` |
| 121 | |
| 122 | ## Code standards |
| 123 | |
| 124 | [`docs/code-standards.md`](docs/code-standards.md) is the contract for contributions: DRY and SOLID, no DTO reshaping helpers, no concatenated strings, comments that explain why and fit on one line, and `services/` holding nothing but services. |
| 125 | |
| 126 | ## Design decisions |
| 127 | |
| 128 | [`docs/`](docs/README.md) covers why the transport takes streams instead of |
| 129 | `Request`/`Response`, why a push is one compare-and-swap against a write-ahead |
| 130 | log, why materialization is forward-only replay, and why a pull request spans |
| 131 | two logs and lends objects instead of copying them. Each file lists what was |
| 132 | rejected and what it costs. |