Try   HackMD

Project Challenge: MongoDB and Express

CoderManagement

CoderManagement is a platform that helps individuals and teams manage their tasks.
These are more than just simple to-do lists. Task management tools allow teams to collaborate digitally by organizing, prioritizing, and assigning tasks to each other.

So what exactly does task management software do? As with most software, there is a range of complexity and technological advancement among different systems. With that being said, typical features include:
  1. Task scheduling to set deadlines in advance.
  2. Task customization and editing to update for specific situations.
  3. Task assignment, which may include internal coworkers, external partners, or both.
  4. Notifications/Alerts to remind users about upcoming tasks and responsibilities.
  5. Recurring tasks or templates to standardize repetitive steps in your workflow.
  6. Sub-tasks or parent tasks to create additional steps within a task.
  7. Time Tracking to record the amount of time spent on tasks.
  8. Progress reporting to track current positioning in regards to the overall goal.
  9. Task organization using tags to prioritize the tasks.
  10. To-do lists for easy task visualization.

That's a lot! The actual task management system is quite large for us at the moment. But we can utilize our knowledge to achieve a few features from it. To be specific, let's implement the 1, 3, 7, 9, and 10 features in our app.

Overview

You're the CEO of a small tech start-up company.
After a while, you realize that you need a system that can keep track of the tasks and improve productivity.
As this is just an internal mini-project of the company, your goal is also to keep the cost low.
Remembered your amazing time at CoderSchool learning how to code, you roll up your sleeve and start up your Visual Studio Code.

As a wise programmer, you started off planning for an MVP (Minimum Viable Product). For the first phase of this product:

Entity relationship diagram

You came up with this design

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Features

You have decided for this first phase of the application that:

  • You are the only manager who assign task
  • Your team members are employee
  • Your team members could sign up for an account with their name and become employee by default
  • You will create, assign and delete tasks to other users
  • A user may have one, many, or no task he/she responsible for.
  • A task may have one or no one asign to it yet
  • Right now you are the only user of this project, so no authentication needed

Description

Everyone who uses the app is a user. there are 2 roles for user: employee and manager
You are the user that have higher authority in the company ( later could be other managers).
This hierarchy of roles allows us to limit access to certain features in the application that only the manager has permission.

However, at this stage, you just want to warm up your coding skill and make the most straightforward version as fast as possible.

End points requirements

For now, your account will be created through compass with the role: manager

From a client app, you could test these routes to:

  1. Create a new user by user's name. default role is employee

  2. Browse for all your employee with filter

  3. Search for an employee by name

  4. Browse your tasks with filter allowance ( status, createdAt,updatedAt,). The following attribute is required to help category tasks by tag and status, also sorting bycreatedAt,updatedAt

    • status
    • createdAt,updatedAt
    • description
  5. Get a detailed description of a single task by id.

  6. You could search all tasks of 1 member either by name or id

  7. You could assign member to a task or unassign them

  8. You could create a task with the required information.

  9. You could update the status of a task.

  10. There are some rules for updating task status :

    • When the status is set done, it can't be changed to other value except archive
    • Soft delete a task, by changing isDeleted to true
  11. Research and Apply: In backend development, input validation is an important step. This time, you are required to research on express-validator and apply further control API request input.

    • Create user request must check body for : existence, include name , name's value is a valid string.
    • Create task request must check body for : existence, and other requirements per task schema.
    • All routes that required _id , must be check for its : existence, is a mongo object id.

Schema hint

In the real world, schema design is often the responsibility of senior devs. However, it is an important skill for a new developer to obtain and build gradually.

Don't worry. We will help you out a bit.

As you already identified the problem above, the next step is to critically think about Schema - how and what data we want to record in our database.

You will need 2 Schemas: User and Task.

User Schema:

  • User is created by name, so there must be a name field in user schema. This is mandatory (required)
  • User has two roles: manager and employee => a role field in User with String type and we need enum validator for its value. more

The enum validator is an array that will check if the value given is an item in the array. If the value is not in the array, Mongoose will throw an error.

Task Schema:

  • A task should contain the field name and description for the basic information. Can a task have no name and no description? For now, let's say make them mandatory too.

  • The task status is tricky. Let's say you have decided there are 5 types of the status field: pending, working, review, done, archive.

    • pending: work not started
    • working: is working on it
    • review: waiting for review result
    • done : review is finished with satisfaction
    • archive: package as references for future
  • Key note from requirements

    • A user may have one, many, or no task he/she responsible for.
    • A task may have one or no one asign to it yet

Project planning tip

Plan your routes

Instead of jumping right into making routes, we should plan for it by writing pseudo code. It would be helpful to have the big picture at the beginning.

User

  • Get all user
/** * @route GET API/users * @description Get a list of users * @access private */
  • Get a single user by Id
/** * @route GET api/users/:id * @description Get user by id * @access public */
  • Create a new user (assigner)
/** * @route POST api/users * @description Create new user * @access private, assigner */

Now it's your turn to complete all the requirements!

Marking Guide

Everyone will start at a 100 score.

Requirement Grade
Missing any requirements -10
Missing the planning part a.k.a the pseudo-code for each route -3
Handling probable errors +10

This assignment's minimum pass score is 80/100


Good luck have fun!