GitHunt
TH

thanhdaon/task-management

Task Management API

Table of Contents

  1. Environments
  2. Tech Stack
  3. Features
  4. Steps to Run the Project Locally
  5. Scripts
  6. API Documentation
  7. Deployment Instructions

Environments

  • Node.js: 23
  • Package Manager: pnpm

Tech Stack

  • Backend Framework: Hono
  • Validation: Zod
  • API Documentation: Hono Zod-OpenAPI, Hono Swagger-UI
  • ORM: Drizzle ORM
  • Database: PostgreSQL
  • Testing: Vitest

Features

Employee Role

  • View Assigned Tasks
    Employees can only view tasks specifically assigned to them.
  • Update Task Status
    Employees can update the status of their tasks (e.g., "In Progress," "Completed").

Employer Role

  • Create and Assign Tasks
    Employers can create tasks and assign them to employees.
  • View All Tasks with Filtering and Sorting
    • Filter By: Assignee, Status (e.g., "Pending," "In Progress," "Completed").
    • Sort By: Creation Date, Due Date, Task Status (e.g., Active or Completed).
  • View Employee Task Summary
    • Total number of tasks assigned to an employee.
    • Number of tasks completed by each employee.

Steps to Run the Project Locally

1. Clone the Project:

First, clone the project repository to your local machine:

git clone <your-repo-url>
cd <your-project-directory>

2. Install Dependencies:

Install the required dependencies using pnpm:

pnpm install

3. Set Up Environment Variables:

Create a .env file in the root directory of the project (if it's not already present).

Example .env:

PORT= # port of server
DATABASE_URL= # PostgreSQL connection string

4. Run Database Migrations (for development):

To apply pending migrations and update the local development database schema, run:

pnpm db:migrate

5. (Optional) Seed the Database:

If you want to populate the database with mock data for testing, use the seeding script:

pnpm db:seed

6. Start the Development Server:

Now you can start the development server with hot-reloading enabled:

pnpm dev

This will run the server on http://localhost:8000 (by default) and the swagger doc will live on http://localhost:8000/api/doc.

Scripts

Development

  • pnpm dev
    Starts the development server with hot-reloading.

Production

  • pnpm build
    Builds the application for production.

Database Management

  • pnpm db:generate
    Generates a new migration file.

  • pnpm db:migrate
    Applies migrations to update the database schema.

  • pnpm db:seed
    Seeds the database with mock data.

  • pnpm db:studio
    Opens Prisma Studio for database interaction.

Testing

  • pnpm test
    Runs the tests using Vitest.

API Documentation

API documentation is available via Swagger:

Deployment Instructions

Using Docker

  1. Build the Docker image:
docker build -t task-management-api .
  1. Run the container:
docker run -p 8000:8000 --env-file .env task-management-api
  1. The application will be accessible at http://localhost:8000.

Using Docker Compose

  1. Run the application:
docker-compose up --build
thanhdaon/task-management | GitHunt