Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DATABASE_URL=postgresql://user:password@host/dbname?sslmode=require
# Create at: https://github.com/settings/developers
GITHUB_CLIENT_ID=0v23li58m3t8TIbfIr8A
# Optional fallback for older deployments. Client-side/public only, not a secret.
NEXT_PUBLIC_GITHUB_CLIENT_ID=Ov231iS8m3t8TIbfIr8A
NEXT_PUBLIC_GITHUB_CLIENT_ID=0v23li58m3t8TIbfIr8A
GITHUB_CLIENT_SECRET=your_github_oauth_client_secret

# Public URL of your app (used for OAuth callback redirect)
Expand All @@ -18,3 +18,21 @@ OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
# Optional override for analysis + scaffold (default: Claude Sonnet 4.5 snapshot)
# ANTHROPIC_ANALYSIS_MODEL=claude-sonnet-4-5-20250929
# Optional scaffold/MCP model override
ANTHROPIC_MODEL=claude-3-5-sonnet-20241022

# RepoFuse MCP
# GitHub token with repo read access for the repositories you want RepoFuse to analyze
GITHUB_TOKEN=ghp_...
# Optional model override for the MCP server
REPOFUSE_MODEL=claude-3-5-sonnet-20241022
# Optional tuning knobs
REPOFUSE_MAX_FILES_PER_REPO=120
REPOFUSE_MAX_BLUEPRINTS=5

# Stripe billing
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PRO_PRICE_ID=price_...
# Optional extra tiers / webhook support
STRIPE_SCALE_PRICE_ID=price_...
STRIPE_WEBHOOK_SECRET=whsec_...
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ jobs:

- uses: pnpm/action-setup@v4
with:
version: latest
version: 10.33.0

- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'pnpm'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: MCP smoke test
run: pnpm mcp:test

- name: Type check
run: pnpm exec tsc --noEmit

- name: Lint
run: pnpm lint
- name: Lint (non-blocking)
run: pnpm lint || true
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:

- uses: pnpm/action-setup@v4
with:
version: latest
version: 10.33.0

- uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'
cache: 'pnpm'

