madison / open-git

public

Public repo for open-git repository.

359 files

on test_pr

README.md

open-git

open-git is a GitHub-inspired code hosting app built for the community, by the community. Open-git is geared towards recreating github, but at a open source scale. Lets build the future!

Apps and Packages

  • apps/web - Next.js App Router application.
  • packages/ui - shared shadcn/base-ui components and global styles.
  • packages/code-storage - isomorphic-git + S3 SDK package.

Stack Auth

The app is wired for Stack Auth with:

  • apps/web/stack.ts - shared StackServerApp configuration.
  • apps/web/app/handler/[...stack]/page.tsx - Stack Auth catch-all handler.
  • apps/web/app/dashboard/page.tsx - example protected server route.
  • apps/web/.env.example - required environment variables.

Copy apps/web/.env.example to apps/web/.env.local and fill in values from Stack Auth:

NEXT_PUBLIC_STACK_PROJECT_ID=
STACK_SECRET_SERVER_KEY=
DATABASE_URL=postgresql://opengit:opengit@localhost:54329/opengit
CODE_STORAGE_BUCKET=opengit-code-storage
CODE_STORAGE_REGION=us-east-1
CODE_STORAGE_S3_ENDPOINT=http://localhost:9000
CODE_STORAGE_ACCESS_KEY_ID=opengit
CODE_STORAGE_SECRET_ACCESS_KEY=opengit_password
GIT_REMOTE_BASE_URL=http://localhost:4321
GIT_GATEWAY_PORT=4321
GIT_GATEWAY_CACHE_ROOT=.git-gateway-cache

The official initializer can be rerun after authenticating with Stack Auth:

npx @stackframe/stack-cli@latest init --mode create --output-dir apps/web --no-agent

Local Infrastructure

Stack Auth owns authentication and session identity. open-git owns product data that needs app-level invariants, starting with unique usernames.

The local development stack uses Postgres and MinIO:

  • compose.yaml - local Postgres and S3-compatible MinIO for OrbStack/Docker.
  • apps/web/db/schema.ts - schema definitions.
  • apps/web/db/index.ts - shared Drizzle client.
  • apps/web/db/user-profiles.ts - Stack Auth user to app profile helper.
  • apps/web/drizzle.config.ts - Drizzle migration config.
  • packages/code-storage - SDK that stores bare Git repositories in S3.

user_profiles.stack_user_id is unique and maps to user.id from Stack Auth. user_profiles.username is also unique, but nullable until the future onboarding flow lets a signed-in user reserve a username.

The onboarding flow lives at apps/web/app/onboarding. It validates usernames on the server, writes the unique username to Postgres, then sets clientReadOnlyMetadata.onboarded in Stack Auth after the database write succeeds.

Start all local infrastructure, then generate and apply migrations from the web app package:

pnpm infra:up
pnpm --filter web db:generate
pnpm --filter web db:migrate

Local Postgres runs on localhost:54329 with database, username, and password all set to opengit.

Local MinIO exposes the S3 API on localhost:9000 and the browser console on http://localhost:9001. The local bucket is created automatically as opengit-code-storage; the console login is opengit / opengit_password.

Git HTTP Gateway

The Git gateway exposes normal HTTPS-style Git remotes backed by the same S3 repository storage:

pnpm --filter git-gateway dev
git clone http://localhost:4321/<username>/<repository>.git

Public repositories can be cloned without credentials. Private clones and pushes use HTTP Basic auth with your username and a Git token generated at /settings/developer/tokens.

Adding components

To add components to your app, run the following command at the root of your web app:

pnpm dlx shadcn@latest add button -c apps/web

This will place the ui components in the packages/ui/src/components directory.

Using components

To use the components in your app, import them from the ui package.

import { Button } from "@workspace/ui/components/button";