How eduardosouzv/pokefight-api works
Key Components to Include:
Client Layer
• External clients making API requests
• Webhook endpoints receiving battle results
API Layer
• Express.js server (src/app.js, src/server.js)
• Routes (src/routes/)
• Controllers (src/controllers/PokemonController.js)
Service Layer
• PokeAPI Integration (src/services/PokeApiService.js)
• Webhook Service (src/services/WebhookService.js)
Queue System
• Bull Queue implementation (src/lib/Queue.js)
• Battle Creation Job (src/jobs/BattleCreation.js)
Data Layer
• PostgreSQL Database (src/database/)
• Redis for queue management (src/config/redis.js)
Connection Flows
a. Client → API Routes → Controllers
b. Controllers → Services
c. Services → External APIs (PokeAPI)
d. Controllers → Queue System
e. Queue System → Battle Processing → Webhook Notifications
Component Details
[External Clients] → [Swagger UI (Port 7777)]
• ↓
[API Gateway (Port 3333)]
• ↓
[Routes Layer]
• Pokemon Routes
• Queue Monitoring Routes
• ↓
[Controllers]
• Pokemon Controller
• ↓
[Services Layer]
• PokeAPI Service → [External PokeAPI]
• Webhook Service
• ↓
[Queue System (Bull)]
• Battle Creation Jobs
• Queue Monitoring (Bull Board)
• ↓
[Data Storage]
• PostgreSQL (Battles)
• Redis (Queue Management)
• ↓
[Webhook Notifications] → [External Webhook Endpoints]
Additional Elements
• A container boundary showing Docker components
• Environment configurations
• Database schema for Battles table
• Monitoring points (Bull Board)