Skip to content

Commit 2611d6e

Browse files
Merge pull request #295 from HackYourFuture-CPH/backedn-mid-specialism-projects-improvements-from-feedback
Clarify events backend project scope and cart design expectations
2 parents 7a261d7 + a722044 commit 2611d6e

2 files changed

Lines changed: 62 additions & 8 deletions

File tree

courses/backend/events-startup-project/requirements.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ These requirements describe the overall functionality of the app. Some of these
2222
- [x] 3.1 Users can add tickets to their shopping cart
2323
- [ ] 3.2 Users can select ticket quantity when adding to cart
2424
- [ ] 3.3 Items can be added, updated, or removed while in the cart
25-
- [ ] 3.4 Cart is saved across the session (and beyond the session, if authenticated)
25+
- [ ] 3.4 Cart is persisted in the backend for both authenticated and unauthenticated users
2626

2727
### 4. Checkout
2828

@@ -62,3 +62,41 @@ You should use the technologies, skills, tools, and stack you've learned through
6262
### API
6363

6464
We already have a very basic API in place, but it is missing many features that you will be required to implement. You can find the current API in the project template.
65+
66+
- [ ] API routes must be documented with Swagger / OpenAPI
67+
- [ ] A Postman collection must be included for the implemented API
68+
69+
## Implementation Clarifications
70+
71+
These clarifications define the minimum expectations for this project. They are intended to remove ambiguity while still leaving room for implementation choices.
72+
73+
### Naming Guidance
74+
75+
- Because the program often prefers singular table names, avoid reserved SQL words by using more specific names where needed.
76+
- For example, prefer names such as:
77+
- `app_user` instead of `user`
78+
- `customer_order` instead of `order`
79+
- If you choose plural naming in your own schema, that is also acceptable as long as the schema is consistent and clear.
80+
81+
### Minimum API Expectations
82+
83+
- The public listing route should be `GET /api/events`.
84+
- Search should be implemented through query parameters on the listing route, for example `GET /api/events?q=music&page=1&pageSize=20`.
85+
- A separate `/search` route is not required.
86+
- `PUT /api/cart/items/{itemId}` and `DELETE /api/cart/items/{itemId}` should identify a specific cart line, not the event itself.
87+
- In the default project route design, `{itemId}` is a single cart line identifier.
88+
- If a trainee intentionally chooses a composite-key cart-line design, the route shape should be adjusted accordingly and documented clearly.
89+
- The cart line should store a reference to the related event.
90+
91+
### Cart and Checkout Simplifications
92+
93+
- The cart is backend-persisted in all cases.
94+
- A cart may belong either to an authenticated user or to an unauthenticated user.
95+
- A simple schema approach is to allow `cart.user_id` to be nullable until the cart is associated with a logged-in user.
96+
- The project should enforce the rule that each authenticated user has at most one active cart.
97+
- A database-level approach such as a unique constraint or partial unique index is recommended where supported by the chosen schema design.
98+
- Trainees are not required to implement advanced race-condition handling beyond a reasonable database-backed solution for this course project.
99+
- Ticket inventory is intentionally treated as unlimited in this backend project.
100+
- Because inventory is unlimited, stock validation and overselling prevention are not required.
101+
- During checkout, the minimum required atomic behavior is converting the active cart into an order and preventing further modification of that finalized order.
102+
- Price snapshotting into the order data is recommended, but the exact checkout internals may be kept simple unless the implementation defines stricter business rules.

courses/backend/events-startup-project/weekly-plan.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Weekly Plan
22

33
This document outlines the expected weekly progress and milestones for completing the backend project.
4-
The structure aligns with the Product Requirements Document (PRD), Shared API Contract, and Technical Specification.
4+
The structure aligns with the Requirements document and the minimum API expectations documented in this project folder.
55

6-
The goal is to progressively implement a fully functional, contract-compliant API with proper documentation, testing, and deployment.
6+
The goal is to progressively implement a fully functional backend API with proper documentation, testing, and deployment.
77

88
---
99

