Skip to content
Draft
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
9 changes: 6 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Neon PostgreSQL Database
DATABASE_URL=postgresql://user:password@host/dbname?sslmode=require
# Supabase PostgreSQL Database
# Find your connection string in the Supabase dashboard: Settings → Database → Connection string → URI
DATABASE_URL=postgresql://postgres.[project-ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres

# GitHub OAuth App
# Create at: https://github.com/settings/developers
Expand All @@ -11,8 +12,10 @@ GITHUB_CLIENT_SECRET=your_github_oauth_client_secret
# Public URL of your app (used for OAuth callback redirect)
NEXT_PUBLIC_APP_URL=https://repo-app-architect.vercel.app

# OpenAI API Key (used by Vercel AI SDK for analysis)
# OpenAI API Key (used for GPT-based blueprint analysis)
OPENAI_API_KEY=sk-...
# Optional override for OpenAI model (default: gpt-4o)
# OPENAI_ANALYSIS_MODEL=gpt-4o

# Anthropic API Key (analysis + scaffold generation)
ANTHROPIC_API_KEY=sk-ant-...
Expand Down
53 changes: 53 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AGENTS.md

## Cursor Cloud specific instructions

### Overview

CodeVault is an AI-powered code intelligence platform built with **Next.js 16** (App Router), **TypeScript**, **Tailwind CSS v4**, and **Shadcn UI**. It connects to GitHub repos, scans files, and uses AI to discover application blueprints.

### Package manager

This project uses **pnpm**. The lockfile is `pnpm-lock.yaml`.

### Scripts (from `package.json`)

| Command | Purpose |
|---------|---------|
| `pnpm dev` | Start Next.js dev server (port 3000) |
| `pnpm build` | Production build |
| `pnpm lint` | Run ESLint |
| `pnpm exec tsc --noEmit` | Type check |

### Lint and type check

- **Lint**: `pnpm lint` — runs ESLint. The codebase has a few pre-existing lint warnings/errors (unused vars, `prefer-const`, `set-state-in-effect`). These are not regressions.
- **Type check**: `pnpm exec tsc --noEmit` — clean pass. If you see errors referencing `.next/types/validator.ts` or `.next/dev/types/validator.ts`, run `rm -rf .next` first, as stale generated types can cause false failures.

### No automated test suite

There is no test framework (jest, vitest, playwright, etc.) configured in this codebase. CI only runs lint + typecheck.

### Database

The app uses `postgres` (postgres.js) to connect to PostgreSQL via standard TCP sockets. Any PostgreSQL-compatible database works (Supabase, local PostgreSQL, etc.). Set `DATABASE_URL` to a valid PostgreSQL connection string. The schema migration is at `scripts/01-create-schema.sql`, or hit `GET /api/setup/init-db` to initialize the DB via the app.

### Environment variables

Copy `.env.example` to `.env.local`. Required variables:

- `DATABASE_URL` — Supabase (or any PostgreSQL) connection string
- `GITHUB_CLIENT_ID` / `GITHUB_CLIENT_SECRET` — GitHub OAuth App credentials
- `NEXT_PUBLIC_APP_URL` — App URL (use the local dev server URL)
- `OPENAI_API_KEY` — For AI analysis features
- `ANTHROPIC_API_KEY` — Optional, for scaffold generation
Comment on lines +42 to +43

### Authentication

The app uses GitHub OAuth. The middleware at `middleware.ts` blocks unauthenticated access to `/dashboard/*` routes by checking `github_user_id` and `github_access_token` cookies. To test dashboard features, you need a working GitHub OAuth App with the callback URL set to `{NEXT_PUBLIC_APP_URL}/api/auth/github/callback`.

### Key gotchas

- The landing page (`/`) works without any database or API credentials — it's a static page.
- All dashboard routes require authentication cookies set by the GitHub OAuth flow.
- The pnpm install may warn about ignored build scripts for `sharp` and `unrs-resolver`. This is fine and doesn't affect functionality.
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
┌──────────────────────────────────────────────────────────────────────┐
│ DATA LAYER │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │ Neon PostgreSQL │ │
│ │ Supabase PostgreSQL │ │
│ │ ┌──────────────────────────────────────────────────────────┐ │ │
│ │ │ user_auth Table - GitHub OAuth users │ │ │
│ │ │ repositories Table - Tracked GitHub repos │ │ │
Expand Down
6 changes: 3 additions & 3 deletions IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## ✅ Completed Architecture

### 1. Database Layer (Neon PostgreSQL)
### 1. Database Layer (Supabase PostgreSQL)
- ✅ `user_auth` — GitHub OAuth user records
- ✅ `repositories` — Tracked GitHub repositories
- ✅ `repo_files` — Scanned files with AI metadata (JSONB fields)
Expand Down Expand Up @@ -62,7 +62,7 @@
- UI primitives (Shadcn)

/lib
- db.ts - Neon database client
- db.ts - Database client (postgres.js)
- queries.ts - All database operations
- utils.ts - cn() and other helpers

Expand All @@ -83,7 +83,7 @@
## 🔑 Key Technologies