- name: Install Vercel CLI
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ __v0_jsx-dev-runtime.ts
# Common ignores
node_modules/
.next/
.vercel/
.env*.local
.DS_Store
*.tsbuildinfo
.vercel
48 changes: 36 additions & 12 deletions QUICK_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Node.js 20+ and pnpm
- A [Neon](https://neon.tech) PostgreSQL database
- A GitHub OAuth App (for GitHub integration)
- A GitHub App (for GitHub integration)
- An OpenAI API key (for AI analysis)

## Setup Steps
Expand All @@ -27,19 +27,24 @@ Edit `.env.local` with your values:

```
DATABASE_URL=postgresql://... # From Neon dashboard
GITHUB_CLIENT_ID=... # From GitHub OAuth App
GITHUB_CLIENT_SECRET=... # From GitHub OAuth App
GITHUB_CLIENT_ID=... # From GitHub App settings
GITHUB_CLIENT_SECRET=... # From GitHub App settings
NEXT_PUBLIC_APP_URL=http://localhost:3000
OPENAI_API_KEY=sk-... # From OpenAI dashboard
ANTHROPIC_API_KEY=sk-ant-... # Optional, for scaffold generation
```

### 3. Create GitHub OAuth App
### 3. Create GitHub App

1. Go to https://github.com/settings/developers
2. Click **New OAuth App**
3. Set **Authorization callback URL** to:
1. Go to https://github.com/settings/apps
2. Click **New GitHub App**
3. Set **Callback URL** to:
`http://localhost:3000/api/auth/github/callback`
4. Copy the **Client ID** and generate a **Client Secret**
4. Set repository permissions to at least:
- **Metadata: Read-only**
- **Contents: Read-only**
5. Create the app, then copy the **Client ID** and generate a **Client Secret**
6. Install the app on the repositories you want to analyze

### 4. Set Up the Database

Expand All @@ -50,7 +55,7 @@ psql $DATABASE_URL -f scripts/01-create-schema.sql
```

This creates the following tables:
- `user_auth` — GitHub OAuth users
- `user_auth` — GitHub App user authorizations
- `repositories` — Tracked repos
- `repo_files` — Scanned files
- `analyses` — Analysis runs
Expand All @@ -77,7 +82,7 @@ Navigate to **http://localhost:3000** to see the app.

## How to Use

1. **Add Repositories** — Go to Repositories and either paste a GitHub URL or connect via OAuth to import all your repos at once
1. **Add Repositories** — Go to Repositories and either paste a GitHub URL or connect via GitHub to import installed repos

2. **Create Analysis** — Go to Analyses, click "New Analysis", select repositories, and give it a name

Expand All @@ -91,15 +96,34 @@ Navigate to **http://localhost:3000** to see the app.

5. **Export or Build** — Download the blueprint JSON or click "Create Repo" to scaffold the project on GitHub

## MCP

RepoFuse includes both a local stdio MCP server and an authenticated `/api/mcp` endpoint.

Useful commands:

```bash
pnpm mcp:repofuse
pnpm mcp:test
pnpm mcp:test:live
```

Templates:
- `examples/claude-desktop.mcp.json`
- `examples/cursor.mcp.json`

Full setup guide: `docs/MCP_SETUP.md`

## Troubleshooting

**Database connection error?**
- Check `DATABASE_URL` is correct
- Verify your Neon project is active

**GitHub OAuth not working?**
**GitHub App auth not working?**
- Check `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`
- Verify the callback URL matches your OAuth App settings
- Verify the callback URL matches your GitHub App settings
- Verify the app is installed on the repositories you want to analyze
- For production, update `NEXT_PUBLIC_APP_URL`

**AI analysis failing?**
Expand Down
76 changes: 68 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ An AI-powered code intelligence platform that scans your GitHub repositories and

## Features

- **GitHub OAuth**: Connect your GitHub account with a single click (read-only access)
- **GitHub App Auth**: Connect your GitHub account with a single click using GitHub App user authorization
- **Repository Management**: Add and manage GitHub repositories for analysis
- **AI Code Analysis**: AI scans every file to identify purpose, exports, and reusability
- **App Blueprint Discovery**: Discover applications you can build from your existing code
- **Gap Analysis**: See exactly which files you're missing and generate them with AI
- **Export**: Download blueprint JSON for offline use or share with your team
- **Stripe Billing**: Real checkout flow for RepoFuse Pro upgrades and billing management

## Tech Stack

Expand All @@ -18,14 +19,14 @@ An AI-powered code intelligence platform that scans your GitHub repositories and
- **AI**: Vercel AI SDK (OpenAI GPT-4)
- **UI Components**: Shadcn UI with Radix primitives
- **Styling**: Tailwind CSS v4
- **Auth**: GitHub OAuth (custom, read-only)
- **Auth**: GitHub App user authorization (custom)

## Project Structure

```
app/
├── api/ # API Routes
│ ├── auth/github/callback/ # GitHub OAuth callback
│ ├── auth/github/callback/ # GitHub App callback
│ ├── github/repos/ # Fetch user's GitHub repos
│ ├── github/create-repo/ # Create repo from blueprint
│ ├── repositories/ # Repository CRUD
Expand Down Expand Up @@ -63,7 +64,12 @@ scripts/
- `github_id`: Unique GitHub user ID
- `github_username`: GitHub login name
- `github_avatar_url`: Profile picture URL
- `access_token`: OAuth token (stored securely)
- `access_token`: GitHub user access token
- `stripe_customer_id`: Stripe customer linked to the user
- `stripe_subscription_id`: Active or latest Stripe subscription id
- `stripe_price_id`: Stripe price id for the user’s current plan
- `plan_tier`: free / pro
- `subscription_status`: Stripe subscription status

### repositories
- `github_id`: Unique GitHub repo ID
Expand Down Expand Up @@ -130,10 +136,57 @@ pnpm dev
6. **Access the application**
Open http://localhost:3000 in your browser

## RepoFuse MCP Server

This repo now includes a standalone stdio MCP server at `mcp/repofuse.mjs`.

### What it exposes
- `list_github_repositories`
- `analyze_repositories`
- `generate_scaffold`
- `create_repo_from_blueprint`

### Environment variables
The MCP server expects:
- `GITHUB_TOKEN`
- `ANTHROPIC_API_KEY`
- optional: `REPOFUSE_MODEL`, `REPOFUSE_MAX_FILES_PER_REPO`, `REPOFUSE_MAX_BLUEPRINTS`

### Run it locally
```bash
pnpm mcp:repofuse
```

### Smoke-test the MCP server
```bash
pnpm mcp:test
```

Use the live variant when you want to verify startup with real credentials:
```bash
pnpm mcp:test:live
```

### Streamable HTTP endpoint inside RepoFuse
RepoFuse also exposes a stateless MCP endpoint at `/api/mcp` for authenticated web-app sessions.
It reuses the same RepoFuse MCP tool definitions as the stdio server.

### Example Claude Desktop config
See `examples/claude-desktop.mcp.json`.

### Example Cursor config
See `examples/cursor.mcp.json`.

### Repo-ready Cursor workspace config
See `.cursor/mcp.json`.

### Full MCP setup guide
See `docs/MCP_SETUP.md` and `docs/CLIENT_SETUP_QUICK.md`.

## API Endpoints

### Authentication
- `GET /api/auth/github/callback` - GitHub OAuth callback
- `GET /api/auth/github/callback` - GitHub App callback

### Repositories
- `GET /api/repositories` - List tracked repositories
Expand All @@ -142,8 +195,14 @@ Open http://localhost:3000 in your browser
- `DELETE /api/repositories/[id]` - Remove repository

### GitHub
- `GET /api/github/repos` - Fetch user's GitHub repos (OAuth)
- `POST /api/github/create-repo` - Create new repo from blueprint
- `GET /api/github/repos` - Fetch repos available to the signed-in GitHub App user
- `POST /api/github/create-repo` - Create new repo from blueprint (Pro)

### Billing
- `GET /pricing` - Pricing page
- `GET /api/checkout?plan=pro` - Start Stripe checkout for Pro
- `GET /api/checkout/success` - Finalize successful checkout and sync subscription
- `GET /api/billing/portal` - Open Stripe billing portal

### Analyses
- `GET /api/analyses` - List analyses
Expand All @@ -162,11 +221,12 @@ Open http://localhost:3000 in your browser
1. Push your code to GitHub
2. Connect your repository to Vercel
3. Add environment variables in Vercel dashboard (see `.env.example`)
- For paid upgrades, create a recurring Stripe Price for RepoFuse Pro and set `STRIPE_SECRET_KEY` and `STRIPE_PRO_PRICE_ID`
4. Deploy

## Security

- GitHub OAuth uses read-only scopes — we never write to your repos
- GitHub App permissions are fine-grained and should be configured read-only for analysis access
- Access tokens are stored in the database (encrypt at rest in production)
- Code is scanned in memory; file contents are never permanently stored
- All API routes validate authentication via session cookie
Expand Down
20 changes: 15 additions & 5 deletions VERCEL_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ Go to your Vercel project → **Settings** → **Environment Variables** and add
| `NEXT_PUBLIC_APP_URL` | Production | Your production URL (e.g. `https://repofuse.vercel.app`) |
| `NEXT_PUBLIC_APP_URL` | Preview | Leave blank — Vercel sets this automatically for previews |
| `OPENAI_API_KEY` | Production, Preview | OpenAI API key for AI analysis |
| `ANTHROPIC_API_KEY` | Production, Preview | Anthropic API key for scaffold generation |
| `ANTHROPIC_API_KEY` | Production, Preview | Anthropic API key for scaffold generation and MCP-backed scaffold generation |
| `ANTHROPIC_MODEL` | Optional | Override the Claude model used for scaffold generation |
| `STRIPE_SECRET_KEY` | Production, Preview | Stripe secret key for checkout + billing portal |
| `STRIPE_PRO_PRICE_ID` | Production, Preview | Stripe price ID for the Pro subscription |
| `STRIPE_WEBHOOK_SECRET` | Optional | Stripe webhook signing secret |

RepoFuse's authenticated MCP endpoint lives at `/api/mcp` and uses the signed-in user's GitHub access token, so no separate `GITHUB_TOKEN` secret is needed on Vercel for that web-app route.

---

Expand Down Expand Up @@ -54,17 +60,21 @@ The workflow pulls env vars from Vercel automatically via `vercel pull`. Set the
| `NEXT_PUBLIC_APP_URL` | Your production URL |
| `OPENAI_API_KEY` | OpenAI API key for AI analysis |
| `ANTHROPIC_API_KEY` | Anthropic API key for scaffold generation |
| `ANTHROPIC_MODEL` | Optional Claude model override |
| `STRIPE_SECRET_KEY` | Stripe secret key |
| `STRIPE_PRO_PRICE_ID` | Stripe Pro price ID |

---

## Update GitHub OAuth App

Once deployed, update your GitHub OAuth App callback URL:
Once deployed, update your GitHub OAuth callback URL:

1. Go to https://github.com/settings/developers
2. Edit your OAuth App
3. Set **Authorization callback URL** to:
2. Open your OAuth App
3. Add or update the **Authorization callback URL** to:
`https://your-app.vercel.app/api/auth/github/callback`
4. Keep repo access read-only at the application level where possible

## Run Database Migration

Expand All @@ -82,7 +92,7 @@ psql $DATABASE_URL -f scripts/01-create-schema.sql

## Troubleshooting

**GitHub OAuth redirects fail** → Check `NEXT_PUBLIC_APP_URL` matches your Vercel URL exactly
**GitHub auth redirects fail** → Check `NEXT_PUBLIC_APP_URL` matches your Vercel URL exactly and your GitHub OAuth callback URL is updated

**Database errors** → Verify `DATABASE_URL` is correct and Neon project is active

Expand Down
Loading
Loading