Group Project for CSCI3100 2024-25 Sem 2 at CUHK
- Zhang Ka Sing - Frontend
- Peng Minqi - Frontend
- Li Chun Leung - Backend
- Zeng Bai Chuan - Backend
- Wong Kwok Kam - Backend
Welcome to chat on our websites: https://buzz-net-tau.vercel.app/
For the Usage Guide, please check: https://github.com/NokkTsang/BuzzNet
This project uses VS Code's Remote Development extension for a consistent development environment:
- Install VS Code and the Remote Development extension pack
- Clone this repository via HTTPS
- Open the repository in VS Code
- When prompted, click "Reopen in Container" or run the "Remote-Containers: Reopen in Container" command
- cd
BuzzNetand runnpm installto install the dependencies - Run
cd frontend && npm run devto run the frontend locally - Run
cd backend && npm run devto run the backend locally
-
JWT Token Expiration Handling: Set the expiration time for JWT tokens to 3 hour to prevent rapid invalidation of JWT token, provide better user experience.
-
Modify env file for JWT_SECRET variable.
- Comment Management:
- Implemented comment deletion functionality
- Added comment author and admin deletion permission verification
- Added comment delete button and confirmation prompt in frontend
- Implemented comment deletion API endpoint in backend
- Profile Page Improvements:
- Fixed profile page data fetching from backend
- Added proper user information display
- Implemented loading and error states
- Admin Mode Implementation:
- Added admin role verification middleware
- Implemented admin-specific post deletion permission
- Added admin mode visual indicator in header
- Login/Register Form Improvements:
- Added specific password requirements message
- Added two times repeated password validation
- Added password strength indicator
- Account lockout after multiple failed attempts
- Update password set-up policy:
- at least one upper case, one lower case and one number
- minimum length 8 characters
- Update Comment Post function:
- add addCommentToPost(), likeComment(), dislikeComment() functions in postController.js
- update commentSchema in Post.js
- update postRoutes.js due to new functions
- update PostDetail.jsx to handle comment
- show no. of comments
- show time of comments
- Modify frontend/src/pages/PostDetail.jsx when deplying
- Implement likes and dislikes methods: User can like or dislike posts. Clicking like on a disliked post will remove the dislike and add a like; otherwise, it will remove the like and add a dislikes. The like/dislike count is displayed next to the repective buttons.
- Implement post read more/show less: Clicking "Read more" expands the content to full length; Clicking "Show less" collapses the content to truncated view.
- Implement post detail page: clicking post will redirect to a post detail page; post content display; navigation feature, containing Back button; interaction features: like/dislike posts and comments; some changes on comment system: comment list, comment interactions.
- collarborate with David to fix some bugs in likes and dislikes
- some frontend view bugs, like zoom rate and feed view: Improve the adaptability of web pages to front-end display functions at different zoom rates; Improve the frontend performance the webpages.
- Fixed the bug that logged in user cannot like/unlike a post
- Use optimistic like for a post. (Local change not necesasrily reflect the server state)
- Removed redundant code in the frontend
- Store user_id in local storage for later use
-
Bug Fixes:
- Fixed the issue where usernames were not displaying correctly in posts
- Fixed the post deletion functionality
- Implemented post deletion restriction (only post authors can delete their own posts)
-
UI Improvements:
- Optimized frontend page layout and design
- Added a basic profile page for users (Access by clicking on your username in the header)
- Enhanced overall user experience
- Instructions on how to run the project locally
- Modified the Post Model to embed comments and display comment count.
- Modified the User Model to include role field.
- Modified the authMiddleware to provide more detailed error messages.
- Fixed 'cannot create post' bug, now you can create a post if you are signed in.
- Focus on geting all posts and creating posts only. Modified the routes and controllers to focus on these two functionalities.
- Added a TODO:
- Display username instead of user ID in the posts.
- Fixed the bug which for unsuccessful sign-in of account.
- Limit the time of like/dislike of the post to one.
- Limit the deletion function of post to author and admin only.
I've implemented a complete user authentication system and merged it with the existing codebase. Here's what I've added:
- Frontend Changes:
- Added Login component with form validation
- Implemented user authentication state management
- Added user interface elements (username display, logout button)
- UI with responsive design
- Backend Changes:
- Added user authentication routes (/api/users/register and /api/users/login)
- Implemented JWT-based authentication
- Added user model and controllers
- Security Features:
- Implemented password hashing
- Added JWT token validation
I've fixed a problem when connecting to MongoDB in local development.
Features added / modified:
-
User model
-
Post controller to incorporate user model
-
Error function for easier error handling in backend
-
Fixed code duplication in backend/api/index.js, migrate the logic to backend/index.js -> need to be tested by re-deployment
-
Added .env.example, removed committed .env and .env.production for security reasons.
I've made comprehensive changes to implement the unlike functionality and comment feature:
- Updated the Post component to:
- Add an unlike button
- Add a comment section with a toggle
- Display comment count
- Handle comment submission
- Created a new CommentForm component that:
- Provides a textarea for comment input
- Handles form submission
- Shows error messages
- Disables functionality when offline
- Updated the PostsContext to:
- Add unlike functionality
- Add comment management
- Handle offline mode for comments
- Update the UI state accordingly
- Added new CSS styles for:
- Unlike button
- Comment section
- Comment form
- Individual comments
- Action buttons
The new features include:
- Unlike button next to the like button
- Comment count display
- Expandable comment section
- Comment form with validation
- Styled comment list
- Offline support for all new features
I've implemented a simple but comprehensive set of functions for both frontend and backend. Here's what I've created:
-
Backend: MongoDB Post Model: Created a schema for posts with fields for title, content, author, likes, and creation date. Database Connection: Set up a MongoDB connection configuration with error handling. Post Controller: Implemented controller functions for CRUD operations (Create, Read, Update, Delete) and a like function. Routes: Created API routes for posts with appropriate HTTP methods. Express Server: Updated the main server file to use routes and DB connection. Deployed on Vercel https://vercel.com/nokktsangs-projects/buzz-net-backend
-
Frontend: Post List Component: Fetches and displays posts from the API. Post Item Component: Displays individual posts with formatted date, expandable content, and like functionality. Post Form Component: Allows users to create new posts with validation. Main App Component: Integrates all components with a clean layout and refresh functionality. Real-time refreshing of the webpage CSS Styling: Added comprehensive styling for a modern, responsive UI. Deployed on Vercel https://vercel.com/nokktsangs-projects/buzz-net-frontend
-
Database: Collections: posts Deployed on MongoDB https://cloud.mongodb.com/v2/67fc861383cfad4a0275d512#/overview
-
To use this application locally: Start the backend server: cd BuzzNet/backend && npm run dev Start the frontend development server: cd BuzzNet/frontend && npm run dev
-
Check out the prototype on: https://buzz-net-tau.vercel.app/ and https://github.com/NokkTsang/BuzzNet
Adding more details:
- Encryption
- Rate Limit
- Internationalization
- Provide reason on choosing MongoDB
Communication between frontend and backend: RESTful API Information
Consider removing some part due to tiem limit
Added Developer's Role
Removed ssh mount, change to https instead (easier set up)
