diff --git a/README.md b/README.md index 202e1d4..5ab2b97 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/apps/api/README.md b/apps/api/README.md index 39997a8..9c7803d 100644 --- a/apps/api/README.md +++ b/apps/api/README.md @@ -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. @@ -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 @@ -85,13 +90,17 @@ Then connect through the session pooler as `api_app.`. ## 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. diff --git a/kb/CHANGELOG.md b/kb/CHANGELOG.md index 037fce8..eaf2dc8 100644 --- a/kb/CHANGELOG.md +++ b/kb/CHANGELOG.md @@ -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) diff --git a/kb/auth.md b/kb/auth.md index a13f87b..a781f01 100644 --- a/kb/auth.md +++ b/kb/auth.md @@ -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 diff --git a/kb/commit_guidelines.md b/kb/commit_guidelines.md index 0689b27..6f54f0c 100644 --- a/kb/commit_guidelines.md +++ b/kb/commit_guidelines.md @@ -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 @@ -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`. diff --git a/kb/events_and_rsvp.md b/kb/events_and_rsvp.md index 9465271..2effd2f 100644 --- a/kb/events_and_rsvp.md +++ b/kb/events_and_rsvp.md @@ -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). diff --git a/kb/feature_flags.md b/kb/feature_flags.md index b5b1c9b..a258f75 100644 --- a/kb/feature_flags.md +++ b/kb/feature_flags.md @@ -1,6 +1,6 @@ # Feature Flags -Everything merged into `main` is **automatically deployed to production**. +Everything merged into `main` is **automatically deployed to [dev.devsuoa.org](https://dev.devsuoa.org)**. Sometimes we need to merge work that **isn’t ready to be public yet**. Feature flags let us safely ship code without exposing unfinished features. @@ -10,7 +10,7 @@ Feature flags let us safely ship code without exposing unfinished features. Feature flags are defined in: ``` -src/config/feature-flags.json +apps/web/src/config/feature-flags.json ``` Each flag controls whether a feature, page, or section of the site is accessible at runtime. diff --git a/kb/genericRSVPDialog.md b/kb/genericRSVPDialog.md index 440a5d0..1978ac6 100644 --- a/kb/genericRSVPDialog.md +++ b/kb/genericRSVPDialog.md @@ -1,5 +1,7 @@ # Generic RSVP Dialog Component +> **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`. + The **GenericRSVPDialog** is a modal used to collect **event RSVPs**: leader email, optional **group emails** (when the event allows group RSVP), dietary requirements, and **per-event custom questions** (text, single select, or multi select). When the leader's email does not belong to an existing DEVS member, the dialog **reveals an inline signup step** so the user can register and RSVP without leaving the page. ## Purpose @@ -81,7 +83,6 @@ import { rsvpToEvent } from "./lib/eventsRSVPController"; ## Related -- `src/components/MemberSignupFields.tsx` – shared signup form fields (also used by `/join`) - `src/lib/eventsRSVPController.ts` – server-side rules and Supabase writes; throws `NotMemberError` - `src/lib/signupController.ts` – creates the member record from `signupInfo` - `src/lib/eventRsvpTypes.ts` – question shapes diff --git a/kb/home.md b/kb/home.md index ee563e9..873a86d 100644 --- a/kb/home.md +++ b/kb/home.md @@ -1,6 +1,6 @@ # Home -Welcome to the Knowledge Base (KB) for the DEVS Website. +Welcome to the Knowledge Base (KB) for the DEVS website and its Java API. This is to help understand components and guidelines to ensure everyone is on the same page. > **AI documentation notice:** Some KB material (including repository-wide docs) was **generated or assisted by AI** and **may contain errors**. Always verify against the codebase. Full wording: [Documentation disclaimer](disclaimer.md). @@ -25,7 +25,6 @@ This is to help understand components and guidelines to ensure everyone is on th ### Components -- [Binary Background Component](binaryBackground.md) - [Cookie Disclaimer Component](cookiesDisclaimer.md) - [Events Card Component](eventsCard.md) - [Footer Component](footer.md) @@ -35,6 +34,7 @@ This is to help understand components and guidelines to ensure everyone is on th - [Page Title Component](pagetitle.md) - [Pagination Component](pagination.md) - [Pixelated Button Component](pixelatedButton.md) +- [Site Toast Component](siteToast.md) - [Social Links Component](socialLinks.md) - [Sponsor Card Component](sponsorCard.md) - [Sponsor Form Component](sponsorForm.md) @@ -45,6 +45,7 @@ This is to help understand components and guidelines to ensure everyone is on th ### Pages - [Auth](auth.md) +- [Links](links.md) - [Marketing Portal](marketingPortal.md) - [Page Not Found](pageNotFound.md) diff --git a/kb/links.md b/kb/links.md index e257b3f..a5618ca 100644 --- a/kb/links.md +++ b/kb/links.md @@ -11,6 +11,8 @@ The **Links Management** system provides a way to manage and display active link ## Database Setup +The `links` table is defined in `db/migrations`. Only the API reads and writes it. + ### Table Fields - **id** (UUID): Primary key, auto-generated @@ -21,6 +23,7 @@ The **Links Management** system provides a way to manage and display active link - **active_to** (TIMESTAMPTZ): Optional end date for when link becomes inactive - **display_order** (INTEGER): Order in which links are displayed (lower numbers appear first) - **is_spacer** (BOOLEAN): Whether this is a spacer/divider (not a clickable link) +- **custom_icon** (TEXT): Optional uploaded icon, used instead of the favicon - **created_at** (TIMESTAMPTZ): Timestamp when link was created - **updated_at** (TIMESTAMPTZ): Timestamp when link was last updated @@ -62,7 +65,8 @@ The **Links Management** system provides a way to manage and display active link - Add spacers/dividers between links (with optional title) - Edit existing links and spacers - Delete links and spacers with confirmation -- Reorder links and spacers using up/down buttons +- Reorder links and spacers by dragging them +- Upload a custom icon for a link - View all links with their current status (ACTIVE/INACTIVE) - See date ranges for each link - Toggle active status for links and spacers @@ -85,12 +89,13 @@ Located at `src/lib/linksController.ts`, provides: **Functions:** -- `fetchActiveLinks()`: Fetches and filters currently active links (ordered by display_order) -- `fetchAllLinks()`: Fetches all links (for admin, ordered by display_order) -- `createLink()`: Creates a new link (auto-assigns display_order if not provided) -- `updateLink()`: Updates an existing link -- `deleteLink()`: Deletes a link -- `reorderLinks()`: Swaps display_order of two links +- `fetchActiveLinks()`: `GET /api/links`, then keeps the currently active ones (ordered by display_order) +- `fetchAllLinks()`: `GET /api/admin/links`, every link for the admin page +- `createLink()`: `POST /api/admin/links` (display_order is auto-assigned if not provided) +- `updateLink()`: `PUT /api/admin/links/{id}` +- `deleteLink()`: `DELETE /api/admin/links/{id}` +- `updateLinkOrder()` / `reorderLinks()`: save the new order with `PUT /api/admin/links/order` +- `uploadLinkIcon()`: `POST /api/admin/uploads/link-icon`, returns the icon URL - `getFaviconUrl()`: Generates favicon URL from domain - `isLinkCurrentlyActive()`: Checks if a link is currently active @@ -111,10 +116,10 @@ Favicons are fetched based on the domain extracted from the link URL. ## Security -- **Row Level Security (RLS)** is enabled on the `links` table -- Public read access for displaying links -- Admin-only write access (insert, update, delete) -- Admin authentication verified through `profiles.role = 'admin'` +- Anyone can read links through `GET /api/links`. +- Adding, editing, reordering and deleting go through `/api/admin/links`, which needs an exec login. The API checks `profiles.role = 'admin'` on every request. +- The API rejects unsafe URLs (for example `javascript:`) and checks field lengths. +- The browser can't touch the `links` table directly. ## Usage Examples @@ -148,13 +153,11 @@ Spacers allow you to add visual breaks or section headers between links: ## Reordering Links -Links and spacers can be reordered using the up/down arrow buttons on the Manage Links page: +Drag links and spacers on the Manage Links page to reorder them: -- Click the ↑ button to move a link/spacer up in the list -- Click the ↓ button to move a link/spacer down in the list -- The first item cannot be moved up, and the last item cannot be moved down -- Reordering updates the `display_order` field in the database -- Items are displayed in order on both the public Links page and the Manage Links page +- Grab an item and drop it where it should go. +- The new order is saved in one request (`PUT /api/admin/links/order`), which updates `display_order` for every link. +- The order is the same on the public Links page and the Manage Links page. ## Future Enhancements diff --git a/kb/marketingPortal.md b/kb/marketingPortal.md index 7e38bdd..f175cb6 100644 --- a/kb/marketingPortal.md +++ b/kb/marketingPortal.md @@ -1,5 +1,7 @@ # Marketing Portal +> **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`. + The **Marketing Portal** provides a form-based interface for Execs to submit marketing requests for events or sponsorship posts. It integrates with Google Sheets via Google Apps Script and automatically creates Asana tasks through Zapier automation. ## Purpose diff --git a/kb/pageNotFound.md b/kb/pageNotFound.md index c552465..5972839 100644 --- a/kb/pageNotFound.md +++ b/kb/pageNotFound.md @@ -30,7 +30,7 @@ The Page Not Found system consists of two parts: ### Component ``` -src/pages/PageNotFound.tsx +apps/web/src/pages/PageNotFound.tsx ``` ### Responsibilities @@ -58,7 +58,7 @@ This ensures that **any unknown route** automatically resolves to the Page Not F ### Location ``` -src/lib/pageNotFoundController.tsx +apps/web/src/lib/pageNotFoundController.ts ``` ### Purpose diff --git a/kb/repository_overview.md b/kb/repository_overview.md index 713d6e2..d6591f0 100644 --- a/kb/repository_overview.md +++ b/kb/repository_overview.md @@ -2,23 +2,23 @@ > **AI documentation notice:** This page was created with AI assistance and **may contain errors**. See [Documentation disclaimer](disclaimer.md). -This document summarises the **DEVS website** codebase: layout, routing, major dependencies, and how data and admin tools fit together. Use it alongside [Project Setup](setup.md) and feature-specific KB pages. +This document summarises the **DEVS website** and the **Java API** behind it: layout, routing, major dependencies, and how data and admin tools fit together. Use it alongside [Project Setup](setup.md) and feature-specific KB pages. ## Purpose - Give new contributors a **map of the repository** without opening every folder. - List **public and admin routes** as wired in the app. -- Describe **Supabase-backed features** and **client-side integrations** at a high level. +- Describe how pages get their data (through the Java API) and the **client-side integrations** at a high level. ## Tech stack -As declared in `package.json` and used in practice: +Website, as declared in `apps/web/package.json`: - **React** (19) and **TypeScript** - **Vite** – dev server and production build - **React Router** – client-side routing - **Tailwind CSS** – utility-first styling (`src/main.css` entry) -- **Supabase** – auth, Postgres data, storage, and Edge Function invocation (`@supabase/supabase-js`) +- **Supabase** – login (`@supabase/supabase-js`). Data is moving to the Java API; see [Data access](#data-access) - **MUI** (`@mui/material`, icons) and **Emotion** – component library usage where adopted - **Framer Motion**, **GSAP** – motion and animation - **@dnd-kit** – drag-and-drop (e.g. task UI) @@ -26,10 +26,12 @@ As declared in `package.json` and used in practice: - **react-paginate** – pagination primitives (see also the custom [Pagination](pagination.md) component) - **recharts** – charts where used - **posthog-js** – product analytics (optional; gated by env and cookie consent) -- **resend** – present as a dependency; outbound mail from the **browser** goes through Supabase (see [Email](#email-and-edge-functions)) +- **resend** – present as a dependency but unused; email is sent by the API (see [Email](#email)) **Linting:** ESLint with React hooks and refresh plugins. +API (`apps/api`): **Java 25**, **Spring Boot 4**, plain SQL through `JdbcClient`, Spring Security checking Supabase login tokens. See [the API README](../apps/api/README.md). + ## Top-level layout The repo is a pnpm workspace (monorepo). Each app lives in its own folder, and repo-wide tooling (Prettier, git hooks, commit rules, docs) stays at the root. @@ -39,7 +41,7 @@ The repo is a pnpm workspace (monorepo). Each app lives in its own folder, and r | `apps/web/` | This website (Vite + React). Paths below starting `src/` are in here | | `apps/api/` | Java / Spring Boot API | | `apps/mobile/` | _Planned:_ Expo / React Native app | -| `db/` | Flyway database migrations | +| `db/` | Flyway database migrations (schema, RLS policies, grants) | | `services/audit/` | _Planned:_ separate audit log service | | `packages/` | _Planned:_ shared code, e.g. the API client generated from OpenAPI | | `kb/` | Knowledge base (this documentation) | @@ -55,11 +57,10 @@ The repo is a pnpm workspace (monorepo). Each app lives in its own folder, and r | `src/pages/` | Route-level screens (public, admin, legal, utility) | | `src/pages/admin/` | Admin-only flows (dashboard, CMS-style tools) | | `src/pages/hidden/` | Non-marketed routes (e.g. easter-egg page) | -| `src/lib/` | Data access, auth helpers, hooks, feature logic (“controllers”) | +| `src/lib/` | API calls, auth helpers, hooks, feature logic (“controllers”) | | `src/config/` | Static config (e.g. `feature-flags.json`) | | `src/data/` | Bundled JSON (e.g. sponsor data mirror) | | `public/` | Static assets served as-is; includes sponsor JSON used by the site | -| `vercel.json` | SPA rewrite: all paths → `index.html` | | `.env` | Local environment variables (not committed) | The README at the repo root links to [Home](home.md) for documentation entry. @@ -99,11 +100,10 @@ Routes are defined in `src/App.tsx`. Approximate grouping: | `/qr-code` | `QRCode` | | `/404` and `*` | `PageNotFound` | -### Admin (Supabase `admin` role) +### Admin (`admin` role in `profiles`, checked by the API) | Path | Page component | | -------------------------- | ---------------------------- | -| `/admin/signup` | `AdminSignup` | | `/admin/login` | `AdminLogin` | | `/admin/reset-password` | `AdminResetPassword` | | `/admin/dashboard` | `AdminDashboard` | @@ -114,13 +114,15 @@ Routes are defined in `src/App.tsx`. Approximate grouping: | `/admin/tasks` | `TaskTracker` | | `/admin/event-attendees` | `EventsDashboard` | | `/admin/audit-log` | `AdminCMSAuditLog` | +| `/admin/event-todo` | `EventTodo` | | `/admin/*` | Fallback to `AdminDashboard` | ### Hidden -| Path | Notes | -| ---------- | ---------------------------------- | -| `/p/b/6/7` | `Pb` – intentionally obscure route | +| Path | Notes | +| ----------- | ---------------------------------- | +| `/p/b/6/7` | `Pb` – intentionally obscure route | +| `/p/kartik` | `KartikGlazer` | Admin layout: many admin screens use shared chrome (`Header`, `PageTitle`, `Footer`) and **`useAdminDashboard`** or equivalent checks (`checkAdminAuthorization` in `auth.ts`) before showing content. @@ -128,43 +130,56 @@ Admin layout: many admin screens use shared chrome (`Header`, `PageTitle`, `Foot Flags live in `src/config/feature-flags.json` and are read through **`isFeatureEnabled`** in `src/lib/featureFlags.ts`. Pages and navigation should consult flags before exposing routes or links. Details: [Feature Flags](feature_flags.md). -## Supabase and data model (client usage) +## Data access + +Pages get their data from the **Java API** through `api()` in `src/lib/api.ts`, which adds the logged-in user's token. In dev, Vite proxies `/api` to the local API; on Firebase Hosting, `/api/**` is routed to the API on Cloud Run (`firebase.json`). + +**Status (November 2026):** most features are being rebuilt on the API, one page at a time. + +| Feature | Where its data comes from today | +| ------------------------------------------------------------------------ | ----------------------------------------------------------- | +| Login, links, audit log, image uploads, exec invites | The Java API | +| Member signup, events, RSVP, attendees, members, tasks, todos, marketing | Old direct Supabase calls (tables, storage, Edge Functions) | +| Contact and sponsor forms | The Supabase Edge Function `send-email` | -The Supabase client is created in `src/lib/supabase.ts` from **`VITE_SUPABASE_URL`** and **`VITE_SUPABASE_ANON_KEY`**. If either is missing, the client throws at import time with a pointer to the KB. +Since migration `V20261026_0320`, the browser's database roles can't read or write any table, so the pages in the second row don't work until they're rebuilt on the API. The Supabase client in `src/lib/supabase.ts` (from **`VITE_SUPABASE_URL`** and **`VITE_SUPABASE_ANON_KEY`**) is meant only for logging in. -Tables and resources referenced from `src/lib` (names as in code; RLS and schemas live in Supabase, not in this repo): +The schema, RLS policies and grants live in `db/migrations` (see [Database Migrations](database_migrations.md)). Main tables: -| Name | Typical use | -| --------------------------------- | -------------------------------------------------------------------------------- | -| `profiles` | Auth-linked profiles; `role` (e.g. `admin`), `is_superuser` for audit log access | -| `events` | Event listings, RSVP settings, active flag | -| `events_rsvp` | RSVP rows (email, group, answers, attendance, links to members/events) | -| `members` | Member signup inserts | -| `student_degree`, `student_major` | Degree/major relations after signup | -| `degrees`, `degree_major` | Reference data for signup (`degreeData.ts`) | -| `links` | Manageable links CRUD | -| `member_registry` | Read model for admin member registry | -| `tasks`, `task_comments` | Task tracker | -| `marketing_requests` | Marketing portal persistence (alongside external Google Sheet flow) | -| `admin_audit_log` | CMS audit entries; superuser-gated UI | +| Name | Typical use | +| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `profiles` | Login-linked profiles; `role` (e.g. `admin`), `is_superuser` for audit log access | +| `events` | Event listings, RSVP settings, active flag | +| `events_rsvp` | RSVP rows (email, group, answers, attendance, links to members/events) | +| `event_rsvp_pending_payments` | Card checkouts waiting for Stripe to confirm payment | +| `members` | Member signups | +| `student_degree`, `student_major` | Degree/major choices per member | +| `degrees`, `majors`, `degree_major` | Reference data for signup | +| `member_registry` | View used by the admin member registry | +| `links` | Links page content | +| `tasks`, `task_comments` | Task tracker | +| `event_todo_items`, `event_todo_comments`, `event_notes`, `event_doc_links` | Event to-do lists | +| `marketing_requests` | Marketing portal requests | +| `admin_audit_log` | Audit trail written by database triggers; superuser-only page | -**Storage buckets (from code):** `event-images` (public URLs for event images), and link-related uploads as implemented in `linksController` (bucket naming in code should be treated as the source of truth). +**Storage buckets:** `event-images`, `event-payments` (bank transfer screenshots) and `Links` (link icons). The API uploads to them through `/api/admin/uploads/*`, using the server-only service role key. The browser can't write to them directly any more. ## Lib layer (“controllers”) Business logic and data fetching are concentrated under **`src/lib/`** rather than inside large page files. Examples: - **`auth.ts`** – session check, admin role verification, password reset/update helpers -- **`login.ts`**, **`signup.ts`** – admin auth forms and profile updates +- **`api.ts`** – the API client every page uses (`api()`, `ApiError`, `fetchMe()`) +- **`login.ts`** – exec login form - **`eventsController.ts`** – public active events and date helpers - **`manageEventsController.ts`**, **`eventsRSVPController.ts`**, **`eventsDashboardController.ts`** – admin CRUD, RSVP submission rules, attendee reporting - **`memberSignup.ts`**, **`signupController.ts`** – public member registration pipeline - **`memberRegistryController.ts`** – registry fetch and chart helpers - **`linksController.ts`** – links management and uploads - **`taskTrackerController.ts`** – tasks and comments -- **`marketingPortalController.ts`** – marketing requests (Supabase + external POST) +- **`marketingPortalController.ts`** – marketing requests (old Supabase calls, being rebuilt) - **`auditLogController.ts`** – superuser check and audit log fetch -- **`emailController.ts`** – invokes Supabase Edge Function `send-email` +- **`emailController.ts`** – contact and sponsor form (Edge Function `send-email`, being rebuilt) - **`posthog.ts`** – analytics init, opt-in/out vs cookie consent - **`cookieConsentController.ts`** – consent persistence used with cookies UI - **`pageNotFoundController.ts`** – centralised navigation for 404 behaviour @@ -174,16 +189,9 @@ Business logic and data fetching are concentrated under **`src/lib/`** rather th Naming is not uniform (`*Controller.ts` vs `use*` hooks in the same file); when extending the app, match the nearest existing feature. -## Email and Edge Functions +## Email -The client invokes Supabase Edge Functions by name or URL. Examples referenced in this repo: - -| Function | Invoked from | -| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -| `send-email` | `src/lib/emailController.ts` via `supabase.functions.invoke` | -| `create-marketing-task` | `src/lib/marketingPortalController.ts` via authenticated `fetch` to `{VITE_SUPABASE_URL}/functions/v1/create-marketing-task` | - -Implementation and secrets (e.g. email provider such as Resend) live in the **Supabase project**, not necessarily in this repository. +Today the contact and sponsor forms call the Supabase Edge Function `send-email` (`src/lib/emailController.ts`). The rebuild moves this to an API endpoint, where the API builds the email and sends it through **Resend** (the API already has `EMAIL_MODE`, `RESEND_API_KEY` and `CONTACT_EMAIL_TO` settings). The browser should never choose the recipient. ## Analytics @@ -191,12 +199,7 @@ PostHog is initialised in `src/lib/posthog.ts` with **`VITE_PUBLIC_POSTHOG_KEY`* ## Marketing portal -On submit, `handleMarketingSubmit` in `src/lib/marketingPortalController.ts` runs **in parallel**: - -1. **`submitToGoogle`** – POST to the configured **Google Apps Script** URL (`no-cors`) for Sheets automation (see [Marketing Portal](marketingPortal.md)). -2. **`submitToSupabase`** – inserts into **`marketing_requests`** with `created_by` set to the current user, then calls the Supabase Edge Function **`create-marketing-task`** with the session access token. - -Both paths must succeed for the handler to complete without throwing; see the controller for error handling and field mapping. +Today `handleMarketingSubmit` in `src/lib/marketingPortalController.ts` still uses the old flow: it posts to the Google Apps Script, inserts into **`marketing_requests`** and calls the Edge Function **`create-marketing-task`**. The insert is refused since `V20261026_0320`, so the portal is being rebuilt on the API. See [Marketing Portal](marketingPortal.md). ## Build, preview, deploy @@ -205,18 +208,19 @@ Run these from the repo root; they forward to `apps/web`. - **Develop:** `pnpm dev` (Vite default port, commonly `5173`). - **Production build:** `pnpm build` runs `tsc` then `vite build`, output in `apps/web/dist`. - **Preview:** `pnpm preview` serves the production build locally. -- **Vercel:** the project's Root Directory is `apps/web`; `apps/web/vercel.json` rewrites all routes to `index.html` for SPA hosting. +- **Hosting:** everything merged into `main` goes live on [dev.devsuoa.org](https://dev.devsuoa.org), served by **Firebase Hosting** (project `devs-dev-2027`, config in `firebase.json`). It serves `apps/web/dist`, sends every other path to `index.html`, and routes `/api/**` to the `devs-api` service on Cloud Run (`australia-southeast1`). ## Environment variables (summary) -| Variable | Used for | -| -------------------------- | ------------------------------ | -| `VITE_SUPABASE_URL` | Supabase project URL | -| `VITE_SUPABASE_ANON_KEY` | Supabase anon client key | -| `VITE_PUBLIC_POSTHOG_KEY` | PostHog project key (optional) | -| `VITE_PUBLIC_POSTHOG_HOST` | PostHog API host (optional) | +| Variable | Used for | +| -------------------------- | ------------------------------------------------------------------------------ | +| `VITE_API_URL` | API address; leave empty when `/api` is on the same site (dev proxy, Firebase) | +| `VITE_SUPABASE_URL` | Supabase project URL | +| `VITE_SUPABASE_ANON_KEY` | Supabase anon key (login only) | +| `VITE_PUBLIC_POSTHOG_KEY` | PostHog project key (optional) | +| `VITE_PUBLIC_POSTHOG_HOST` | PostHog API host (optional) | -Admin signup/login and any serverless pieces may require additional configuration in Supabase (Auth URLs, email templates, Edge Function secrets). Those settings are **not** stored in this repo. +The API has its own settings (database, Supabase, Stripe, Resend): see [the API README](../apps/api/README.md). Supabase Auth settings (redirect URLs, email templates) are set in the Supabase dashboard, not in this repo. ## Related KB entries @@ -227,10 +231,10 @@ Admin signup/login and any serverless pieces may require additional configuratio - [Events & RSVP](events_and_rsvp.md) - [Marketing Portal](marketingPortal.md) - [Feature Flags](feature_flags.md) +- [Database Migrations](database_migrations.md) - [Analytics](analytics.md) - [Commit & Branching Guidelines](commit_guidelines.md) ## Future enhancements - [ ] Auto-generate route tables from a single source of truth if the app grows further -- [ ] Document Supabase RLS policies and Edge Functions in a secure internal wiki if not open-sourced diff --git a/kb/setup.md b/kb/setup.md index 8be0e20..5c66982 100644 --- a/kb/setup.md +++ b/kb/setup.md @@ -1,6 +1,6 @@ # Project Setup -This project is a **React + TypeScript + Tailwind CSS** web application built using **Vite**. +This repo holds the DEVS website (**React + TypeScript + Tailwind CSS**, built with **Vite**) and the **Java API** it gets its data from. This document explains how to set up the project locally and get it running for development. ## Tech Stack @@ -35,8 +35,8 @@ git --version ### 1. Clone the Repository ```bash -git clone https://github.com/devsuoa/devsuoa-website.git -cd devsuoa-website +git clone https://github.com/devsuoa/devs-core.git +cd devs-core ``` ### 2. Install Dependencies @@ -66,10 +66,12 @@ apps/ src/ components/ Reusable UI components pages/ Page-level components - lib/ Data access and feature logic + lib/ API calls and feature logic main.tsx App entry point public/ Static assets .env Your local environment variables (ask an exec for the values) + api/ Java API (see apps/api/README.md) +db/ Database migrations kb/ Documentation (you are here) scripts/ Repo tooling ``` diff --git a/kb/sponsorForm.md b/kb/sponsorForm.md index 68f36ef..11aecf1 100644 --- a/kb/sponsorForm.md +++ b/kb/sponsorForm.md @@ -1,5 +1,7 @@ # Sponsor Form Component +> **Status (November 2026):** this feature is being rebuilt on the Java API. Its code still calls the Supabase Edge Function `send-email` directly, as described below. Whether that still works depends on the function still being deployed in Supabase; the rebuild moves it to `POST /api/contact`. The rebuilt version gets its data through `api()` in `apps/web/src/lib/api.ts`. + The **SponsorForm** is a **contact-style form** that emails **`contact@devsuoa.com`** via the **`sendEmail`** helper (Supabase Edge Function **`send-email`**). It supports two modes: **sponsorship inquiry** and **general contact**, selected with the **`formType`** prop. ## Purpose diff --git a/kb/task_tracker_components.md b/kb/task_tracker_components.md index 88c1e84..922cfb7 100644 --- a/kb/task_tracker_components.md +++ b/kb/task_tracker_components.md @@ -1,5 +1,7 @@ # Task Tracker UI Components +> **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`. + These components power **`/admin/tasks`** together with **`taskTrackerController`**. They share the **`Task`** and **`Comment`** types exported from **`TaskCard.tsx`**. ## Shared types (`TaskCard.tsx`)