Skip to content

About

Challenge 06 of the DNC Software Engineering course.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

DNCommerce API

This project was originally developed as a required challenge for Escola DNC. It has since been completely refactored, modernized, and containerized following software engineering best practices.

Overview

This is a RESTful API built with Node.js, Express, and MongoDB. It manages a complete e-commerce backend workflow including Customers, Products, Inventory, and Sales. The code structure strictly adheres to the MVC (Model-View-Controller) architecture, ensuring clean separation of concerns and maintainability. All internal code, database schemas, and endpoints are implemented in English, while end-user-facing messages (such as UI translations and generic validation errors) remain in Portuguese.

Features

  • Products: Full CRUD operations for products.
  • Inventory: Automatic inventory creation for new products and seamless deduction upon successful sales.
  • Customers: Management of customer profiles with embedded address documents.
  • Sales: Transactional workflow that validates inventory, calculates totals, updates statuses, and deducts items from inventory stocks automatically.

Tech Stack

  • Node.js
  • Express.js
  • MongoDB with Mongoose
  • Docker & Docker Compose

Project Structure

src/
├── config/       # Database and environment configurations
├── controllers/  # Request handlers and business logic
├── models/       # Mongoose schema definitions
├── routes/       # Express route declarations
└── app.js        # Entry point and middleware setup

Running the Application

1. Using Docker (Recommended)

Make sure you have Docker and Docker Compose installed.

  1. Clone the repository and navigate into the project root directory.
  2. Build and start the containers using Docker Compose:
    docker-compose up --build
  3. The API will be available at http://localhost:3000 and it will automatically connect to a MongoDB instance running in the background.

2. Running Locally

If you prefer to run the application locally without Docker, ensure you have Node.js and a local instance of MongoDB running.

  1. Install dependencies:
    npm install
  2. Create a .env file in the root directory and set your MongoDB URI:
    PORT=3000
    MONGODB_URI=mongodb://localhost:27017/dncommerce
  3. Start the application:
    npm start

Testing

You can use the provided bash script to quickly verify all endpoints:

chmod +x tests/test_api_bash.sh
./tests/test_api_bash.sh

(A PowerShell script is also provided in the tests directory for Windows users).

About

Challenge 06 of the DNC Software Engineering course.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages