Skip to content
Merged
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# DEVS Website

This repository contains the source code for the **DEVS (Developers Society) website**, built with **React, TypeScript, Tailwind CSS, and Vite**.
This repository contains the source code for the **DEVS (Developers Society) website** and the API behind it:

- `apps/web`: the website, built with **React, TypeScript, Tailwind CSS, and Vite**
- `apps/api`: the **Java / Spring Boot** API, the only thing that reads and writes the database
- `db`: database migrations, applied by Flyway in CI

Everything merged into `main` goes live on [dev.devsuoa.org](https://dev.devsuoa.org).

The project follows a component-first approach with shared design and development guidelines to ensure consistency across the site.

Expand Down
27 changes: 18 additions & 9 deletions apps/api/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# DEVS API

The only service that reads and writes the DEVS database and file storage. The website calls
this API; it no longer talks to Supabase tables, storage or edge functions directly. Supabase
is still used for logging in (Auth), Postgres and Storage.
this API instead of talking to Supabase tables, storage or edge functions. Supabase is still
used for logging in (Auth), Postgres and Storage.

**Status (November 2026):** the feature endpoints (members, contact, marketing, events, RSVP,
tasks, to-dos) were removed so club members can rebuild them, one page at a time. What's left
is the shared groundwork (auth, config, errors, storage, payments, audit log, invites) and
**links**, kept as the worked example to copy.

Java 25, Spring Boot 4, plain SQL through `JdbcClient`. Database changes live in
[`db/migrations`](../../db/migrations) and are applied by Flyway in CI, never by the API.
Expand All @@ -22,8 +27,8 @@ from [`db/seed/dev_seed.sql`](../../db/seed/dev_seed.sql), and runs the API on
There's no Supabase Auth in the local stack, so mint a token for one of the seeded users:

```sh
curl localhost:8080/api/events
curl -H "Authorization: Bearer $(apps/api/scripts/dev-token.sh admin)" localhost:8080/api/admin/members
curl localhost:8080/api/links
curl -H "Authorization: Bearer $(apps/api/scripts/dev-token.sh admin)" localhost:8080/api/admin/links
```

`pnpm dev` proxies `/api` to `localhost:8080`, so the website's public pages work against the
Expand Down Expand Up @@ -85,13 +90,17 @@ Then connect through the session pooler as `api_app.<project ref>`.

## Endpoints

Public: `GET /api/events`, `GET /api/links`, `GET /api/degrees`, `GET /api/degrees/{id}/majors`,
`POST /api/members`, `POST /api/events/{id}/rsvps`, `POST /api/events/{id}/rsvps/bank-transfer`,
`POST /api/events/{id}/rsvps/checkout`, `POST /api/contact`, `POST /api/webhooks/stripe` (Stripe-signed).
Public: `GET /api/health`, `GET /api/links`, `POST /api/webhooks/stripe` (Stripe-signed).

Logged in: `GET /api/me`.

Execs (`/api/admin/**`): events, uploads, attendees and payment proofs, members, links, event
to-dos/notes/doc links, tasks and comments, marketing requests.
Execs (`/api/admin/**`): links (`GET`, `POST`, `PUT /{id}`, `DELETE /{id}`, `PUT /order`) and
uploads (`POST /api/admin/uploads/event-image`, `POST /api/admin/uploads/link-icon`).

Superusers: `/api/admin/audit-log/**` (view and restore) and `/api/admin/users/invite`.

Until the RSVP endpoints are rebuilt, the Stripe webhook doesn't create RSVPs: a paid checkout is
marked `failed` with reason `rsvp_not_built`, so an admin can refund it.

New endpoints go on the public list in `SecurityConfig` or under `/api/admin/`. `SecurityMatrixTest`
fails for anything else.
63 changes: 63 additions & 0 deletions kb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,71 @@ All notable changes to this project are recorded here from **commit messages on
- **Chore** / deployment-only commits are included for a complete history; skim as needed.
- For full diffs, follow the commit link.

## November 2026

- [#0] Feature Rollback (#3): removes the feature endpoints so club members can rebuild them; feature pages go back to their pre-API code — [a48f7b2](https://github.com/devsuoa/devs-core/commit/a48f7b2) (2026-11-25)
- Proof of concept (#2): adds the Java API and moves all data access behind it — [ea65c84](https://github.com/devsuoa/devs-core/commit/ea65c84) (2026-11-19)

## October 2026

- Chore/FlywaySetup (#1): database migrations with Flyway — [298d43e](https://github.com/devsuoa/devs-core/commit/298d43e) (2026-10-26)

## September 2026

- chore: deploy loading screen (#152) — [5e40d2a](https://github.com/devsuoa/devs-core/commit/5e40d2a) (2026-09-29)
- feat: added loading screen (#151) — [422e3aa](https://github.com/devsuoa/devs-core/commit/422e3aa) (2026-09-18)

## August 2026

- feat: new execs on team page (#150) — [87876ef](https://github.com/devsuoa/devs-core/commit/87876ef) (2026-08-28)
- chore: deploy changes (#149) — [ac3aa24](https://github.com/devsuoa/devs-core/commit/ac3aa24) (2026-08-14)
- fix: improve pagination, filtering, event image cleanup (#148) — [b24b05b](https://github.com/devsuoa/devs-core/commit/b24b05b) (2026-08-14)
- feat: add smooth scrolling (#147) — [801680a](https://github.com/devsuoa/devs-core/commit/801680a) (2026-08-14)
- chore: update pnpm-lock.yaml to fix vercel build (#146) — [ea18226](https://github.com/devsuoa/devs-core/commit/ea18226) (2026-08-07)
- chore: deploy changes — [80de96c](https://github.com/devsuoa/devs-core/commit/80de96c) (2026-08-07)
- fix: event rsvp disappearing on day of event (#145) — [297c449](https://github.com/devsuoa/devs-core/commit/297c449) (2026-08-07)
- improve: Change fonts and make things look better (#142) — [b0249b5](https://github.com/devsuoa/devs-core/commit/b0249b5) (2026-08-02)
- feat: add auto linking when creating events (#143) — [fdf4f1e](https://github.com/devsuoa/devs-core/commit/fdf4f1e) (2026-08-02)
- chore: reformatting entire repo with prettier (#136) — [016c2d5](https://github.com/devsuoa/devs-core/commit/016c2d5) (2026-08-02)

## July 2026

- fix: change qr code url (#144) — [bbdce2f](https://github.com/devsuoa/devs-core/commit/bbdce2f) (2026-07-20)

## May 2026

- fix: rsvp is case insensitive (#141) — [42f072a](https://github.com/devsuoa/devs-core/commit/42f072a) (2026-05-15)
- fix: past events order reversed to descending dates (#140) — [c013193](https://github.com/devsuoa/devs-core/commit/c013193) (2026-05-14)
- feat: add rsvp for non members in rsvp dialog (#139) — [f0b4947](https://github.com/devsuoa/devs-core/commit/f0b4947) (2026-05-11)
- fix: filtering on the events page and allow for inactive events (#138) — [d1e6398](https://github.com/devsuoa/devs-core/commit/d1e6398) (2026-05-11)
- fix: added active/inactive events (#130) — [37ecac3](https://github.com/devsuoa/devs-core/commit/37ecac3) (2026-05-08)

## April 2026

- chore: reroute qr code for imc tech race (#137) — [11a82b2](https://github.com/devsuoa/devs-core/commit/11a82b2) (2026-04-21)
- feat: visual indicator of completed task and current day (#128) — [4857c84](https://github.com/devsuoa/devs-core/commit/4857c84) (2026-04-17)
- fix: prevent duplicated submissions by disabling submit button (#133) — [798d87d](https://github.com/devsuoa/devs-core/commit/798d87d) (2026-04-17)
- chore: updated audit row limit (#134) — [a7ed1b2](https://github.com/devsuoa/devs-core/commit/a7ed1b2) (2026-04-17)
- fix: prevent bank transfers submission from non members (#129) — [8bede84](https://github.com/devsuoa/devs-core/commit/8bede84) (2026-04-16)
- chore: deploy drag and drop for links (#127) — [314de3b](https://github.com/devsuoa/devs-core/commit/314de3b) (2026-04-14)
- feat: implemented drag and drop to manage links (#126) — [f755975](https://github.com/devsuoa/devs-core/commit/f755975) (2026-04-14)
- feat: added graphs and undo to audit log (#125) — [ac20269](https://github.com/devsuoa/devs-core/commit/ac20269) (2026-04-13)
- chore: deploy rsvp fix (#124) — [253f8b0](https://github.com/devsuoa/devs-core/commit/253f8b0) (2026-04-11)
- fix: adjust for moible resize on rsvp (#123) — [5d41ac2](https://github.com/devsuoa/devs-core/commit/5d41ac2) (2026-04-11)
- fix: prevent unexpected rsvp close on mobile (#122) — [aaf7d5c](https://github.com/devsuoa/devs-core/commit/aaf7d5c) (2026-04-10)
- fix: prevent unwanted rsvp close (#121) — [d530246](https://github.com/devsuoa/devs-core/commit/d530246) (2026-04-10)
- fix: stop ghost clicks from closing rsvp dialog (#120) — [e37a5e6](https://github.com/devsuoa/devs-core/commit/e37a5e6) (2026-04-10)
- fix: group attendee count is accurate (#119) — [73d6484](https://github.com/devsuoa/devs-core/commit/73d6484) (2026-04-10)
- fix: add payment disclaimers (#118) — [9463d6f](https://github.com/devsuoa/devs-core/commit/9463d6f) (2026-04-10)
- feat: introduce payments (#116) — [8cc7c31](https://github.com/devsuoa/devs-core/commit/8cc7c31) (2026-04-10)
- feat: introduce event to do lists (#115) — [c9e48d1](https://github.com/devsuoa/devs-core/commit/c9e48d1) (2026-04-06)
- feat: posthog user failure tracking (#114) — [b47614f](https://github.com/devsuoa/devs-core/commit/b47614f) (2026-04-06)

## March 2026

- feat: introduce kartik glazer page (#113) — [e8309af](https://github.com/devsuoa/devs-core/commit/e8309af) (2026-03-27)
- feat: autofill on events rsvp to join redirect (#112) — [9defbfd](https://github.com/devsuoa/devs-core/commit/9defbfd) (2026-03-27)
- fix: improve rsvp grammar discrepencies (#111) — [301dba4](https://github.com/devsuoa/devs-core/commit/301dba4) (2026-03-27)
- feat: extend rsvp capability (#109) — [e699834](https://github.com/Gh05stt/devsuoa/commit/e699834) (2026-03-26)
- fix: event card register button and desc adujustments (#104) — [ef4366f](https://github.com/Gh05stt/devsuoa/commit/ef4366f) (2026-03-25)
- fix: adjust sponsor card font (#108) — [5a73e7f](https://github.com/Gh05stt/devsuoa/commit/5a73e7f) (2026-03-25)
Expand Down
180 changes: 42 additions & 138 deletions kb/auth.md
Original file line number Diff line number Diff line change
@@ -1,178 +1,82 @@
# Auth Service

The **Auth Service** provides authentication functionality for admin users through Supabase Auth. It handles user signup and login with role-based access control, ensuring only users with the `admin` role can access protected admin areas.
Execs log in with **Supabase Auth**. Whether someone is an exec is decided by the **DEVS API** from the database on every request, never by the browser. There is no public admin signup: superusers invite new execs.

## Purpose

- Admin user registration with email verification
- Secure admin login with role validation
- Email domain validation during signup
- Profile management integration with Supabase
- Exec login and logout
- Password reset by email
- Admin-only pages for execs, and superuser-only tools (audit log, inviting execs)

## Supabase Setup Requirements
## Environment variables

### 1. Environment Variables

Create a `.env` file in the project root with the following variables:
The website's `apps/web/.env` needs:

```env
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
```

**Where to find these values:**

- Go to your Supabase project dashboard
- Navigate to **Settings** → **API**
- Copy the **Project URL** (for `VITE_SUPABASE_URL`)
- Copy the **anon/public** key (for `VITE_SUPABASE_ANON_KEY`)

> **Note:** The `.env` file is already in `.gitignore` to prevent committing sensitive credentials.

## How Signup Works

The signup flow (`handleSignupSubmit` in `src/lib/signup.ts`) follows these steps:

### 1. Client-Side Validation

- **Username validation:** Ensures username is provided and not empty
- **Password matching:** Verifies password and confirm password match
- **Password length:** Requires minimum 6 characters
- **Email format:** Validates email format using regex

### 2. Email Domain Verification

- Extracts domain from email address
- Queries Google DNS API to verify the domain has MX records
- Prevents signup with invalid or non-existent email domains

### 3. Supabase Account Creation

- Calls `supabase.auth.signUp()` with email and password
- Includes username in user metadata (`options.data.username`)
- Handles Supabase-specific errors (e.g., email already exists)

### 4. Profile Creation

- After successful signup, updates the `profiles` table
- Sets the `username` field from the signup form
- Links profile to the authenticated user via `id`

### 5. Success Handling

- Displays success message prompting user to check email
- Clears all form fields
- User must confirm email before logging in (if email confirmation is enabled)

### Signup Flow Diagram

```
User submits form
↓
Client-side validation (username, password, email format)
↓
Email domain verification (DNS check)
↓
Supabase auth.signUp()
↓
Update profiles table with username
↓
Success: Clear form, show success message
```

## How Login Works

The login flow (`handleLoginSubmit` in `src/lib/login.ts`) follows these steps:

### 1. Authentication

- Calls `supabase.auth.signInWithPassword()` with email and password
- Validates credentials against Supabase Auth

### 2. Role Verification
Find them in the Supabase dashboard under **Settings** → **API**. The anon key is public by design: it can log people in, but it can't read or write any table.

- Queries the `profiles` table to fetch user's role
- Verifies the role is `'admin'`
- If role is not `'admin'`, signs out the user and shows error
> **Note:** `.env` is in `.gitignore`. Never commit it.

### 3. Success Handling
## How login works

- Clears form fields
- Currently logs success
- User is now authenticated and can access protected routes
`handleLoginSubmit` in `apps/web/src/lib/login.ts`:

### Login Flow Diagram
1. Calls `supabase.auth.signInWithPassword()` with the email and password.
2. Calls `GET /api/me` through `fetchMe()` in `apps/web/src/lib/api.ts`. The API reads the caller's role from `public.profiles`.
3. If the role isn't `admin`, signs the user out and shows "You do not have access".
4. Otherwise clears the form and goes to `/admin/dashboard`.

```
User submits form
↓
supabase.auth.signInWithPassword()
↓
Query profiles table for user role
GET /api/me (API reads the role from profiles)
↓
Verify role === 'admin'
↓
Success: Clear form, redirect to dashboard (TODO)
role === 'admin' ? → /admin/dashboard
: → sign out, "You do not have access"
```

## Pages

### Admin Signup Page

**Route:** `/admin/signup`

**Component:** `src/pages/admin/AdminSignup.tsx`
Admin pages call `checkAdminAuthorization()` in `apps/web/src/lib/auth.ts`, which repeats the same `/api/me` check for an existing session.

**Features:**
Every API call sends the Supabase access token as a `Bearer` header (`api.ts` adds it). The API checks the token and reads the role again on every request, so removing someone's `admin` role ends their access straight away.

- Two-column form layout (name/email, password/confirm password)
- Real-time password matching validation
- Email domain verification
- Success message after signup
- Error handling with user-friendly messages
## Password reset

### Admin Login Page
- `handlePasswordReset(email)` sends a Supabase reset email that links to `/admin/reset-password`.
- `handlePasswordUpdate(newPassword)` sets the new password (minimum 6 characters).

**Route:** `/admin/login`
## Adding execs

**Component:** `src/pages/admin/AdminLogin.tsx`
Superusers invite execs with `POST /api/admin/users/invite`. The API creates the login through Supabase Auth and sends the invite email. There is no page for this yet.

**Features:**

- Role-based access control (admin only)
- Error handling for invalid credentials
- Loading states during authentication

## Error Handling

Both signup and login handlers provide error messages:

**Common Signup Errors:**
## Pages

- `"Please enter your name"` - Username validation failed
- `"Passwords do not match"` - Password confirmation mismatch
- `"Password must be at least 6 characters long"` - Password too short
- `"Please enter a valid email address"` - Invalid email format
- `"This email domain does not exist or cannot receive emails"` - DNS verification failed
- Supabase-specific errors (e.g., email already exists)
| Route | Component | What it does |
| ----------------------- | ------------------------------------------------- | -------------------------------------- |
| `/admin/login` | `apps/web/src/pages/admin/AdminLogin.tsx` | Login and "forgot password" |
| `/admin/reset-password` | `apps/web/src/pages/admin/AdminResetPassword.tsx` | Set a new password from the email link |

**Common Login Errors:**
## Error messages

- `"Invalid email or password"` - Authentication failed
- `"Failed to verify user role"` - Profile lookup failed
- `"You do not have access"` - User does not have admin role
- `"Invalid email or password"`: Supabase rejected the login.
- `"You do not have access"`: logged in, but not an exec.
- `"Please enter a valid email address"`: reset form email is malformed.
- `"Password must be at least 6 characters long"`: new password too short.

## Security Considerations
## Security

1. **Environment Variables:** Never commit `.env` file to version control
2. **Role Verification:** Always verify user roles server-side for sensitive operations
3. **Email Confirmation:** Enable email confirmation in Supabase for production
4. **Password Requirements:** Currently minimum 6 characters; need to consider implementing stronger requirements
5. **Rate Limiting:** Supabase provides built-in rate limiting for auth endpoints
1. **Roles live in the database.** Only the API reads `profiles.role` and `profiles.is_superuser`. The browser can't change them (migration `V20261026_0300` closed that hole).
2. **Never commit `.env`**, and never put the Supabase service role key in the website's env. Only the API has it.
3. **Email confirmation** should stay enabled in the Supabase Auth settings.
4. **Rate limiting:** Supabase limits auth endpoints; the API limits public writes per IP.

## Future Enhancements
## Future enhancements

- [ ] Password reset functionality
- [ ] A page for superusers to invite execs
- [ ] Two-factor authentication (2FA)
- [ ] Stronger password requirements (uppercase, numbers, special characters)
- [ ] Account lockout after failed login attempts
- [ ] Stronger password requirements
8 changes: 7 additions & 1 deletion kb/commit_guidelines.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# DEVS Commit & Branching Guidelines

These guidelines define how to write commit messages and name branches for DEVS projects.
They exist to keep our Git history **clean, readable, and consistent**. As well as to avoid any breaking changes from being deployed into production
They exist to keep our Git history **clean, readable, and consistent**. As well as to avoid any breaking changes from being deployed

> **Important:**
> Always open a Pull Request
Expand Down Expand Up @@ -65,3 +65,9 @@ All branches **must** follow this format:
- Reference the task ID
- Be small and focused where possible
- Do not self-merge unless explicitly approved

`main` enforces this with a GitHub ruleset:

- Changes reach `main` only through a PR. Direct pushes, force pushes and deleting `main` are blocked.
- Each PR needs 1 approval from the `devscore-approvals` team. A new push after approval needs approving again.
- PRs are squash merged. After yours merges, start your next branch from the latest `main`.
2 changes: 2 additions & 0 deletions kb/events_and_rsvp.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Events & RSVP

> **Status (November 2026):** this feature is being rebuilt on the Java API. Its code still uses the direct Supabase calls described below, and the database now refuses them (migration `V20261026_0320`), so it won't work until the rebuild is merged. The rebuilt version gets its data through `api()` in `apps/web/src/lib/api.ts`.

> **AI documentation notice:** This page was created with AI assistance and **may contain errors**. See [Documentation disclaimer](disclaimer.md).

This document describes how **public events**, **RSVP**, **admin event management**, and the **event attendees dashboard** work in the codebase. It complements [Repository overview](repository_overview.md) and [Auth Service](auth.md).
Expand Down
Loading