mirror of
https://gitbruv.vercel.app/api/git/bruv/gitbruv.git
synced 2025-12-20 23:24:09 +01:00
Read-only mirror
https://gitbruv.vercel.app/bruv/gitbruv
| actions | ||
| app | ||
| components | ||
| db | ||
| lib | ||
| .gitignore | ||
| bun.lock | ||
| components.json | ||
| drizzle.config.ts | ||
| eslint.config.mjs | ||
| next.config.ts | ||
| package.json | ||
| postcss.config.mjs | ||
| README.md | ||
| tsconfig.json | ||
gitbruv
A GitHub clone built with Next.js, featuring real Git repository support with Cloudflare R2 storage.
Tech Stack
- Framework: Next.js 16 (App Router)
- Auth: better-auth (email/password)
- Database: PostgreSQL + Drizzle ORM
- Storage: Cloudflare R2 (S3-compatible)
- UI: shadcn/ui + Tailwind CSS
- Data Fetching: TanStack React Query
- Git: isomorphic-git + Git HTTP Smart Protocol
Getting Started
Prerequisites
- Node.js 18+ or Bun
- PostgreSQL database
- Git installed on your system
- Cloudflare account with R2 enabled
Cloudflare R2 Setup
- Go to Cloudflare Dashboard → R2
- Create a bucket named
gitbruv-repos - Go to R2 → Manage R2 API Tokens → Create API Token
- Select "Object Read & Write" permissions
- Copy the Account ID, Access Key ID, and Secret Access Key
Setup
- Clone and install dependencies:
bun install
- Create a
.envfile with the following variables:
DATABASE_URL=postgresql://postgres:password@localhost:5432/gitbruv
BETTER_AUTH_SECRET=your-secret-key-here-at-least-32-characters
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Cloudflare R2 Configuration
R2_ACCOUNT_ID=your-cloudflare-account-id
R2_ACCESS_KEY_ID=your-r2-access-key-id
R2_SECRET_ACCESS_KEY=your-r2-secret-access-key
R2_BUCKET_NAME=gitbruv-repos
- Push the database schema:
bun run db:push
- Start the development server:
bun run dev
Features
- User authentication (sign up, sign in, sign out)
- Create public/private repositories
- Browse repository files
- View file contents with syntax highlighting
- Clone repositories via HTTP
- Push to repositories via HTTP (with authentication)
- Markdown README rendering
- Cloud storage with Cloudflare R2 (zero egress fees)
Project Structure
app/
├── (auth)/ # Auth pages (login, register)
├── (main)/ # Main app pages
│ ├── [username]/ # User profile & repos
│ └── new/ # Create repository
├── api/
│ ├── auth/ # better-auth API
│ └── git/ # Git HTTP Smart Protocol
actions/ # Server actions
components/ # React components
db/ # Database schema & connection
lib/ # Utilities, auth config, R2 integration
Git Operations
Clone a repository:
git clone http://localhost:3000/api/git/username/repo.git
Push to a repository (requires auth):
git push origin main
# Enter your email and password when prompted
Architecture
Git repositories are stored in Cloudflare R2 as bare repos. When git operations occur:
- Repository files are synced from R2 to a temp directory
- Git commands execute against the temp directory
- For push operations, changes are synced back to R2
- Temp directory is cleaned up
This allows serverless deployment while maintaining full Git compatibility.