Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
58ab852
Add user and event lookup endpoints
rxmox Jan 26, 2026
e429cd1
Add authentication for get user data from userId and get events from …
lnqminh3003 Jan 26, 2026
d8e24bf
Merge branch 'STR-101-Create-User-Connections-between-Users' of https…
rodolfo-gp Jan 29, 2026
b23b1a8
Merge branch 'STR-101-Create-User-Connections-between-Users' of https…
rodolfo-gp Jan 29, 2026
9f64b44
Functionality
rodolfo-gp Jan 30, 2026
36109d1
Fixed Controller logic. No duplicate creation
rodolfo-gp Feb 6, 2026
e7442ab
Added get cconnections by email route
rodolfo-gp Feb 6, 2026
be17dca
Merge branch 'main' into STR-101-Create-User-Connections-between-Users
lnqminh3003 Feb 7, 2026
8730ab7
Update route for bingo game
lnqminh3003 Feb 7, 2026
93fbf76
Revert "Update route for bingo game"
lnqminh3003 Feb 8, 2026
c3c6fde
Merge branch 'main' into STR-101-Create-User-Connections-between-Users
lnqminh3003 Feb 17, 2026
07c68f5
Updating UserConnections to now be participant connenctions. Needs to…
rodolfo-gp Feb 23, 2026
4cc0ea6
(Update) Added Profile Updating Page, Needs Backend Update
keeryn04 Feb 25, 2026
a2a0850
(Fix) Login Failure Fix
keeryn04 Feb 25, 2026
5371270
(Update) Re-added Connections Functionality
keeryn04 Feb 25, 2026
5c633c6
(Update) Removed AuthUser, Fixed Signup
keeryn04 Feb 25, 2026
9093ad7
(Update) Better Error Handling
keeryn04 Feb 25, 2026
e41acf3
(Progress) Added Guest User Changes
keeryn04 Feb 25, 2026
e58e50a
(Progress) Guest w/ ID calls User Join, Not Guest Join
keeryn04 Feb 26, 2026
9f4fc27
(Update) Version Updates
keeryn04 Feb 26, 2026
88d6a17
(Fix) Join Event User Working
keeryn04 Feb 28, 2026
5c7a3b3
(Update) More Bingo Functionality
keeryn04 Feb 28, 2026
a3f26ff
(Progress) Event State Updates Correctly through Events Page
keeryn04 Feb 28, 2026
d1eb47d
(Progress) Game Status through Event Joining
keeryn04 Feb 28, 2026
9791aa6
add authMiddleware
lnqminh3003 Feb 28, 2026
65b8da9
Merge pull request #65 from techstartucalgary/STR-101-Create-User-Con…
lnqminh3003 Feb 28, 2026
38cdd89
Change route method and use query parameters
lnqminh3003 Feb 28, 2026
744e74a
Merge pull request #66 from techstartucalgary/STR-101-Create-User-Con…
lnqminh3003 Feb 28, 2026
a2d5d8a
Merge pull request #67 from techstartucalgary/backend
lnqminh3003 Feb 28, 2026
019dd8c
Fix guest join 409 error caused by duplicate email index
rxmox Mar 1, 2026
9eefba0
Add backend documentation suite for frontend/mobile integration
rxmox Mar 1, 2026
f4ed706
Add table of contents, endpoint summary table, and response format guide
rxmox Mar 1, 2026
c830dca
Merge pull request #68 from techstartucalgary/fix/guest-join-duplicat…
lnqminh3003 Mar 1, 2026
4f50e26
Add gameType, eventImg fields and status transition API to Event model
rxmox Mar 2, 2026
15b3630
Return 400 for Mongoose validation errors in createEvent
rxmox Mar 2, 2026
feebd7b
(Update) Added Connection Functionality, Needs Backend Update
keeryn04 Mar 4, 2026
be11fc2
(Update) Added Documentation for Mobile Flow
keeryn04 Mar 4, 2026
e9d6ca4
Merge pull request #69 from techstartucalgary/event-model-updates
lnqminh3003 Mar 4, 2026
065f1c8
Fetch connected user's info
lnqminh3003 Mar 5, 2026
62f5d01
(Progress) Connection Info Fetch
keeryn04 Mar 5, 2026
b19b17b
Sign up and log in styling
tahaminachy43 Mar 5, 2026
11e4f40
Merge pull request #71 from techstartucalgary/main
tahaminachy43 Mar 5, 2026
ef2c732
Merge branch 'mobile-signin-styling' into mobile-connections
tahaminachy43 Mar 5, 2026
022c0f9
(Progress) Added Basic Styling for Event Page, Tab Bar
keeryn04 Mar 6, 2026
f1433b3
Improve getConnectedUsersInfo endpoint and update docs
rxmox Mar 7, 2026
03bb315
Merge pull request #70 from techstartucalgary/get-connected-user's-in…
rxmox Mar 7, 2026
37375db
Merge pull request #73 from techstartucalgary/backend
rxmox Mar 7, 2026
6bf744f
(Update) Event Page, Game Page Styled
keeryn04 Mar 9, 2026
71b8c96
(Update) EventLobby Styling
keeryn04 Mar 10, 2026
ca425f0
(Progress) Created Page for End-of-Event, Needs Testing
keeryn04 Mar 10, 2026
9ab1cf2
(Update) Event Card Styling, EventCompleted Styling
keeryn04 Mar 10, 2026
21274af
(Update) Styling Updates
keeryn04 Mar 10, 2026
5ed6d7d
(Fix) Merge Conflicts
keeryn04 Mar 10, 2026
785557f
(Fix) More Merge Conflicts
keeryn04 Mar 10, 2026
4a4750d
Merge branch 'mobile-event-complete', remote-tracking branch 'origin'…
keeryn04 Mar 10, 2026
81ccadc
(Progress) Roller for Name Bingo, Need to Fix Styling
keeryn04 Mar 11, 2026
2aab605
(Update) Roller Styling Fixed, Working on Connections
keeryn04 Mar 11, 2026
ac47982
(Progress) Connections Being Made and Fetched, Needs Participant Info…
keeryn04 Mar 11, 2026
c7a41a2
(Progress) Fixed Connections Loading, Added Profile Photo Functionality
keeryn04 Mar 11, 2026
f9334ce
(Fix) Can't Enter Names in Completed Event
keeryn04 Mar 11, 2026
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
1,270 changes: 1,270 additions & 0 deletions shatter-backend/docs/API_REFERENCE.md

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions shatter-backend/docs/DATABASE_SCHEMA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# Shatter Backend — Database Schema Reference