@@ -19,10 +19,12 @@ Design and implement the foundational database schema for users and catalog enti
1919
- [ ] Design ERD (v1) including:
2020
- `user`
2121
- `{domain}_item` (e.g. `event`)
22+
- [ ] Naming hint: if you use singular table names, avoid reserved SQL words by choosing clearer names such as `app_user` instead of `user`
2223
- [ ] Implement PostgreSQL schema with:
2324
- Primary keys
2425
- Foreign keys (where applicable)
2526
- Proper constraints
27+
- [ ] Start planning which relationships are required and which foreign keys may need to be optional, for example a cart that can exist before it is bound to a user
2628
- [ ] Add seed data for:
2729
- At least 1 test user
2830
- Multiple catalog items
@@ -53,14 +55,22 @@ Finalize database structure to support cart, checkout, and order flows.
5355
- `cart_item`
5456
- `order`
5557
- `order_item`
58+
- [ ] Continue to avoid reserved SQL words in the schema, for example by using names such as `customer_order` instead of `order`
5659
- [ ] Implement all foreign key relationships
57-
- [ ] Enforce “one active cart per user” rule
60+
- [ ] Design the cart so it can be persisted for both authenticated and unauthenticated users
61+
- [ ] Decide which foreign keys and columns are required versus optional, for example whether `cart.user_id` is nullable until a cart is attached to an authenticated user
62+
- [ ] Enforce “one active cart per authenticated user” rule
63+
- [ ] Choose a cart-line key strategy:
64+
- Project default: a simple single primary key such as `cartLineId`
65+
- Alternative design: a composite key such as (`cartId`, `lineNo`)
66+
- [ ] Design note: if you choose the alternative composite-key design, make sure your later endpoint design reflects it clearly
5867
- [ ] Implement SQL queries for:
5968
- Paginated item listing (`LIMIT`, sorting)
6069
- Cart subtotal calculation
6170
- Order totals snapshot logic
6271
- [ ] Update ERD (v2)
6372
- [ ] Add seed updates if needed
73+
- [ ] Decide how the schema enforces one active cart per authenticated user
6474

6575
### Week 2 Outcome
6676

@@ -81,9 +91,9 @@ Expose public catalog endpoints and implement initial API documentation.
8191
- [ ] Set up Express application structure
8292
- [ ] Connect application to PostgreSQL
8393
- [ ] Implement public endpoints:
84-
- `GET /api/{domain}` (paginated)
85-
- `GET /api/{domain}/search`
86-
- `GET /api/{domain}/{id}`
94+
- `GET /api/events` (paginated)
95+
- `GET /api/events/{id}`
96+
- [ ] Support search through query parameters on `GET /api/events` (for example `?q=music&page=1&pageSize=20`)
8797
- [ ] Implement pagination response format:
8898

8999
```json
@@ -129,6 +139,10 @@ Implement authentication and protected cart functionality.
129139
- `GET /api/cart`
130140
- `POST /api/cart/items`
131141
- `PUT /api/cart/items/{itemId}`
142+
- [ ] Treat `{itemId}` as the cart line identifier, not the catalog item identifier
143+
- [ ] Project default: use the simple cart-line design with a single cart line id in routes such as `PUT /api/cart/items/{itemId}`
144+
- [ ] Design note: if you intentionally choose the composite-key alternative from Week 2, your routes would typically become more explicit, for example `/api/carts/{cartId}/lines/{lineNo}`
145+
- [ ] Support cart behavior for both guest and authenticated users using the backend-persisted cart model chosen in Week 2
132146
- [ ] Validate request payloads
133147
- [ ] Ensure consistent error responses
134148
- [ ] Update Swagger documentation
@@ -154,13 +168,15 @@ Complete private API, implement checkout transaction, and deploy.
154168
- [ ] Implement remaining cart endpoints:
155169
- `DELETE /api/cart/items/{itemId}`
156170
- `POST /api/cart/checkout` (transactional)
171+
- [ ] Keep route design consistent with your cart-line key choice from Week 2
157172
- [ ] Implement order endpoints:
158173
- `GET /api/orders`
159174
- `GET /api/orders/{orderId}`
160175
- [ ] Implement database transaction for:
161176
- Converting active cart → order
162177
- Creating order items
163178
- Clearing/replacing active cart
179+
- [ ] Keep checkout logic simple: inventory is treated as unlimited for this project
164180
- [ ] Finalize error handling across all routes
165181
- [ ] Complete Swagger documentation
166182
- [ ] Finalize Postman collection
@@ -171,7 +187,7 @@ Complete private API, implement checkout transaction, and deploy.
171187

172188
### Week 5 Outcome
173189

174-
- Fully functional contract-compliant backend
190+
- Fully functional backend covering the minimum required project scope
175191
- Checkout flow transactional and stable
176192
- Orders history available
177193
- Swagger/OpenAPI docs accurately reflect the implemented API

0 commit comments

Comments
 (0)