https://github.com/arakakimath/order-logistics-api
Last challenge of Rocketseat Node.js course, in which the student has to develop an api, for a ficticious delivery company called FastFeet, to manage related issues
https://github.com/arakakimath/order-logistics-api
apprunner aws ci-cd clean-architecture ddd docker ecr iac-terraform mongodb mongoose nestjs nodejs semantic-release solid-principles swagger tdd test typescript vitest zod
Last synced: 4 months ago
JSON representation
Last challenge of Rocketseat Node.js course, in which the student has to develop an api, for a ficticious delivery company called FastFeet, to manage related issues
- Host: GitHub
- URL: https://github.com/arakakimath/order-logistics-api
- Owner: arakakimath
- Created: 2025-02-11T15:24:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-14T16:32:09.000Z (over 1 year ago)
- Last Synced: 2025-07-19T12:39:15.128Z (11 months ago)
- Topics: apprunner, aws, ci-cd, clean-architecture, ddd, docker, ecr, iac-terraform, mongodb, mongoose, nestjs, nodejs, semantic-release, solid-principles, swagger, tdd, test, typescript, vitest, zod
- Language: TypeScript
- Homepage:
- Size: 416 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Order Logistics API ๐
The **Order Logistics API** is the final challenge of Rocketseat's Node.js course, designed for managing deliveries in a fictional company called **FastFeet**. It provides features for **user authentication**, **order tracking**, **delivery management**, and **recipient notifications**, following best practices like **Clean Architecture, DDD, and TDD**.
The project is built with **NestJS, TypeScript, MongoDB**, and **Docker**, ensuring **scalability and maintainability**. It uses **JWT authentication** with **public/private key encryption**, and the infrastructure is deployed using **AWS AppRunner** with a fully automated **CI/CD pipeline**.
The API supports **role-based access control**, allowing **admins to manage deliveries** while **delivery personnel handle pickups and drop-offs**. It also includes a robust **testing suite** and **Swagger documentation** for easy integration.
## ๐ Table of Contents
- [๐ About the Project](#about)
- [๐ Technologies](#technologies)
- [โ๏ธ Getting Started](#getting-started)
- [๐ Environment Variables](#env-vars)
- [โ
Functional Requirements](#functional-requirements)
- [๐ Business Rules](#business-rules)
- [๐งช Running Tests](#running-tests)
- [๐ API Endpoints](#api-endpoints)
- [๐ค Contributing](#contributing)
- [๐ License](#license)
- [๐ฉ Contact](#contact)
---
The Order Logistics API is a system designed to manage deliveries for a fictitious company called FastFeet. It allows administrators to manage orders, delivery personnel, and recipients while providing delivery personnel with tools to track and complete deliveries efficiently.
The API includes authentication, role-based access control, order tracking, and notifications for recipients when an order's status changes.
### **Tech Stack & Tools**
- **๐ข NestJS (Express)** โ Modular and structured Node.js framework for building efficient and scalable server-side applications.
- **๐ TypeScript** โ Statically typed JavaScript for enhanced code quality and maintainability.
- **๐ MongoDB + Mongoose** โ NoSQL database with a schema-based ORM for flexible and scalable data persistence.
- **๐ณ Docker** โ Containerized infrastructure for consistent development and deployment environments.
- **๐ฆ Clean Architecture** โ Separation of concerns for a modular, testable, and scalable codebase.
- **๐ JWT Authentication (ES256)** โ Secure user authentication using private/public key encryption and ECDSA algorithm.
- **๐ก๏ธ Zod** โ Schema-based validation for environment variables, request body, query, and params.
- **๐งช Vitest + Supertest** โ Unit and integration testing for ensuring API reliability and robustness.
- **๐ ESLint** โ Code formatting and linting for maintaining consistent code quality.
- **๐ bcryptjs** โ Password hashing and comparison for secure authentication.
- **๐ Swagger** โ API documentation for easy testing and integration.
- **๐ Semantic Release** โ Automated versioning and changelog generation for streamlined releases.
- **๐ OAuth 2.0 with GitHub** โ Secure authentication via GitHub using OAuth 2.0 for user login.
### **Infrastructure & Deployment**
- **โ๏ธ AWS ECR (Elastic Container Registry)** โ Secure storage for Docker images.
- **๐ฆ AWS AppRunner** โ Fully managed service for deploying containerized applications.
- **๐ ๏ธ Infrastructure as Code (IaC)** โ Automated provisioning and management of AWS resources using IAM roles.
- **๐ CI/CD Pipeline** โ Automated workflow from code push to deployment:
- **Push to Main (PR)** โ **GitHub Actions** โ **Docker Build** โ **AWS ECR** โ **AWS AppRunner**.
### **Development Principles**
- **๐งฉ Domain-Driven Design (DDD)** โ Focus on core business logic and domain models.
- **๐งช Test-Driven Development (TDD)** โ Write tests before implementation to ensure reliability.
- **๐ง SOLID Principles** โ Design patterns for maintainable and scalable code.
- **๐ Modular Codebase** โ Organized and reusable components for easier maintenance.
### Prerequisites
To run this project, you need:
- ๐ณ **[Docker](https://www.docker.com/)** โ Runs the entire application (MongoDB and the built API image)
### Installation
1๏ธโฃ Clone this repository:
`git clone https://github.com/your-username/order-logistics-api.git`
2๏ธโฃ Enter the project directory:
`cd order-logistics-api`
3๏ธโฃ Install dependencies:
`npm install`
### Running the Project
1๏ธโฃ Start the services with Docker:
`docker-compose up -d`
2๏ธโฃ Make HTTP requests to the base URL [http://localhost:3333](http://localhost:3333)
```
PORT=3333
NODE_ENV="dev"
# Database
DATABASE_URL="mongodb://mongodb:docker@localhost:27017/order-logistics?authSource=admin"
# JWT Secrets => Generate ECDSA private key and then public key
JWT_PRIVATE_KEY="jwt_ec_key"
JWT_PUBLIC_KEY="jwt_ec_public_key"
# Auth with GitHub
GITHUB_CLIENT_ID="someID"
GITHUB_CLIENT_SECRET="someSecret"
```
- [x] Application must have two roles for users: admin and/or delivery person
- [x] It should be possible to sign in with CPF (National ID) and password
- [x] It should be possible to perform the CRUD of the delivery people
- [ ] It should be possible to perform the CRUD of the orders
- [ ] It should be possible to perform the CRUD of the recipients
- [ ] It should be possible to flag an order as awaiting (Available for pickup)
- [ ] It should be possible to pickup an order
- [ ] It should be possible to flag an order as delivered
- [ ] It should be possible to flag an order as returned
- [ ] It should be possible to list orders whose delivery addresses are close to the delivery person
- [x] It should be possible to change user's password
- [ ] It should be possible to list user's orders
- [ ] It should be possible to notify recipient on every order status change
- [x] Only admin users can perform CRUD of the delivery people
- [ ] Only admin users can perform CRUD of the orders
- [ ] Only admin users can perform CRUD of the recipients
- [ ] A photo is needed to flag an order as delivered
- [ ] Only the delivery person who picked up the order can flag it as delivered
- [x] Only admin users can change an user's password
- [ ] It should not be possible for a delivery person to list another one's orders
Run unit tests with:
```bash
npm test
```
Run end-to-end (e2e) tests with:
```bash
npm run test:e2e
```
### Register delivery person - [POST] /users
### Authenticate login - [POST] /auth
### Authenticate with GitHub (OAuth 2.0) - [GET] /auth/github
Redirects users to authorization github page and then to /auth/github/callback, which can link github with already created users or login into API
Want to contribute? Follow these steps:
1. Fork the repository.
2. Create a new branch: `git checkout -b feature-branch`.
3. Make your changes and commit: `git commit -m "Added new feature"`.
4. Push to your fork: `git push origin feature-branch`.
5. Open a Pull Request.
## ๐ License
This project is under the **MIT License** โ see the [LICENSE](https://opensource.org/license/MIT) file for details.
## ๐ฉ Contact
For support or inquiries, contact:
- **Email:** arakakimath@gmail.com
- **LinkedIn:** [Matheus Arakaki](https://linkedin.com/in/arakakimath)
- **GitHub:** [@arakakimath](https://github.com/arakakimath)