Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a8f9349
Add dockerfile
LemonDrew Sep 14, 2025
e77d1df
Merge remote-tracking branch 'origin/dockerize-frontend' into dev/foo…
FooChao Sep 14, 2025
4fd1ddf
Add docker-compose.yml + set up local mongodb
FooChao Sep 14, 2025
4584e97
Rename .env to .env.sample
FooChao Sep 14, 2025
68e41a0
Update docker compose.yml with comments
FooChao Sep 14, 2025
5e3033f
Add debounced input component
FooChao Sep 15, 2025
0178678
Add AI Logging
FooChao Sep 15, 2025
38aa84f
Update time in AI logging
FooChao Sep 15, 2025
bf07c94
Update README.md with reference
FooChao Sep 15, 2025
c11a4d7
Merge branch 'copy-user-service' into add-user-service
FooChao Sep 15, 2025
205a177
Update ai/usage-log.md
FooChao Sep 15, 2025
b1a895c
Set up mongo db and update compose.yml
FooChao Sep 15, 2025
6c1f571
Update user-model.js with verified field
FooChao Sep 15, 2025
aeb55f3
Merge remote-tracking branch 'origin/setup-nginx-docker' into add-use…
FooChao Sep 15, 2025
92c88e5
Update docker compose to use api gateway
FooChao Sep 15, 2025
82f838a
Add npm start / run dev / install shortcuts on root repo
FooChao Sep 15, 2025
56c030e
Improve styling for sign up page
FooChao Sep 15, 2025
5e589f4
Merge remote-tracking branch 'origin/master' into add-user-service
FooChao Sep 15, 2025
18945ad
Synchronise sign up component state
FooChao Sep 15, 2025
4bc013e
Enforce Strong Password using regex
FooChao Sep 15, 2025
2e2b4e3
Improve UX
FooChao Sep 15, 2025
0f01282
Add regions for better readability
FooChao Sep 15, 2025
17bbd94
Use API for signing in and add toast
FooChao Sep 15, 2025
060f99c
Fix middleware at wrong location
FooChao Sep 15, 2025
60a1ce3
Remove unnecessary console.log
FooChao Sep 15, 2025
3d43b24
Move errorHandlers file location
FooChao Sep 15, 2025
5edd94b
Add cookies handler
FooChao Sep 15, 2025
50ff755
Track state in log in component
FooChao Sep 15, 2025
f93c936
Use router for changin page without a reload
FooChao Sep 15, 2025
5909371
Add ability to login
FooChao Sep 15, 2025
e9d7af4
Update AI usuage with correct claude model
FooChao Sep 15, 2025
aace294
Update AI dislosure
FooChao Sep 15, 2025
233363b
Add navbar and userContext to store username and email
FooChao Sep 15, 2025
36c58fc
Update navbar styling
FooChao Sep 15, 2025
3b776b4
Fix bug where context is not updated correctly after logging in
FooChao Sep 15, 2025
584d7f7
Cleqar toast after successful redirecting
FooChao Sep 15, 2025
18ca3e3
Resolve Docker networking issue for middleware token verification
FooChao Sep 15, 2025
e771f39
Merge remote-tracking branch 'origin/master' into add-user-service
FooChao Sep 15, 2025
3d89164
Run auto format fix in frontend
FooChao Sep 15, 2025
d1a575e
Add email regex validation and remove leading/trailing space for emai…
FooChao Sep 16, 2025
4e9157c
Give more specific error message when it is either username or email …
FooChao Sep 16, 2025
c83a000
Run style auto fix
FooChao Sep 16, 2025
c23d1bd
Run npm audit fix
FooChao Sep 16, 2025
b9b1389
Add auth-guard to prevent user from unauthorised back-tracking after …
FooChao Sep 16, 2025
64e4aec
Run format fix
FooChao Sep 16, 2025
004c415
Fix bug where navigation by other means cause the navbar to not get u…
FooChao Sep 17, 2025
425c407
Merge remote-tracking branch 'origin/master' into add-user-service
FooChao Sep 17, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/.env
**/node_modules
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/QUdQy4ix)
# CS3219 Project (PeerPrep) - AY2526S1
## Group: Gxx
## Group: G01

### Note:
- You are required to develop individual microservices within separate folders within this repository.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.

### References:
- https://github.com/CS3219-AY2526Sem1/PeerPrep-UserService
338 changes: 338 additions & 0 deletions ai/usage-log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
# AI Usage Log

## Entry 1

# Date/Time:
2025-09-15 12:00