- **Framework**: Next.js 16 (App Router)
- **Database**: Neon PostgreSQL (`@neondatabase/serverless`)
- **Database**: Supabase PostgreSQL (`postgres` / postgres.js)
- **AI**: Vercel AI SDK + OpenAI GPT-4
Comment on lines +86 to 87
- **Auth**: Custom GitHub OAuth
- **UI**: Shadcn UI + Tailwind CSS v4
Expand Down
8 changes: 4 additions & 4 deletions QUICK_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Prerequisites

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

Expand All @@ -26,7 +26,7 @@ cp .env.example .env.local
Edit `.env.local` with your values:

```
DATABASE_URL=postgresql://... # From Neon dashboard
DATABASE_URL=postgresql://... # From Supabase dashboard (Settings → Database)
GITHUB_CLIENT_ID=... # From GitHub OAuth App
GITHUB_CLIENT_SECRET=... # From GitHub OAuth App
NEXT_PUBLIC_APP_URL=http://localhost:3000
Expand All @@ -43,7 +43,7 @@ OPENAI_API_KEY=sk-... # From OpenAI dashboard

### 4. Set Up the Database

Run the migration in your Neon SQL Editor or with psql:
Run the migration in your Supabase SQL Editor or with psql:

```bash
psql $DATABASE_URL -f scripts/01-create-schema.sql
Expand Down Expand Up @@ -95,7 +95,7 @@ Navigate to **http://localhost:3000** to see the app.

**Database connection error?**
- Check `DATABASE_URL` is correct
- Verify your Neon project is active
- Verify your Supabase project is active (or your PostgreSQL server is running)

**GitHub OAuth not working?**
- Check `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET`
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ An AI-powered code intelligence platform that scans your GitHub repositories and
## Tech Stack

- **Framework**: Next.js 16 with App Router
- **Database**: Neon PostgreSQL with connection pooling
- **Database**: Supabase PostgreSQL (or any PostgreSQL)
- **AI**: Vercel AI SDK (OpenAI GPT-4)
- **UI Components**: Shadcn UI with Radix primitives
- **Styling**: Tailwind CSS v4
Expand Down Expand Up @@ -50,7 +50,7 @@ components/
├── app-suggestions.tsx # App idea cards
└── ui/ # Shadcn components
lib/
├── db.ts # Neon database client
├── db.ts # Database client (postgres.js)
├── queries.ts # Database queries
└── utils.ts # Utility functions
scripts/
Expand Down Expand Up @@ -117,7 +117,7 @@ cp .env.example .env.local
```

4. **Set up the database**
Run the schema migration in your Neon console or with psql:
Run the schema migration in your Supabase SQL Editor or with psql:
```bash
psql $DATABASE_URL -f scripts/01-create-schema.sql
```
Expand Down
8 changes: 4 additions & 4 deletions VERCEL_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Go to your Vercel project → **Settings** → **Environment Variables** and add

| Variable | Environment | Description |
|----------|-------------|-------------|
| `DATABASE_URL` | Production, Preview, Development | Neon PostgreSQL connection string |
| `DATABASE_URL` | Production, Preview, Development | Supabase PostgreSQL connection string |
| `GITHUB_CLIENT_ID` | Production, Preview, Development | GitHub OAuth App client ID |
| `GITHUB_CLIENT_SECRET` | Production, Preview, Development | GitHub OAuth App client secret |
| `NEXT_PUBLIC_APP_URL` | Production | Your production URL (e.g. `https://codevault.vercel.app`) |
Expand Down Expand Up @@ -48,7 +48,7 @@ The workflow pulls env vars from Vercel automatically via `vercel pull`. Set the

| Variable | Description |
|----------|-------------|
| `DATABASE_URL` | Neon PostgreSQL connection string |
| `DATABASE_URL` | Supabase PostgreSQL connection string |
| `GITHUB_CLIENT_ID` | GitHub OAuth App client ID |
| `GITHUB_CLIENT_SECRET` | GitHub OAuth App client secret |
| `NEXT_PUBLIC_APP_URL` | Your production URL |
Expand All @@ -68,7 +68,7 @@ Once deployed, update your GitHub OAuth App callback URL:

## Run Database Migration

Run the schema SQL in your Neon console:
Run the schema SQL in your Supabase SQL Editor:

```sql
-- Paste contents of scripts/01-create-schema.sql
Expand All @@ -84,7 +84,7 @@ psql $DATABASE_URL -f scripts/01-create-schema.sql

**GitHub OAuth redirects fail** → Check `NEXT_PUBLIC_APP_URL` matches your Vercel URL exactly

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

**AI analysis fails** → Check `OPENAI_API_KEY` has sufficient credits

Expand Down
11 changes: 11 additions & 0 deletions app/api/ai-providers/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { NextResponse } from 'next/server'
import { AI_PROVIDERS, getAvailableProviders } from '@/lib/ai-providers'

export async function GET() {
const available = getAvailableProviders()
const providers = AI_PROVIDERS.map((p) => ({
...p,
available: available.includes(p.id),
}))
return NextResponse.json(providers)
}
Loading
Loading