Prerequisites
Before you begin, ensure you have the following installed:- Node.js - Latest LTS version recommended
- npm or yarn - Package manager
- Python 3.10.0 - For reference if working with the ingestion service
- Git - Version control
Required accounts
You’ll also need accounts for these services:- Supabase - PostgreSQL database
- Clerk - Authentication
- Stripe - Payment processing
- OpenRouter - AI model access (Google Gemini)
Installation
Install Node.js dependencies
- Next.js 14
- React 18
- Clerk authentication
- Supabase client
- Stripe integration
- OpenAI SDK (for OpenRouter)
Install Python dependencies (optional)
If you plan to work with or understand the ingestion service logic:
The main application calls a hosted Python API for repository ingestion, so this step is primarily for reference.
Configure environment variables
Create a Add all required environment variables. See the environment variables guide for a complete reference.
.env.local file in the root directory:Set up the Supabase database
- Go to your Supabase project dashboard
- Navigate to the SQL Editor
- Run the migrations in
supabase/migrations/in order:20240320000000_rls_policies.sql20240320000000_add_credit_transaction.sql
user_credits- Stores user credit balancesgenerated_readmes- Stores README generation historyprocessed_stripe_events- Tracks processed payment events
Row Level Security (RLS) policies are automatically applied to protect user data.
Project structure
Understanding the codebase structure:Key API endpoints
The application provides these API routes:POST /api/generate- Generate README from repository URLGET /api/credits- Fetch current user’s credit balancePOST /api/credits- Update user’s credit balancePOST /api/create-checkout-session- Create Stripe checkout sessionPOST /api/verify-payment- Verify Stripe payment and update creditsGET /api/readme-history- Retrieve user’s generated READMEsPOST /api/readme-history- Save generated README to history
Development workflow
Making changes
- Frontend changes - Edit files in
app/components/orapp/page.tsx - API changes - Modify routes in
app/api/ - Styling - Update Tailwind classes or
app/globals.css - Database - Create new migrations in
supabase/migrations/
Testing locally
Test README generation
- Sign in to get credits
- Enter a GitHub repository URL
- Click “Generate README”
- Verify the README is generated and your credits are decremented
Common development tasks
Adding a new API endpoint
- Create a new folder in
app/api/ - Add a
route.tsfile - Export
GET,POST, or other HTTP method handlers - Use
getAuth(req)for authentication
Updating the database schema
- Create a new migration file in
supabase/migrations/ - Write SQL to modify tables or policies
- Run the migration in Supabase SQL Editor
- Update TypeScript types if needed
Adding new environment variables
- Add the variable to
.env.local - Update the environment variables guide
- Access in code:
process.env.VARIABLE_NAME - Restart the development server
Troubleshooting
Port already in use
Database connection errors
- Verify your Supabase URL and keys in
.env.local - Check that your Supabase project is active
- Ensure RLS policies are correctly set up
- Test the connection in Supabase dashboard
API errors
- Check the terminal for error logs
- Verify all environment variables are set
- Ensure external services (Clerk, Stripe, OpenRouter) are accessible
- Check API rate limits
Build errors
Git ingestion service
The repository ingestion logic is handled by an external API:- Endpoint:
https://gitread-api.onrender.com/ingest - Method:
POST - Authentication: Requires
PYTHON_API_KEYin headers
gitingest library to:
- Clone the GitHub repository
- Analyze repository structure
- Extract and summarize file contents
- Estimate token counts
- Return processed data for AI generation
A reference implementation is available in
scripts/git_ingest.py.Next steps
- Configure authentication with Clerk
- Set up all environment variables
- Learn about deployment to production
- Review the README.md for the full technology stack