# Tool:
ChatGPT (model: ChatGPT-4.1)

# Prompt/Command:
Request to implement a reusable debounced input component in React with TypeScript support, extending shadcn/ui Input component with custom debouncing functionality.

# Output Summary:
- Complete React component with TypeScript interfaces
- Custom useDebouncedValue hook implementation
- DebouncedInput component with forwardRef support
- Proper prop extension from React.ComponentProps<"input">
- Integration with shadcn/ui Input component
- Debounce functionality with configurable delay (default 300ms)
- Support for controlled/uncontrolled input patterns

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated correctness of debouncing logic and React hooks usage
- Confirmed security implications are minimal (client-side UI component)
- Tested performance with different debounce delays

---

## Entry 2

# Date/Time:
2025-09-15 15:20

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
"set up docker file for my express app" - Request to create Dockerfile and .dockerignore for Node.js Express user-service application

# Output Summary:
- Multi-stage Dockerfile with deps, builder, and runner stages
- Production-optimized configuration with Alpine Linux base
- Security features: non-root user (expressjs:nodejs), production dependencies only
- Performance optimizations: layer caching, small image size
- Health check endpoint configuration
- Comprehensive .dockerignore file excluding unnecessary files
- Proper file copying and permissions setup

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Reviewed multi-stage build structure for optimization
- Verified security configurations (non-root user, Alpine base)
- Confirmed port 3001 matches application configuration
- Validated .dockerignore excludes sensitive files (.env, node_modules)
- Health check endpoint may need implementation in Express app
- Docker setup follows best practices for Node.js applications

---

## Entry 3

# Date/Time:
2025-09-15 17:30

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
"Create a root package.json with concurrently scripts for concurrent development workflow" - Request to set up npm scripts for running both frontend and user-service simultaneously during development

# Output Summary:
- Root-level package.json configuration for monorepo-style development
- Concurrently package integration for parallel script execution
- Development scripts: dev, dev:frontend, dev:user-service
- Production scripts: start, start:frontend, start:user-service
- Build scripts: build, build:frontend, build:user-service
- Utility scripts: install:all, clean
- Proper cross-platform script configuration for Windows/Unix compatibility

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated script paths and directory navigation (cd commands)
- Confirmed concurrently package version (^8.2.2) is current
- Tested npm run dev workflow for concurrent frontend/backend startup
- Scripts support both development and production deployment scenarios
- Clean script properly removes node_modules from all service directories
- install:all script ensures all dependencies are installed across services
- Improves developer experience with single command for multi-service development

---

## Entry 4

# Date/Time:
2025-09-15 18:45

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Request to implement toast notifications for signup form validation with top-center positioning and custom styling, replacing disabled button with specific error feedback.

# Output Summary:
- Sonner toast library integration in Next.js layout.tsx
- Custom toast positioning (top-center) with enhanced visual styling
- Password complexity validation with detailed toast feedback
- Custom CSS styling with backdrop blur, hover effects, and type-specific border colors
- Toast configuration with rich colors, close button, and 4-second duration
- Individual validation checks replacing single disabled button state

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated toast notification UX improves over disabled button approach
- Confirmed Sonner library is modern and well-maintained for React/Next.js
- Reviewed custom CSS for accessibility and visual consistency
- Tested toast positioning and timing for optimal user experience
- Security implications minimal (client-side UI feedback only)
- Enhanced user experience with specific, actionable error messages

---

## Entry 5

# Date/Time:
2025-09-15 19:15

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Request to implement comprehensive signup form improvements including controlled inputs, debounced password validation, password complexity requirements with visual indicators, and enhanced UX patterns.

# Output Summary:
- Converted all form inputs to controlled React components with proper state management
- Implemented DebouncedInput component for confirm password field with 300ms delay
- Added password complexity validation using regex patterns (length, uppercase, lowercase, number, special characters)
- Dynamic password requirements display with focus/blur states and visual indicators (Check/X icons)
- Password visibility toggle buttons for both password fields
- Real-time password match validation with error messaging
- Enhanced form validation logic with proper state synchronization
- Improved accessibility with proper labeling and error states

# Action Taken:
- [ ] Accepted as-is
- [x] Modified
- [ ] Rejected

# Author Notes:
- Validated all form state management follows React best practices
- Confirmed password regex patterns meet common security requirements
- Tested debounced validation prevents excessive API calls or state updates
- Reviewed accessibility features for screen readers and keyboard navigation
- Performance optimized with proper useCallback and state dependencies
- UX improvements provide clear visual feedback for password requirements
- Security considerations: client-side validation only, server validation still required

