Skip to content

riz007/task-manager

Repository files navigation

Task Manager - A Docker, Node.js, Redis, and PostgreSQL Based Project

This project is a simple task manager application designed to be a learning resource for developers interested in Docker, Node.js, Redis, and PostgreSQL. The application provides a basic REST API for creating, reading, updating, and deleting tasks.

Technologies Used

  • Docker & Docker Compose: Used to containerize the application and its services, making it easy to set up and run in a consistent environment. Docker isolates the application and its dependencies, while Docker Compose orchestrates the multi-container setup.
  • Node.js: The backend of the application is built with Node.js. This provides the REST API for managing tasks.
  • PostgreSQL: A powerful, open-source object-relational database system used as the primary data store for the tasks.
  • Redis: An in-memory data structure store, used as a cache to improve the performance of reading tasks.

Prerequisites

Before you begin, ensure you have the following installed on your system:

Getting Started

  1. Clone the repository:

    git clone https://github.com/riz007/task-manager.git
    cd task-manager
  2. Start the application:

    docker-compose up --build

    This command will build the Docker images for the Node.js application and start the containers for the application, PostgreSQL, and Redis. The application will be available at http://localhost:3000.

Project Structure

.
├── docker-compose.yml  # Defines the services, networks, and volumes for Docker Compose
├── Dockerfile          # Defines the Docker image for the Node.js application
├── LICENSE             # Project license
├── package.json        # Node.js project metadata and dependencies
├── README.md           # This file
└── src
    ├── db.js               # PostgreSQL connection setup
    ├── redis.js            # Redis connection setup
    ├── server.js           # Node.js server setup and API routes
    └── taskController.js   # Application logic for handling tasks

How it Works

The application is composed of three services defined in docker-compose.yml:

  • app: The Node.js application container.
  • db: The PostgreSQL database container.
  • redis: The Redis cache container.

When a request is made to the API:

  1. The Node.js server in server.js receives the request.
  2. The request is routed to the appropriate function in taskController.js.
  3. For read requests (getTasks), the controller first checks if the data is in the Redis cache. If it is, the cached data is returned. If not, the controller queries the PostgreSQL database, stores the result in the cache, and then returns the data.
  4. For write requests (createTask, updateTask, patchTask, deleteTask), the controller updates the PostgreSQL database and then clears the Redis cache to ensure that subsequent reads will fetch the fresh data.

Running Tests

To run the tests, you can use the following command:

docker-compose exec app yarn test

This will execute the tests inside the running app container.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A Node.js Powered Task Manager

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published