1
0
Fork 0
mirror of https://gitbruv.vercel.app/api/git/bruv/gitbruv.git synced 2025-12-20 23:24:09 +01:00
This commit is contained in:
Ahmet Kilinc 2025-12-20 02:43:11 +00:00
parent 8f672d012c
commit 46cab693db
49 changed files with 4725 additions and 118 deletions

125
README.md
View file

@ -1,36 +1,121 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
# 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
First, run the development server:
### Prerequisites
- Node.js 18+ or Bun
- PostgreSQL database
- Git installed on your system
- Cloudflare account with R2 enabled
### Cloudflare R2 Setup
1. Go to [Cloudflare Dashboard](https://dash.cloudflare.com) → R2
2. Create a bucket named `gitbruv-repos`
3. Go to R2 → Manage R2 API Tokens → Create API Token
4. Select "Object Read & Write" permissions
5. Copy the Account ID, Access Key ID, and Secret Access Key
### Setup
1. Clone and install dependencies:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
bun install
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
2. Create a `.env` file with the following variables:
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
```
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
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
# 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
```
## Learn More
3. Push the database schema:
To learn more about Next.js, take a look at the following resources:
```bash
bun run db:push
```
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
4. Start the development server:
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
```bash
bun run dev
```
## Deploy on Vercel
5. Open [http://localhost:3000](http://localhost:3000)
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
## Features
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
- 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:
```bash
git clone http://localhost:3000/api/git/username/repo.git
```
Push to a repository (requires auth):
```bash
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:
1. Repository files are synced from R2 to a temp directory
2. Git commands execute against the temp directory
3. For push operations, changes are synced back to R2
4. Temp directory is cleaned up
This allows serverless deployment while maintaining full Git compatibility.