A NestJS microservice that aggregates and caches NASA RSS feeds using a clean hexagonal architecture. It automatically synchronizes data, ensures high performance with Redis caching, and exposes a documented REST API.
- Fetches and stores NASA news in PostgreSQL
- Uses Redis for caching and fast responses
- Syncs automatically via cron job
- Provides REST API with Swagger docs
- Fully testable hexagonal architecture (ports & adapters)
Scheduler → SyncNewsUseCase → NasaProvider → PostgreSQL
HTTP GET /news → GetNewsUseCase → Redis Cache → PostgreSQL
Scheduler → SyncNewsUseCase → NasaProviderClient
↓
Fetch XML Feed
↓
Parse with fast-xml-parser
↓
Validate & Create Entities
↓
NewsRepository (Upsert)
↓
PostgreSQL
HTTP GET /news?limit=10
↓
NewsController
↓
GetNewsUseCase
↓
Check Redis Cache
├─ ✅ HIT: Return cached data (⚡ fast)
└─ ❌ MISS: Query PostgreSQL → Cache in Redis → Return
| Category | Technology |
|---|---|
| Framework | NestJS 11 + TypeScript 5 |
| Database | PostgreSQL (Prisma ORM) |
| Cache | Redis 7 |
| Infra | Docker Compose |
| Docs | Swagger / OpenAPI |
| Tests | Jest |
- Node.js ≥ 18
- pnpm ≥ 8
- Docker & Docker Compose
git clone https://github.com/annaescalada/news-aggregator-api.git
cd api && pnpm install
make run # Starts DB, runs migrations, and launches the APIAPI available at http://localhost:3000 Swagger docs at /docs
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/anna_escalada
REDIS_URL=redis://localhost:6379
NASA_RSS_URL=https://www.nasa.gov/rss/dyn/breaking_news.rss
PORT=3000
NODE_ENV=development- 🕒 Hourly sync of NASA RSS feeds
- ⚡ Smart Redis caching for repeated queries
- 🧩 Modular & maintainable architecture
- 🧪 Unit & E2E tests with Jest
- 🐳 Docker-based local setup
pnpm test # Run all tests
pnpm test:e2e # Run end-to-end tests
pnpm test:cov # Generate coverage reportapi/
├── src/
│ ├── modules/news/
│ │ ├── domain/ # Entities
│ │ ├── application/ # Use cases & ports
│ │ ├── adapters/ # Controllers, schedulers, repos
│ │ └── news.module.ts
│ ├── common/ # Shared services (Prisma, Redis)
│ └── main.ts
└── prisma/ # DB schema & migrations
make up # Start PostgreSQL & Redis
make migrate # Run migrations
make dev # Run NestJS in watch mode
make down # Stop Docker containersMIT
Built using NestJS and Hexagonal Architecture