**Last updated:** 2026-03-01
**Database:** MongoDB with Mongoose ODM
**Collections:** 6

---

## Table of Contents

- [Relationship Diagram](#relationship-diagram)
- [1. Users Collection](#1-users-collection)
- [2. Events Collection](#2-events-collection)
- [3. Participants Collection](#3-participants-collection)
- [4. Bingo Collection](#4-bingo-collection)
- [5. ParticipantConnection Collection](#5-participantconnection-collection)
- [6. AuthCode Collection](#6-authcode-collection)

---

## Relationship Diagram

```
┌──────────┐ ┌─────────────┐ ┌──────────┐
│ Users │◄──────│ Participant │──────►│ Events │
│ │ userId│ (junction) │eventId│ │
└──────────┘ └──────┬──────┘ └────┬─────┘
│ │ │
│ eventHistoryIds │ participantIds │
│ (refs Event) │ (refs Participant) │
│ │ │
│ ┌─────┴──────────┐ ┌────┴─────┐
│ │ Participant │ │ Bingo │
│ │ Connection │ │ │
│ └────────────────┘ └──────────┘
│ ┌────────────────┐
└──────────────│ AuthCode │
userId │ (TTL: 60s) │
└────────────────┘
```

- **User ↔ Event** is a many-to-many relationship via the **Participant** junction table
- Each **Event** can have one **Bingo** game
- **ParticipantConnection** links two participants within the same event
- **AuthCode** is a temporary, single-use token linking to a User (auto-deleted after 60s)

---

## 1. Users Collection

**Model name:** `User`
**Collection:** `users`
**Source:** `src/models/user_model.ts`

### Fields

| Field | Type | Required | Default | Notes |
|--------------------|-------------------|----------|------------|-------|
| `_id` | ObjectId | Auto | Auto | MongoDB default |
| `name` | String | Yes | — | Trimmed |
| `email` | String | No | — | Unique (sparse), lowercase, trimmed, regex-validated |
| `passwordHash` | String | No | — | `select: false` — excluded from queries by default |
| `linkedinId` | String | No | — | Unique (sparse) |
| `linkedinUrl` | String | No | — | Unique (sparse) |
| `bio` | String | No | — | Trimmed |
| `profilePhoto` | String | No | — | |
| `socialLinks` | Object | No | — | `{ linkedin?: String, github?: String, other?: String }` |
| `authProvider` | String (enum) | Yes | `'local'` | One of: `'local'`, `'linkedin'`, `'guest'` |
| `lastLogin` | Date | No | `null` | |
| `passwordChangedAt`| Date | No | `null` | |
| `eventHistoryIds` | [ObjectId] | No | `[]` | Refs `Event` |
| `createdAt` | Date | Auto | Auto | Mongoose timestamps |
| `updatedAt` | Date | Auto | Auto | Mongoose timestamps |

### Indexes

| Fields | Type | Notes |
|-------------------|----------------|-------|
| `email` | Unique, sparse | Allows multiple `null` values (guests) |
| `linkedinId` | Unique, sparse | |
| `linkedinUrl` | Unique, sparse | |

### Pre-Save Hooks

1. **Password requirement check:** If `authProvider` is `'local'` and `passwordHash` is missing, throws `"Password required for local authentication"`
2. **Password change tracking:** If `passwordHash` is modified on an existing document, auto-sets `passwordChangedAt` to current date

### Key Behaviors

- `passwordHash` is excluded from all queries by default. Use `.select('+passwordHash')` only when verifying passwords.
- Email uses a sparse unique index, allowing multiple users with `null` email (guest accounts).
- Guest users can upgrade to `local` auth by setting a password via the update endpoint.

---

## 2. Events Collection

**Model name:** `Event`
**Collection:** `events`
**Source:** `src/models/event_model.ts`

### Fields

| Field | Type | Required | Default | Notes |
|------------------|---------------|----------|--------------|-------|
| `_id` | ObjectId | Auto | Auto | |
| `name` | String | Yes | — | |
| `description` | String | Yes | — | |
| `joinCode` | String | Yes | — | Unique, auto-generated 8-digit number |
| `gameType` | String (enum) | Yes | — | One of: `'Name Bingo'` |
| `eventImg` | String | No | — | URL for event image |
| `startDate` | Date | Yes | — | |
| `endDate` | Date | Yes | — | Must be after `startDate` |
| `maxParticipant` | Number | Yes | — | |
| `participantIds` | [ObjectId] | No | `[]` | Refs `Participant` |
| `currentState` | String (enum) | Yes | `'Upcoming'` | One of: `'Upcoming'`, `'In Progress'`, `'Completed'` |
| `createdBy` | ObjectId | Yes | — | User who created the event (no ref set) |
| `createdAt` | Date | Auto | Auto | Mongoose timestamps |
| `updatedAt` | Date | Auto | Auto | Mongoose timestamps |

### Indexes

| Fields | Type | Notes |
|------------|--------|-------|
| `joinCode` | Unique | |

### Pre-Save Hooks

1. **Date validation:** If `endDate <= startDate`, throws `"endDate must be after startDate"`

---

## 3. Participants Collection

**Model name:** `Participant`
**Collection:** `participants`
**Source:** `src/models/participant_model.ts`

**Purpose:** Junction table linking Users to Events (many-to-many).

### Fields

| Field | Type | Required | Default | Notes |
|-----------|----------|----------|---------|-------|
| `_id` | ObjectId | Auto | Auto | |
| `userId` | ObjectId | No | `null` | Refs `User`. Nullable for legacy reasons |
| `name` | String | Yes | — | Display name in the event |
| `eventId` | ObjectId | Yes | — | Refs `Event` |

### Indexes

| Fields | Type | Notes |
|--------------------|--------|-------|
| `(eventId, name)` | Unique | Case-insensitive collation (`locale: "en", strength: 2`) |

### Key Behaviors

- The compound unique index on `(eventId, name)` is case-insensitive, so "John" and "john" are treated as the same name within an event.
- No timestamps are enabled on this model.

---

## 4. Bingo Collection

**Model name:** `Bingo`
**Collection:** `bingos`
**Source:** `src/models/bingo_model.ts`

### Fields

| Field | Type | Required | Default | Notes |
|---------------|------------|----------|---------|-------|
| `_id` | String | Auto | Auto | Custom: `bingo_<8 random chars>` |
| `_eventId` | ObjectId | Yes | — | Refs `Event` |
| `description` | String | No | — | |
| `grid` | [[String]] | No | — | 2D array of strings |

### Pre-Save Hooks

1. **ID generation:** If `_id` is not set, generates `bingo_` + 8 random alphanumeric characters

### Options

- `versionKey: false` — no `__v` field on documents

---

## 5. ParticipantConnection Collection

**Model name:** `ParticipantConnection`
**Collection:** `participantconnections`
**Source:** `src/models/participant_connection_model.ts`

### Fields

| Field | Type | Required | Default | Notes |
|--------------------------|----------|----------|---------|-------|
| `_id` | String | Auto | Auto | Custom: `participantConnection_<8 random chars>` |
| `_eventId` | ObjectId | Yes | — | Refs `Event` |
| `primaryParticipantId` | ObjectId | Yes | — | Refs `Participant` |
| `secondaryParticipantId` | ObjectId | Yes | — | Refs `Participant` |
| `description` | String | No | — | e.g., the bingo question they connected with |

### Pre-Save Hooks

1. **ID generation:** If `_id` is not set, generates `participantConnection_` + 8 random alphanumeric characters

### Options

- `versionKey: false` — no `__v` field on documents

### Key Behaviors

- Duplicate prevention is handled at the application level (controller checks for existing connection with same `_eventId` + `primaryParticipantId` + `secondaryParticipantId`), not via a database index.

---

## 6. AuthCode Collection

**Model name:** `AuthCode`
**Collection:** `authcodes`
**Source:** `src/models/auth_code_model.ts`

**Purpose:** Single-use authorization codes for the LinkedIn OAuth flow.

### Fields

| Field | Type | Required | Default | Notes |
|-------------|----------|----------|------------|-------|
| `_id` | ObjectId | Auto | Auto | |
| `code` | String | Yes | — | Unique, indexed |
| `userId` | ObjectId | Yes | — | Refs `User` |
| `createdAt` | Date | Auto | `Date.now` | TTL: auto-deleted after 60 seconds |

### Indexes

| Fields | Type | Notes |
|--------|--------|-------|
| `code` | Unique | Also has explicit index |

### Key Behaviors

- **TTL (Time-To-Live):** Documents are automatically deleted by MongoDB 60 seconds after `createdAt`. This ensures auth codes are short-lived.
- **Single-use:** The exchange endpoint uses `findOneAndDelete` to atomically consume the code.
- No timestamps option — uses manual `createdAt` for TTL.
Loading
Loading