|
| 1 | +<img width="1512" height="368" alt="Screenshot 2026-01-31 at 13 21 43" src="https://github.com/user-attachments/assets/4554058b-dbde-4cb8-a83d-ea0cdaa6514b" /> |
| 2 | + |
| 3 | +# CompSoc Events Platform |
| 4 | + |
| 5 | +A full-stack event management platform for the University of Edinburgh's Computing Society (CompSoc). Members can browse and register for events organized by the society and its Special Interest Groups (SIGs). |
| 6 | + |
| 7 | +## Architecture |
| 8 | + |
| 9 | +This is a **pnpm monorepo** with three packages: |
| 10 | + |
| 11 | +| Package | Description | Tech Stack | |
| 12 | +|---------|-------------|------------| |
| 13 | +| `apps/api` | REST API server | Fastify, Drizzle ORM, PostgreSQL | |
| 14 | +| `apps/web` | Frontend application | React 19, TanStack Router, TanStack Query, Tailwind CSS | |
| 15 | +| `apps/shared` | Shared types & schemas | Zod, TypeScript | |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +- **Event Management** - Create, edit, publish, and delete events |
| 20 | +- **Event Registration** - Members can register for events with custom form fields |
| 21 | +- **Registration Management** - Committee members can accept, reject, or waitlist registrations |
| 22 | +- **Analytics** - View registration statistics and charts |
| 23 | +- **Role-based Access** - Member and Committee roles with different permissions |
| 24 | +- **Authentication** - Clerk authentication with webhook sync |
| 25 | + |
| 26 | +## Getting Started |
| 27 | + |
| 28 | +### 1. Install Dependencies |
| 29 | + |
| 30 | +```bash |
| 31 | +pnpm install |
| 32 | +``` |
| 33 | + |
| 34 | +### 2. Environment Setup |
| 35 | + |
| 36 | +**API** (`apps/api/.env`): |
| 37 | + |
| 38 | +```env |
| 39 | +# Database |
| 40 | +DATABASE_URL="postgresql://user:[email protected]/neondb?sslmode=require" |
| 41 | +
|
| 42 | +# Clerk Authentication |
| 43 | +CLERK_PUBLISHABLE_KEY=pk_test_your_publishable_key |
| 44 | +CLERK_SECRET_KEY=sk_test_your_secret_key |
| 45 | +
|
| 46 | +# Clerk Webhooks (for user sync) |
| 47 | +CLERK_WEBHOOK_SECRET=whsec_your_webhook_secret |
| 48 | +``` |
| 49 | + |
| 50 | +**Web** (`apps/web/.env.local`): |
| 51 | + |
| 52 | +```env |
| 53 | +VITE_CLERK_PUBLISHABLE_KEY=pk_test_your_publishable_key |
| 54 | +VITE_API_URL=http://localhost:8080 |
| 55 | +``` |
| 56 | + |
| 57 | +### 3. Database Setup |
| 58 | + |
| 59 | +Generate and run migrations: |
| 60 | + |
| 61 | +```bash |
| 62 | +cd apps/api |
| 63 | +pnpm db:migrate |
| 64 | +``` |
| 65 | + |
| 66 | +### 4. Build Shared Package |
| 67 | + |
| 68 | +```bash |
| 69 | +pnpm --filter @events.comp-soc.com/shared build |
| 70 | +``` |
| 71 | + |
| 72 | +### 5. Start Development Servers |
| 73 | + |
| 74 | +```bash |
| 75 | +# Run both API and Web |
| 76 | +pnpm dev |
| 77 | + |
| 78 | +# Or run individually |
| 79 | +pnpm dev:api # API on http://localhost:8080 |
| 80 | +pnpm dev:web # Web on http://localhost:3000 |
| 81 | +``` |
| 82 | + |
| 83 | +## Clerk Webhook Setup |
| 84 | + |
| 85 | +To sync users from Clerk to your database: |
| 86 | + |
| 87 | +1. Go to [Clerk Dashboard](https://dashboard.clerk.com) → Webhooks |
| 88 | +2. Create a new endpoint with URL: `https://your-api-domain.com/webhooks/clerk` |
| 89 | +3. Subscribe to events: `user.created`, `user.updated`, `user.deleted` |
| 90 | +4. Copy the **Signing Secret** to `CLERK_WEBHOOK_SECRET` in your API `.env` |
| 91 | + |
| 92 | +For local development, use [ngrok](https://ngrok.com) to expose your local server: |
| 93 | + |
| 94 | +```bash |
| 95 | +ngrok http 8080 |
| 96 | +# Use the ngrok URL + /webhooks/clerk as your endpoint |
| 97 | +``` |
| 98 | + |
| 99 | +## API Endpoints |
| 100 | + |
| 101 | +| Method | Endpoint | Description | |
| 102 | +|--------|----------|-------------| |
| 103 | +| `GET` | `/health` | Health check | |
| 104 | +| `GET` | `/v1/events` | List events | |
| 105 | +| `POST` | `/v1/events` | Create event | |
| 106 | +| `GET` | `/v1/events/:id` | Get event | |
| 107 | +| `PUT` | `/v1/events/:id` | Update event | |
| 108 | +| `DELETE` | `/v1/events/:id` | Delete event | |
| 109 | +| `GET` | `/v1/events/:eventId/registrations` | List registrations | |
| 110 | +| `POST` | `/v1/events/:eventId/registrations` | Create registration | |
| 111 | +| `PATCH` | `/v1/events/:eventId/registrations/:userId` | Update registration status | |
| 112 | +| `GET` | `/v1/users/:id` | Get user | |
| 113 | +| `GET` | `/v1/users/registrations` | Get user's registrations | |
| 114 | +| `POST` | `/webhooks/clerk` | Clerk webhook endpoint | |
| 115 | + |
| 116 | +## Scripts |
| 117 | + |
| 118 | +### Root |
| 119 | + |
| 120 | +```bash |
| 121 | +pnpm dev # Run all apps in development |
| 122 | +pnpm build # Build all packages |
| 123 | +pnpm lint # Lint all apps |
| 124 | +pnpm format # Format code with Prettier |
| 125 | +pnpm typecheck # Type check all packages |
| 126 | +``` |
| 127 | + |
| 128 | +### API (`apps/api`) |
| 129 | + |
| 130 | +```bash |
| 131 | +pnpm dev # Start dev server with hot reload |
| 132 | +pnpm build # Build for production |
| 133 | +pnpm start # Start production server |
| 134 | +pnpm db:generate # Generate migrations |
| 135 | +pnpm db:migrate # Run migrations |
| 136 | +pnpm db:studio # Open Drizzle Studio |
| 137 | +pnpm test # Run tests |
| 138 | +``` |
| 139 | + |
| 140 | +### Web (`apps/web`) |
| 141 | + |
| 142 | +```bash |
| 143 | +pnpm dev # Start dev server on port 3000 |
| 144 | +pnpm build # Build for production |
| 145 | +pnpm preview # Preview production build |
| 146 | +pnpm test # Run tests |
| 147 | +``` |
| 148 | + |
| 149 | +## Docker |
| 150 | + |
| 151 | +Build and run the API with Docker: |
| 152 | + |
| 153 | +```bash |
| 154 | +docker-compose up --build |
| 155 | +``` |
| 156 | + |
| 157 | +The API will be available at `http://localhost:8080`. |
| 158 | + |
| 159 | +## Deployment |
| 160 | + |
| 161 | +### API |
| 162 | + |
| 163 | +The API is containerized and pushed to GitHub Container Registry on merge to `main`: |
| 164 | + |
| 165 | +``` |
| 166 | +ghcr.io/compsoc-edinburgh/events-api:latest |
| 167 | +``` |
| 168 | + |
| 169 | +### Web |
| 170 | + |
| 171 | +The web app can be deployed to Vercel. The `vercel.json` is already configured. |
| 172 | + |
| 173 | +## Testing |
| 174 | + |
| 175 | +API tests run against a PostgreSQL container: |
| 176 | + |
| 177 | +```bash |
| 178 | +cd apps/api |
| 179 | +pnpm test:local # Spins up test DB, runs tests, tears down |
| 180 | +``` |
| 181 | + |
| 182 | +## License |
| 183 | + |
| 184 | +MIT |
0 commit comments