Forge is a self-hosted Git platform for small trusted groups and for learning how GitHub-style systems actually work. The current repository contains a deployable backend foundation with smart HTTP and SSH Git transport, revocable sessions, PostgreSQL-backed metadata, organizations and collaborators, a browser UI, repository webhooks, and a MkDocs Material documentation site under docs/.
Implemented now:
- HTTP server with graceful shutdown and structured logging
GET /healthzliveness endpoint andGET /readyzdependency readiness checks- JWT cookie auth with register, login, logout, and current-user endpoints
- Session persistence and logout revocation via stored session records
- Repository CRUD API with repository detail responses and owner-aware clone URLs
- PostgreSQL-backed store when
DATABASE_URLis set, with in-memory fallback for tests and no-DB runs - Sharded bare repository provisioning under
FORGE_REPOS_ROOTwith atomic staging, safe deletion, and advisory repo-level mutation locking - Embedded PostgreSQL migrations applied automatically on startup
- Organization ownership, org membership roles, and repository collaborators
- Smart HTTP Git transport through
git-http-backend - SSH Git transport with registered public keys and
git-upload-pack/git-receive-pack - Background repository maintenance for
git gc --auto, commit-graph refresh, and size accounting - Repository webhooks for push and delete events with signed async delivery and delivery status tracking
- Browser UI at
/appfor sign-in, repo creation, org management, SSH key management, collaborator management, and webhook management - Production-oriented config validation, database pool tuning, request IDs, body limits, and baseline security headers
- Non-root container runtime, health checks, and safer compose defaults for internal deployment
- MkDocs Material documentation site under
docs/ docker-compose.yml,Dockerfile, andsqlcconfiguration to anchor local development
Not implemented yet:
- Pull requests, issues, code review flows, releases, and CI runners
- Notifications, admin workflows, and broader instance management
- Rate limiting, CSRF protection, audit logging, and richer security hardening
- Webhook retries with persistent delivery queues, Git LFS, and search
- Copy
.env.exampleto.envand adjust the values you care about. - Run
docker-compose up --build -d. - Visit
http://localhost:3000/app.
For local-only development without Docker:
go mod tidy
go run ./cmd/forgeThe project ships a MkDocs Material documentation site in docs/ with a quickstart, guides, and reference pages for architecture, API behavior, data model details, deployment, and testing.
Install the docs dependencies and preview locally:
python3 -m pip install -r requirements-docs.txt
mkdocs serveThen open http://127.0.0.1:8000/.
To produce a production build locally:
mkdocs build --strictGitHub Pages deployment is wired through .github/workflows/deploy-pages.yml. To use it, enable GitHub Pages in the repository settings and choose GitHub Actions as the source.
The current API is JSON plus Git transport, with a browser app mounted at /app.
GET /healthzGET /readyzPOST /api/v1/auth/registerPOST /api/v1/auth/loginPOST /api/v1/auth/logoutGET /api/v1/meGET /api/v1/keysPOST /api/v1/keysGET /api/v1/orgsPOST /api/v1/orgsPOST /api/v1/orgs/{org}/membersGET /api/v1/reposGET /api/v1/repos/{owner}/{repo}POST /api/v1/reposDELETE /api/v1/repos/{owner}/{repo}POST /api/v1/repos/{owner}/{repo}/collaboratorsGET /api/v1/repos/{owner}/{repo}/webhooksPOST /api/v1/repos/{owner}/{repo}/webhooksDELETE /api/v1/repos/{owner}/{repo}/webhooks/{webhookID}- Smart HTTP Git at
/git/{owner}/{repo}.git - SSH Git at
ssh://git@host:2222/{owner}/{repo}.git - Browser UI at
/app,/app/repos,/app/orgs,/app/keys, and/app/repos/{owner}/{repo}
Example register request:
{
"username": "yash",
"password": "correct horse battery staple"
}Example repository creation request:
{
"owner": "team",
"owner_type": "organization",
"name": "forge",
"description": "Self-hosted git platform",
"visibility": "private",
"default_branch": "main"
}cmd/forge: process entrypointinternal/config: environment-driven application configinternal/auth: password hashing and JWT session helpersinternal/database: database connection bootstrapinternal/repository: repository metadata/filesystem orchestrationinternal/server: HTTP router, middleware, and handlersinternal/store: storage interface plus memory and PostgreSQL implementationsdb/migrations: PostgreSQL schema evolutiondb/queries: startersqlcquery definitionsdeploy: container and reverse proxy assetsdocs: MkDocs documentation source filesmkdocs.yml: MkDocs Material site configuration
Bare repositories on disk are still the correct Git storage primitive here. The scaling work is in the operational layer around them: sharded layout, atomic provisioning, PostgreSQL advisory leases, coordinated mutations, background maintenance, transport isolation, authorization, and webhook delivery around Git events.
The natural next step is product depth rather than core plumbing: pull requests, issues, release flows, stronger security controls, and a more durable background job model for webhook retries and future automation.