Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
227 changes: 208 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,67 @@
# πŸ“ NestJS Todo Playground

A simple and extensible Todo backend playground built with [NestJS](https://nestjs.com/), MongoDB (Mongoose), and TypeScript. This project demonstrates modular architecture, DTO validation, custom error handling, and includes ready-to-use Docker and test setups.
A comprehensive Todo backend playground built with [NestJS](https://nestjs.com/), showcasing modern backend architecture with microservices patterns, event-driven design, and AI integration. This project demonstrates advanced NestJS features, distributed systems concepts, and production-ready patterns.

---

## πŸš€ Features

- Modular structure with NestJS
- Authentication (JWT tokens)
- `MongoDB` integration using Mongoose
- User registration with unique nickname validation
- DTO validation with class-validator
- Custom error and exception handling
- Ready-to-use `integration tests` (Jest & Supertest)
- `Docker support` for easy development and deployment
### Core Backend Features

- **Modular NestJS Architecture** with clean separation of concerns
- **JWT Authentication** with access & refresh tokens
- **MongoDB Integration** using Mongoose ODM
- **Redis Caching & Session Management**
- **DTO Validation** with class-validator
- **Custom Exception Handling** with structured error responses
- **Integration Testing Suite** (Jest & Supertest)

### Advanced Features

- **πŸ”„ BullMQ Job Queue** - Delayed todo deletion with rollback support
- **πŸ” Elasticsearch Integration** - Full-text search capabilities
- **🐰 RabbitMQ Event System** - Event-driven architecture for data synchronization
- **πŸ”’ RedLock Distributed Locking** - Race condition protection
- **⚑ Real-time Search** - Instant todo search with Elasticsearch
- **🐳 Docker-Compose Setup** - Multi-container development environment

### AI & Integration

- **πŸ€– MCP (Model Context Protocol)** - Claude Desktop integration
- **πŸ”§ Natural Language Interface** - Control your app via AI commands
- **πŸ“‘ JSON-RPC Protocol** - Standardized AI-to-backend communication

---

## πŸ› οΈ Tech Stack

### Backend Framework

- **[NestJS](https://nestjs.com/)** - Progressive Node.js framework
- **TypeScript** - Type-safe JavaScript
- **Express.js** - Web framework (underlying NestJS)

### Databases & Storage

- **[MongoDB](https://www.mongodb.com/)** - Document database with Mongoose ODM
- **[Redis](https://redis.io/)** - In-memory caching & session storage
- **[Elasticsearch](https://www.elastic.co/)** - Full-text search engine

### Message Queues & Events

- **[BullMQ](https://bullmq.io/)** - Redis-based job queue for background tasks
- **[RabbitMQ](https://www.rabbitmq.com/)** - Message broker for event-driven architecture

### DevOps & Infrastructure

- **[Docker](https://www.docker.com/)** & **Docker Compose** - Containerization
- **[Jest](https://jestjs.io/)** - Testing framework with Supertest
- **[Swagger](https://swagger.io/)** - API documentation

### AI Integration

- **[Model Context Protocol (MCP)](https://spec.modelcontextprotocol.io/)** - AI integration standard
- **JSON-RPC** - Remote procedure call protocol

---

Expand All @@ -29,7 +77,7 @@ npm install

```bash
$ cd docker
$ docker compose up
$ docker compose up
```

---
Expand All @@ -38,7 +86,103 @@ $ docker compose up

```bash
$ cd docker
$ docker compose down
$ docker compose down
```

---

## πŸ€– MCP (Model Context Protocol) Integration

This project includes MCP server integration, allowing **Claude Desktop** to interact with your Todo application using natural language commands.

### πŸƒβ€β™‚οΈ Running MCP Server

The MCP server runs automatically when you start the Docker containers:

```bash
$ cd docker
$ docker compose up
```

This starts both:

- **HTTP API Server** (port 3000) - Regular REST API
- **MCP Server** (stdio) - Claude Desktop integration

### πŸ”§ Claude Desktop Setup

1. **Install Claude Desktop** from Anthropic

2. **Create/Edit Claude Desktop config file**:

- **macOS**: `~/.config/claude-desktop/claude_desktop_config.json`
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux**: `~/.config/claude-desktop/claude_desktop_config.json`

3. **Add MCP server configuration**:

```json
{
"mcpServers": {
"nestjs-todo": {
"command": "docker",
"args": [
"exec",
"-i",
"docker-mcp-server-1",
"node",
"dist/mcp-server.js"
]
}
}
}
```

4. **Restart Claude Desktop** completely

### 🎯 Available MCP Tools

- `auth_register` - Register new user
- `auth_login` - User authentication and JWT token retrieval

### πŸ’¬ Example Claude Desktop Commands

Try these natural language commands in Claude Desktop:

```
Can you register a new user with:
- Full name: "John Doe"
- Nickname: "johndoe"
- Password: "secure123"
```

```
Please login user "johndoe" with password "secure123"
```

```
What MCP tools are available in this application?
```

### πŸ” Troubleshooting MCP

**Check if MCP server is running:**

```bash
docker ps | grep mcp-server
# Should show: docker-mcp-server-1
```

**View MCP server logs:**

```bash
docker logs docker-mcp-server-1
```

**Restart only MCP server:**

```bash
docker compose restart mcp-server
```

---
Expand Down Expand Up @@ -79,17 +223,57 @@ npm run test

## πŸ“¬ Example API Usage

Create a user:
### Authentication

```http
# Register User
POST /user
Content-Type: application/json

{
"nickname": "your_nickname",
"fullname": "Your Name",
"password": "your_password"
"nickname": "johndoe",
"fullname": "John Doe",
"password": "secure123"
}

# Login User
POST /auth/sign-in
Content-Type: application/json

{
"nickname": "johndoe",
"password": "secure123"
}
```

### Todo Management

```http
# Create Todo
POST /todo
Authorization: Bearer <access_token>
Content-Type: application/json

{
"title": "Learn NestJS",
"description": "Build a comprehensive todo app"
}

# Get Todos
GET /todo?page=1&limit=10&completed=false
Authorization: Bearer <access_token>

# Search Todos (Elasticsearch)
GET /todo/search?q=NestJS
Authorization: Bearer <access_token>

# Delete Todo (with 4-second delay)
DELETE /todo/:id
Authorization: Bearer <access_token>

# Cancel Deletion (within 4 seconds)
POST /todo/:id/cancel-deletion
Authorization: Bearer <access_token>
```

---
Expand All @@ -110,12 +294,17 @@ Pull requests and suggestions are welcome!

## πŸ“š Resources

- [NestJS Documentation](https://docs.nestjs.com)
- [Mongoose Docs](https://mongoosejs.com/)
- [Jest Docs](https://jestjs.io/)
- [NestJS Documentation](https://docs.nestjs.com) - Framework fundamentals
- [MongoDB & Mongoose](https://mongoosejs.com/) - Database & ODM
- [BullMQ Documentation](https://bullmq.io/) - Job queue system
- [RabbitMQ Tutorials](https://www.rabbitmq.com/tutorials.html) - Message broker
- [Elasticsearch Guide](https://www.elastic.co/guide/) - Search engine
- [Model Context Protocol](https://spec.modelcontextprotocol.io/) - AI integration standard
- [Docker Compose](https://docs.docker.com/compose/) - Multi-container applications
- [Jest Testing](https://jestjs.io/) - Testing framework

---

## πŸͺͺ License

This project is for educational purposes and is currently **unlicensed**.
This project is for educational purposes demonstrating advanced NestJS patterns and AI integration. Currently **unlicensed**.
16 changes: 16 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ services:
networks:
- nestjs-todo-network

mcp-server:
build:
context: ..
dockerfile: ./docker/Dockerfile
command: npm run mcp:dev
volumes:
- ../src:/usr/src/app/src
depends_on:
- mongo
- redis-db
- todo-playground-server
env_file:
- ../.env
networks:
- nestjs-todo-network

mongo:
image: mongo
container_name: todo-playground-mongo
Expand Down
Loading