Backend system for the HoBom project, built with NestJS and TypeScript following Hexagonal Architecture principles.
- Modular architecture with clear boundaries
- RESTful API using NestJS
- MongoDB integration via Mongoose
- Daily todo management like
TODO MATES - Comprehensive unit and integration testing with Jest
- Swagger-based API documentation
- GitHub Actions for CI/CD
- Framework: NestJS
- Language: TypeScript
- Database: MongoDB
- ODM: Mongoose
- Testing: Jest
- API Docs: Swagger
- CI/CD: GitHub Actions
npm installnpm run start:devnpm run testhttp://localhost:8080/api-docsHexagonal Architecture (Ports & Adapters) ํจํด์ ์ ์ฉํ๋ค.
๊ฐ ๋๋ฉ์ธ ๋ชจ๋ ๊ตฌ์กฐ:
{domain}/
โโโ domain/
โ โโโ model/ # Entity, Value Object, Repository ์ธํฐํ์ด์ค
โ โโโ ports/
โ โโโ in/ # Input Port (Use Case ์ธํฐํ์ด์ค)
โ โโโ out/ # Output Port (Command, ์ธ๋ถ ์์กด์ฑ ์ธํฐํ์ด์ค)
โโโ application/ # Use Case ๊ตฌํ์ฒด (Service)
โโโ adapters/
โ โโโ in/ # HTTP Controller, gRPC Controller
โ โโโ out/ # Persistence/Query Adapter
โโโ infra/ # Repository ๊ตฌํ์ฒด (Mongoose)
์ธ๋ถ ํด๋ผ์ด์ธํธ(์ฑ/์น)๋ REST(ํฌํธ 8080), ๋ด๋ถ ์๋น์ค ๊ฐ ํต์ ์ **gRPC(ํฌํธ 50051)**๋ฅผ ์ฌ์ฉํ๋ค.
์ด ์๋น์ค๋ Transactional Outbox ํจํด์ ๊ตฌํํ๋ค. ๋ชจ๋ ์ํ ๋ณ๊ฒฝ ์ด๋ฒคํธ๋ outbox ์ปฌ๋ ์
์ PENDING ์ํ๋ก ๊ธฐ๋ก๋๊ณ , ๋ณ๋์ consumer ์๋น์ค๋ค์ด ์ด๋ฅผ ์ฒ๋ฆฌํ๋ค.
[REST Client (์ฑ/์น)]
โ HTTP (8080)
[hobom-backend]
โ outbox ์ปฌ๋ ์
์ ์ด๋ฒคํธ ์ ์ฅ (PENDING)
โ gRPC (50051)
[Consumer Services]
- FindOutboxByEventTypeAndStatus: pending ์ด๋ฒคํธ polling
- PatchOutboxMarkAsSent: ์ฒ๋ฆฌ ์๋ฃ ํ SENT๋ก ๊ฐฑ์
1. ๊ฐํ์ ๊ณ์ฝ (Contract-First)
Protocol Buffers(.proto ํ์ผ)๊ฐ ๋ช
์์ ์ธํฐํ์ด์ค ๊ณ์ฝ์ ์ญํ ์ ํ๋ค. ์๋ฒ์ ๋ชจ๋ consumer๊ฐ ๋์ผํ hobom-buf-proto git submodule์ ์ฐธ์กฐํ๋ฏ๋ก ์คํค๋ง ๋ณ๊ฒฝ ์ ์ปดํ์ผ ํ์์ ๋ถ์ผ์น๋ฅผ ๊ฐ์งํ ์ ์๋ค.
REST๋ฅผ ์ฌ์ฉํ๋ฉด ๊ณ์ฝ์ด ์๋ฌต์ ์ด ๋์ด ๋ด๋ถ ์๋น์ค ๊ฐ ๋ฐํ์ ์๋ฌ๊ฐ ๋ฐ์ํ๊ธฐ ์ฝ๋ค.
2. ์ฑ๋ฅ
JSON ๋๋น Protocol Buffers ๋ฐ์ด๋๋ฆฌ ์ธ์ฝ๋ฉ์ payload ํฌ๊ธฐ๊ฐ ์๋ค. outbox polling์ฒ๋ผ ์ฃผ๊ธฐ์ ์ผ๋ก ๋๋์ ๋ ์ฝ๋๋ฅผ ์กฐํํ๋ ํจํด์์ ํจ์จ์ ์ด๋ค.
3. ์ฝ๋ ์์ฑ
proto ํ์ผ๋ก๋ถํฐ ํด๋ผ์ด์ธํธ/์๋ฒ ์ฝ๋๊ฐ ์๋ ์์ฑ๋์ด ํ์ ์์ ์ฑ์ด ๋ณด์ฅ๋๋ค.
| ๋์ | ๊ธฐ๊ฐ ์ด์ |
|---|---|
| REST (๋ด๋ถ) | ๊ณ์ฝ์ด ์๋ฌต์ , ๋ฒ์ ๊ด๋ฆฌ ์ด๋ ค์ |
| Message Queue (Kafka ๋ฑ) | ํ์ฌ ๊ท๋ชจ์์ ์ธํ๋ผ ๋ณต์ก๋ ๊ณผ๋ค |
hobom-buf-proto/ (git submodule)์์ ๊ด๋ฆฌํ๋ค.