How evaristopinto16/currency-exchange-services works
Project type and purpose
• This is a monolithic, full-stack (API-only) microservice written in Node.js using the Fastify framework.
• Purpose: provide informal, up-to-date currency exchange rates via two REST endpoints:
• GET /api/v1/getcoin – returns supported currency codes
• POST /api/v1/conversor – returns converted value plus informal rate tiers and past quotations
File structure
• Top-level files:
• app.js – Fastify initialization and server start
• package.json / package-lock.json – dependencies and scripts
• .gitignore / getGrafico.http – HTTP test snippets
• src/config/apiurlConfig.js – external API URL and credentials
• src/routers/router.js – defines /api/v1 routes
• src/controllers/…Controller.js – parse request, handle HTTP response
• src/service/cambioServices.js – core business logic orchestration
• src/utilis/*.js – stateless helper modules:
• conversaoCambioUtilis.js – calculate basic conversion
• cotacoesPassadasUtilis.js – fetch or compute past quotations
• notsleepUtilis.js – delay or retry logic
README for insights
a. Main components
• Client (e.g., Postman, browser, mobile app)
• Fastify HTTP Server (app.js)
• Router layer (router.js)
• Controller layer (cambioController.js & getCoinController.js)
• Service layer (cambioServices.js)
• Utility modules (conversion util, past-quotes util, non-sleep util)
• External Currency Rates API
b. Relationships & interactions
1. Client → HTTP Server (incoming request)
2. HTTP Server → Router → Controller
3. Controller → Service (pass parameters)
4. Service → Utility modules & External API
5. Utility modules call External API and perform business calculations
6. Service aggregates results and returns to Controller
7. Controller → HTTP Server → Client (response JSON)
c. Architectural patterns
• Layered architecture (HTTP → Router → Controller → Service → Utils)
• Separation of concerns: routing, request handling, business logic, helpers
• Single-responsibility utility modules for conversion, past data, retry/delay
d. Key technologies
• Node.js, Fastify (ultra-fast HTTP framework)
• JavaScript ES modules (import/exports in app.js, controllers, services)
• External REST API for live currency data
Final advice
• Be exhaustive: include every layer and helper module.
• Both happy-path and any retry/delay logic (notsleepUtilis).
• Labels match actual file or module names for clarity to the engineering team.