---

## Entry 6

# Date/Time:
2025-09-15 20:30

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Request to create reusable error handling utilities for consistent API error management and user feedback across the application.

# Output Summary:
- Created comprehensive error handling utility (/utils/errorHandler.ts)
- Implemented extractErrorInfo function for normalizing different error types
- Added handleApiError function with smart error detection and toast notifications
- Created handleApiSuccess function for consistent success feedback
- Added withErrorHandling and withLoadingAndErrorHandling wrapper functions
- Integrated TypeScript interfaces for error responses
- Implemented status-specific error titles (Conflict, Validation Error, etc.)
- Added automatic toast management with loading state handling
- Updated SignUpComponent to use new error handling utilities

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated error handling covers all HTTP status codes and network scenarios
- Confirmed TypeScript type safety for all error and response scenarios
- Reviewed reusable utility functions for DRY principle adherence
- Performance considerations: automatic loading toast dismissal prevents UI conflicts
- Security implications minimal: client-side error handling only
- UX improvements: consistent error messaging and user feedback across application
- Maintainability: centralized error handling logic for easy updates

---

## Entry 7

# Date/Time:
2025-09-15 21:15

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Request to implement simple cookie utilities for JWT token storage and removal, ensuring compatibility with Next.js middleware authentication.

# Output Summary:
- Created minimal cookie management utilities (/services/userServiceCookies.ts)
- Implemented addToken function for setting JWT token in browser cookies
- Implemented removeToken function for clearing authentication cookies on logout


# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated cookie naming convention matches middleware token reading logic
- Confirmed simplicity over complexity for basic token storage requirements
- Maintainability: simple two-function API for easy integration across application

---

## Entry 8

# Date/Time:
2025-09-16 00:05

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Request to implement UserContext for managing user authentication state and create a global navigation bar that appears on all non-auth pages with conditional rendering.

# Output Summary:
- Created React UserContext (/contexts/UserContext.tsx) for centralized user state management
- Implemented automatic token verification using verifyToken API
- Added user data persistence across page refreshes with token-based restoration
- Created Navbar component (/app/components/layout/Navbar.tsx) with PeerPrep branding and navigation
- Implemented NavbarWrapper (/app/components/layout/NavbarWrapper.tsx) for conditional rendering
- Updated root layout.tsx to include UserProvider and NavbarWrapper
- Enhanced LoginComponent to set user data in context after successful authentication
- Updated WelcomeComponent to display actual username from UserContext instead of hardcoded name
- Fixed cookie utilities with getToken function for token retrieval

# Action Taken:
- [ ] Accepted as-is
- [x] Modified
- [ ] Rejected

# Author Notes:
- Validated UserContext properly handles token verification through API calls rather than JWT parsing
- Confirmed conditional navbar rendering excludes auth pages (/auth/*) as required
- Reviewed user state persistence across page refreshes and browser sessions
- Tested integration between LoginComponent, UserContext, and display components
- Security considerations: Token verification through backend API ensures data integrity
- UX improvements: Consistent navigation experience with user-aware display elements
- Maintainability: Centralized user state management with clear separation of concerns
- Debug logging enables easier troubleshooting of authentication state issues
- Navbar modified by me after AI implementation to meet specific design requirements

---

## Entry 9

# Date/Time:
2025-09-16 16:00

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Configure Nginx reverse proxy for PeerPrep frontend and user service with proper routing, CORS handling, and Next.js client-side navigation support.

# Output Summary:
- Configured Nginx API gateway for frontend and user service routing
- Fixed Docker networking issues for login redirects
- Enhanced API configuration for server-side vs client-side calls

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated correctness, security, and performance of the configuration

---

## Entry 10

# Date/Time:
2025-09-16 16:30

# Tool:
GitHub Copilot (model: Claude Sonnet 4)

# Prompt/Command:
Fix Docker networking bug where middleware (server-side) and browser (client-side) need different API endpoints for same service.

# Output Summary:
- Added dynamic axios client creation to handle different execution contexts
- Implemented separate URLs for server-side (http://user-service:4000) and client-side (http://localhost/api) calls
- Fixed middleware token verification failing due to incorrect API endpoint routing
- Added comprehensive documentation explaining the Docker networking solution

# Action Taken:
- [x] Accepted as-is
- [ ] Modified
- [ ] Rejected

# Author Notes:
- Validated dynamic client creation approach fixes Docker container-to-container communication issues
- Confirmed solution maintains proper API gateway routing for browser requests

---


Loading