- TypeScript 99%
- CSS <1%
Summer School #
A web application for managing summer school programs, student assessments, team formation, and challenges.
Prerequisites #
- Bun (v1.0+) - JavaScript runtime and package manager
- PostgreSQL (v15+) - Database
- Docker (optional) - For running PostgreSQL in a container
Quick Start #
git clone https://github.com/username/summerschool.git
cd summerschool
bun install
docker compose up -d # Start PostgreSQL
cp .env.example .env # Edit with your secrets
bunx prisma migrate deploy
bunx prisma db seed
bun dev
Then open http://localhost:3000
Local Setup #
1. Clone and install dependencies #
git clone https://github.com/username/summerschool.git
cd summerschool
bun install
2. Set up PostgreSQL #
Option A: Using Docker (recommended)
docker compose up -d
This starts PostgreSQL on port 5432 with:
- User:
username - Password:
password - Database:
summerschool
Option B: Local PostgreSQL
Install PostgreSQL and create a database:
createdb summerschool
3. Configure environment variables #
cp .env.example .env
Edit .env with your values:
# Required
DATABASE_URL="postgresql://username:password@localhost:5432/summerschool"
BETTER_AUTH_SECRET="generate-with-openssl-rand-base64-32"
# Required for production - callback security for background team formation
EDU2COM_CALLBACK_SECRET="generate-with-openssl-rand-base64-32"
NEXT_PUBLIC_APP_URL="https://yourdomain.com"
# Optional - for seeding admin user
ADMIN_EMAIL="admin@example.com"
ADMIN_PASSWORD="your-password"
Generate a secret:
openssl rand -base64 32
4. Initialize the database #
bunx prisma migrate deploy
bunx prisma db seed
5. Start the development server #
bun dev
Open http://localhost:3000.
Production Deployment #
Option A: Vercel #
- Push your code to GitHub
- Import the repository in Vercel
- Add environment variables in Vercel dashboard:
DATABASE_URL- Your production PostgreSQL connection stringBETTER_AUTH_SECRET- Your auth secret
- Deploy
Vercel auto-detects Next.js and handles the build.
Option B: Self-hosted (VPS/Docker) #
Using Docker Compose:
Create docker-compose.prod.yml:
services:
app:
build: .
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://user:password@postgres:5432/summerschool
- BETTER_AUTH_SECRET=your-secret
- NODE_ENV=production
depends_on:
- postgres
postgres:
image: postgres:15
environment:
POSTGRES_USER: user
POSTGRES_PASSWORD: password
POSTGRES_DB: summerschool
volumes:
- postgres_data:/var/lib/postgresql/data
volumes:
postgres_data:
Create Dockerfile:
FROM oven/bun:1 AS builder
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun install --frozen-lockfile
COPY . .
RUN bunx prisma generate --no-engine
RUN bun run build
FROM oven/bun:1-slim
WORKDIR /app
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["bun", "server.js"]
Update next.config.ts to enable standalone output:
const nextConfig: NextConfig = {
output: "standalone",
// ... rest of config
};
Deploy:
docker compose -f docker-compose.prod.yml up -d --build
Manual deployment:
bun install
bunx prisma migrate deploy
bun run build
bun run start
Use a process manager like PM2 or systemd to keep the app running.
Option C: Railway / Render / Fly.io #
These platforms support Next.js deployments. Set the build command to bun run build and start command to bun run start. Add your environment variables in the platform dashboard.
Environment Variables Setup #
Required Variables #
DATABASE_URL
PostgreSQL connection string. Format:
postgresql://USER:PASSWORD@HOST:PORT/DATABASE
Examples:
- Local (Docker):
postgresql://username:password@localhost:5432/summerschool - Local (custom):
postgresql://postgres:mypassword@localhost:5432/summerschool - Remote:
postgresql://user:pass@db.example.com:5432/summerschool?sslmode=require
For production, use a managed PostgreSQL service like:
BETTER_AUTH_SECRET
A random string used to encrypt sessions and tokens. Generate one with:
openssl rand -base64 32
Keep this secret and never commit it to version control.
Production Variables #
EDU2COM_CALLBACK_SECRET
Required in production for background team formation. When forming teams with many students (>40) or tasks (>14), the app uses an async webhook pattern. The external edu2com service calls back to your app with results, and this secret authenticates those callbacks.
openssl rand -base64 32
NEXT_PUBLIC_APP_URL
Your application's public URL. Used to construct callback URLs for the edu2com service. In development, falls back to localhost:3000.
NEXT_PUBLIC_APP_URL="https://yourdomain.com"
Optional Variables #
Google OAuth (for "Sign in with Google")
- Go to Google Cloud Console
- Create a new project or select existing one
- Go to APIs & Services > Credentials
- Click "Create Credentials" > "OAuth client ID"
- Select "Web application"
- Add authorized redirect URI:
http://localhost:3000/api/auth/callback/google(development) orhttps://yourdomain.com/api/auth/callback/google(production) - Copy the Client ID and Client Secret
GOOGLE_CLIENT_ID="your-client-id.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="your-client-secret"
Admin Seeding (for initial admin account)
Set these before running bunx prisma db seed:
ADMIN_EMAIL="admin@yourschool.com"
ADMIN_PASSWORD="secure-password-here"
Full Example .env #
# Required
DATABASE_URL="postgresql://username:password@localhost:5432/summerschool"
BETTER_AUTH_SECRET="K7gH2jM9pL4qR8tY1wX6zV3bN0mC5fA="
# Required for production
EDU2COM_CALLBACK_SECRET="X9kL3mN7pQ2rS5tU8vW1xY4zA6bC0dE="
NEXT_PUBLIC_APP_URL="https://yourdomain.com"
# Optional - Google OAuth
GOOGLE_CLIENT_ID="123456789.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="GOCSPX-abcdefghijk"
# Optional - Admin seeding
ADMIN_EMAIL="admin@example.com"
ADMIN_PASSWORD="admin123"
Common Commands #
bun dev # Start development server
bun run build # Build for production
bun run start # Start production server
bun test # Run tests
bun run lint # Lint and format code
bunx prisma studio # Open database GUI