Welcome to the official repository for the Skill-Sharing Community Platform project. This document provides all the necessary information to get the project set up, running, and to contribute effectively.
Follow these steps to get a local copy of the project running on your machine.
Navigate to your desired directory in your terminal and clone the repository from GitHub.
git clone https://github.com/Ashjani/Skill_Sharing_app.git
cd Skill_Sharing_appOnce inside the project directory, run the following command to install all the required Node.js packages listed in package.json.
npm installThis project uses a .env file to manage secret keys and configuration variables.
- Create a new file named
.envin the root of the project. - Copy the contents of the
.env.examplefile (or the block below) into your new.envfile. - Fill in the required values.
# .env.example
# -----------------
# The connection string for your local or cloud MongoDB instance
MONGO_URI=mongodb://localhost:27017/skillsharing
# The secret key for signing JSON Web Tokens (JWT)
# Use a long, random, and secure string
JWT_SECRET=your_super_secret_key_here
# The port the application server will run on
PORT=3000To run the application, you'll need two terminals running simultaneously: one for the MongoDB database and one for the Node.js server.
Open a new terminal and run the following command to start the MongoDB database. You must leave this terminal running.
mongodOpen a second terminal, navigate to the project's root directory, and run the following command to start the application server with nodemon, which will automatically restart on file changes.
npm run devOnce both servers are running, open your web browser and go to:
http://localhost:3000
This project includes a full suite of automated tests for the controllers and models. To run all tests, execute the following command from the project root:
npm testThis project follows the Model-View-Controller (MVC) architectural pattern to keep the code organized.
- π models: Contains all Mongoose schemas, which define the structure of our database documents.
- π views: Contains all EJS (
.ejs) template files, which are rendered to the user's browser. - π controllers: Contains the business logic of the application, handling requests and sending responses.
- π routes: Defines the URL endpoints and maps them to the appropriate controller functions.
- π public: Contains all static assets, such as CSS, client-side JavaScript, and images.
- π config: For configuration files, like the database connection setup.
- π tests: Contains all test files for the application (e.g., for controllers and models).
- π middleware: Contains custom middleware functions, such as for authentication and authorization.
- π assets: Contains documentation images, like the ERD.
The authentication system introduces two core pages, Login and Register, implemented using EJS for server-side rendering and styled with Materialize CSS.
- Login Page: Provides users with access to the platform by entering valid credentials. It features a responsive card layout (
views/auth/login.ejs) and client-side validation (public/js/validation.js). - Register Page: Allows new users to create an account. It uses a consistent responsive design (
views/auth/register.ejs) and includes client-side validation for email format and password strength.
This summary outlines the step-by-step process of how data moves through the application when a logged-in user creates a new review.
- API Request: A logged-in user submits a review on the frontend, which makes a
POSTrequest to the/api/reviewsroute. The request includes a JSON Web Token (JWT) in theAuthorizationheader and a body with theserviceId,rating, andcomment. - Authentication Middleware: The
protectmiddleware intercepts the request. It verifies the JWT to confirm the user is logged in and attaches the user's data to the request object (req.user). - Controller Logic: The request is passed to the
createReviewfunction in thereviewController. - Document Creation: The controller creates a new
Reviewdocument, populating it with data from the request body and assigning theuserfield based on the ID fromreq.user. - Database Insertion: The new
Reviewdocument is saved to thereviewscollection in MongoDB. - Update Relationships: Upon successful creation, the new review's
_idis pushed into thereviewsarray within the correspondingUserandServicedocuments to maintain the one-to-many relationships. - API Response: The server sends back a
201 Createdstatus code along with the created review object as a JSON response.
Weβve added full support for Accepting / Declining booking requests for service providers.
- Requesters can create a booking by selecting a service and submitting the booking form.
- Providers will now see Accept and Decline buttons next to pending bookings on the Bookings page.
- Once a provider takes action:
- The booking status is updated in the database (
AcceptedorDeclined). - The UI updates with a status badge.
- Toast notifications confirm the action.
- The booking status is updated in the database (
-
Updated
views/account/bookings.ejsto render Accept / Decline buttons when:- The logged-in user is the provider, and
- The booking is still
Pending.
-
Added client-side logic in
public/js/bookings.jsto:- Handle button clicks.
- Send POST requests to
/api/bookings/:id/acceptor/api/bookings/:id/decline. - Show toast notifications and refresh the booking list.
-
Added new routes to handle booking acceptance/decline:
POST /api/bookings/:id/acceptPOST /api/bookings/:id/decline
-
Only the provider of a booking can update its status.
- Requester books a service β Status:
Pending. - Provider logs in and sees request.
- Provider clicks:
- β
Accept β Booking moves to
Accepted. - β Decline β Booking moves to
Declined.
- β
Accept β Booking moves to
Our application's data is organized into several interconnected Mongoose models.
username: (String, Required, Unique)email: (String, Required, Unique)password: (String, Required, Hashed)credits: (Number, Default: 1)role: (String, Enum: ['Member', 'Admin'], Default: 'Member')
title: (String, Required)description: (String, Required)category: (String, Required)user: (ObjectID, Ref: 'User')status: (String, Enum: ['available', 'in_progress', 'completed'])ratings: (Array of embedded Rating documents)
rating: (Number, Required, Min: 1, Max: 5)comment: (String)user: (ObjectID, Ref: 'User', Required)service: (ObjectID, Ref: 'Service', Required)
service: (ObjectID, Ref: 'Service', Required)requester: (ObjectID, Ref: 'User', Required)provider: (ObjectID, Ref: 'User', Required)status: (String, Enum: ['Pending', 'Accepted', 'Completed'], Default: 'Pending')
participants: (Array of ObjectID, Ref: 'User')messages: (Array of embedded Message documents)
| Method | Path | Description | Access |
|---|---|---|---|
POST |
/auth/register |
Registers a new user. | Public |
POST |
/auth/login |
Authenticates a user and returns a token. | Public |
GET |
/api/services |
Retrieves a list of all services. | Public |
POST |
/api/services |
Creates a new service. | Private |
GET |
/api/services/:id |
Retrieves a single service by ID. | Public |
PUT |
/api/services/:id |
Updates a service. | Private (Owner/Admin) |
DELETE |
/api/services/:id |
Deletes a service. | Private (Owner/Admin) |
POST |
/api/reviews |
Creates a new review. | Private |
PUT |
/api/reviews/:id |
Updates a review. | Private (Owner) |
DELETE |
/api/reviews/:id |
Deletes a review. | Private (Owner) |
- Express.js: A fast and minimalist web framework for Node.js used to build our server and handle routing.
- Mongoose: An Object Data Modeling (ODM) library for MongoDB and Node.js used for schema validation and data management.
- Dotenv: Loads environment variables from a
.envfile, allowing us to keep secrets out of our code. - Mocha & Chai: Our testing framework and assertion library for writing automated tests.
- bcryptjs: A library for hashing passwords.
- jsonwebtoken: Used for creating and verifying JSON Web Tokens (JWTs) for authentication.
Step 1: Get the Latest Code & Create a Branch
git checkout develop
git pull
git checkout -b <branch-type>/<branch-name>Step 2: Code and Commit Your Work
Complete the work on your new branch, making small, regular commits.
Important: Before pushing, ensure all tests pass by running
npm test.
git add .
git commit -m "feat: implement user registration endpoint"Step 3: Push and Create a Pull Request (PR)
git push origin <branch-type>/<branch-name>Then, go to the GitHub repository to create a Pull Request (PR) from your new branch into the develop branch.
Step 4: Link Your PR and Get it Reviewed Copy the link to your new Pull Request and paste it into the comments of the corresponding Trello card. Request a review from at least one other team member.
Step 5: Merge and Close
Once your PR has been approved, merge it into the develop branch. After merging, move the Trello card to the "Done" column.
We follow a standard format for commit messages:
feat: A new featurefix: A bug fixdocs: Changes to documentationtest: Adding or refactoring testsrefactor: Code changes that neither fix a bug nor add a feature
- Problem: You run
mongodand get a "command not recognized" error. - Reason: MongoDB is installed, but its
bindirectory is not in your systemβs PATH variable. - Solution: Locate your MongoDB
bindirectory (like:C:\Program Files\MongoDB\Server\7.0\bin) and add it to your systemβs environment variables.
- Problem: You run
git pullon a new branch and see an error likeThere is no tracking information for the current branch. - Reason: This happens when your local branch doesn't know which branch to track on GitHub. It's a one-time setup for a new branch.
- Solution: The first time you push a new branch, use the
-uflag to set the upstream tracking link.
git push -u origin <branch-name>After running this once, you can use git pull and git push as normal.
On the Pull Request creation page, find the "Reviewers" section on the right-hand sidebar and click the gear icon βοΈ to select teammates to review your code.

