An open API service indexing awesome lists of open source software.

https://github.com/crabstechnologies/notes-api

🧠 Simple Notes API built with NestJS, TypeORM, SQLite, and Swagger β€” a clean CRUD backend for learning and portfolio projects.
https://github.com/crabstechnologies/notes-api

api backend crud learning-project nestjs nodejs sqlite swagger typeorm typescript

Last synced: about 2 months ago
JSON representation

🧠 Simple Notes API built with NestJS, TypeORM, SQLite, and Swagger β€” a clean CRUD backend for learning and portfolio projects.

Awesome Lists containing this project

README

          

![NestJS](https://img.shields.io/badge/NestJS-E0234E?style=for-the-badge&logo=nestjs&logoColor=white)
![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white)
![TypeORM](https://img.shields.io/badge/TypeORM-FF6C37?style=for-the-badge&logo=typeorm&logoColor=white)
![Swagger](https://img.shields.io/badge/Swagger-85EA2D?style=for-the-badge&logo=swagger&logoColor=black)
![SQLite](https://img.shields.io/badge/SQLite-07405E?style=for-the-badge&logo=sqlite&logoColor=white)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

# 🧠 Notes API β€” NestJS + TypeORM + SQLite

A clean, production-ready **REST API** built with **NestJS**, demonstrating how to design a modular, well-documented backend service using **TypeORM**, **SQLite**, and **Swagger**.
This project is beginner-friendly but follows industry best practices β€” perfect for learning or showcasing your backend skills.

---

## πŸš€ Features

βœ… **CRUD Operations** β€” Create, Read, Update, Delete notes
βœ… **Validation** β€” Strong input validation using `class-validator`
βœ… **Auto Docs** β€” Built-in Swagger UI (`/docs`)
βœ… **TypeORM Integration** β€” SQLite for simplicity (zero setup)
βœ… **Seed Script** β€” Preloads demo data for quick testing
βœ… **Unit Tests** β€” Example service test with Jest
βœ… **Clean Architecture** β€” Organized modules, DTOs, and entities

---

## 🧰 Tech Stack

| Layer | Technology |
|-------------------|--------------------------------------|
| Framework | [NestJS](https://nestjs.com/) |
| ORM | [TypeORM](https://typeorm.io/) |
| Database | SQLite |
| Validation | class-validator / class-transformer |
| Documentation | Swagger (OpenAPI) |
| Testing | Jest |
| Package Manager | Yarn |

---

## πŸ“¦ Installation

Clone and install dependencies:

```bash
git clone https://github.com//notes-api.git
cd notes-api
yarn install
```
---

## βš™οΈ Running the App

# Development mode (auto-reloads)
```bash
yarn start:dev
```
# Production build
```bash
yarn build
yarn start:prod
```
### Database schema sync (TypeORM)

TypeORM's automatic schema sync is controlled via the `TYPEORM_SYNC` environment
variable:

```bash
# .env (local development)
TYPEORM_SYNC=true
```
For production deployments the flag **must** be set to `false` to protect data
migrations. The provided `yarn start:prod` script already enforces this by
running `TYPEORM_SYNC=false node dist/main`. If you use a different process
manager, make sure to export the variable yourself (for Windows PowerShell use
`$env:TYPEORM_SYNC = 'false'`).

---

## 🌱 Seeding Sample Data

You can prefill the database with example notes:

```bash
yarn seed
```
This will insert two demo notes:
β€œWelcome” β€” first seeded note ✨
β€œSecond” β€” edit or delete it in Thunder Client!

---

## πŸ” API Endpoints Overview

| Method | Endpoint | Description |
|---------|-------------|---------------------|
| POST | /notes | Create a new note |
| GET | /notes | Get all notes |
| GET | /notes/:id | Get a specific note |
| PATCH | /notes/:id | Update a note |
| DELETE | /notes/:id | Delete a note |

---

## πŸ§ͺ Testing

```bash
yarn test
```
You’ll find example tests under src/notes/notes.service.spec.ts.

---

## 🧩 Project Structure
```bash
src
β”œβ”€β”€ app.module.ts # Root module
β”œβ”€β”€ main.ts # Entry point + Swagger setup
└── notes
β”œβ”€β”€ dto # Data transfer objects (validation)
β”œβ”€β”€ entities # TypeORM entities
β”œβ”€β”€ notes.controller.ts
β”œβ”€β”€ notes.module.ts
└── notes.service.ts
```
---

## 🧠 Learning Objectives

This project demonstrates:


  • Clean modular design in NestJS

  • DTO + validation + transformation flow

  • Database persistence with TypeORM

  • Swagger documentation automation

  • Dependency injection and testing with Jest

---

## ⭐ If you like this project, consider giving it a star on GitHub, it helps others discover learning-friendly NestJS examples!

---

## πŸ“„ License

This project is licensed under the [MIT License](LICENSE).