Local Development Setup
Prerequisites
Section titled “Prerequisites”- Node.js 20+ (or Bun 1.0+)
- Git 2.30+
- PostgreSQL 14+ (recommended) or SQLite (for quick setup)
- Redis 7+ (optional for local dev, required for background workers)
Quick Setup
Section titled “Quick Setup”# Clone the repositorygit clone https://github.com/swadhinbiswas/OpencodeHub.gitcd OpencodeHub
# Install dependenciesnpm install
# Copy environment configcp .env.example .env
# Edit .env with your settings (at minimum, set the secrets)# Generate secrets with: openssl rand -base64 32Database
Section titled “Database”# Push schema to database (creates tables)npm run db:push
# Or generate and run migrationsnpm run db:generatenpm run db:migrate
# Open Drizzle Studio GUInpm run db:studioFor SQLite (simplest setup), set in .env:
DATABASE_DRIVER=sqliteDATABASE_URL=file:./data/opencodehub.dbSeed Admin User
Section titled “Seed Admin User”bun run scripts/seed-admin.tsStart Development
Section titled “Start Development”# Main app (Web UI + API + Git HTTP)npm run dev
# SSH Git server (optional, for ssh:// clone/push)npm run git:start
# Background worker (optional, for webhooks/notifications)npm run worker:start
# CI runner (optional, for pipeline execution)npm run runner:startThe dev server runs at http://localhost:4321.
Useful Scripts
Section titled “Useful Scripts”| Command | Purpose |
|---|---|
npm run dev | Start Astro dev server |
npm run build | Production build |
npm run test | Run Vitest test suite |
npm run test:coverage | Run tests with coverage |
npm run lint | Run Astro check |
npm run typecheck | TypeScript type checking |
npm run db:push | Push schema to database |
npm run db:generate | Generate Drizzle migrations |
npm run db:migrate | Run migrations |
npm run db:studio | Open Drizzle Studio |
npm run git:start | Start SSH git server |
npm run worker:start | Start background worker |
npm run runner:start | Start CI runner |
Docker Compose (Alternative)
Section titled “Docker Compose (Alternative)”For a full stack with PostgreSQL and Redis:
docker-compose up -ddocker-compose exec app bun run scripts/seed-admin.tsThis starts the app on port 4321 and SSH on port 2222.
IDE Setup
Section titled “IDE Setup”- VS Code: Install the Astro extension for syntax highlighting
- Recommended extensions: Tailwind CSS IntelliSense, ESLint