Develop a Node.js application that extracts data from various APIs (e.g., gold prices, goods prices, crypto P2P prices) and stores the data in a PostgreSQL database. The application should run as a cron job that automatically fetches data every 24 hours, and it should include an endpoint to retrieve data for a specified date. The system should be designed with the flexibility to easily add new APIs or data sources.
- Build a scalable and flexible data extraction service using Node.js.
- Integrate with multiple external APIs to collect price data daily and store it in a PostgreSQL database.
- Implement a RESTful endpoint to fetch stored data for a given date.
- Design a robust database schema to support various data types and retrieval requirements targeting future additions of new API sources.
- Node.js
- Express
- TypeScript
- PostgreSQL with an ORM like Knex, Sequelize, or Drizzle
- Gold prices: https://ceyloncash.com/api/goldrates/
- P2P rates: https://nisal.me/p2p/post.php?asset=USDT&fiat=LKR&tradeType=BUY
- Consumer prices:
- The application should run as a cron job, scheduled to execute every 24 hours.
- Integrate with multiple APIs to fetch data, handle responses, and log results.
- Store data in a PostgreSQL database with a schema designed to support the various data from each API.
- Develop a modular design to easily integrate new services/APIs.
- Define a database architecture that supports storing data from multiple APIs.
- Ensure the schema is structured to efficiently store, index, and retrieve data based on date or other relevant filters.
- The schema should be designed to handle different data structures from each API while maintaining performance.
- Write necessary migration files.
- Implement a RESTful endpoint that allows users to fetch data gathered for a specified date.
- Ensure the endpoint is optimized for querying historical data from the database.
- Implement error handling for API calls, connection issues, and data validation errors.
- Log errors and exceptions to track the daemon’s performance and any issues.
- Set up detailed logging for each API call, including successes and failures.
- Implement retry mechanisms for failed API requests with exponential backoff.
- Complete Node.js application with integrated APIs.
- Defined database schema and migration scripts for PostgreSQL.
- RESTful endpoint for fetching data for a specified date.
- Error handling and logging implementations.
- Tests to validate API integrations, data storage, and endpoint functionality.
- Code quality, modularity, and maintainability.
- Database design and ability to efficiently store and query data.
- Effectiveness and reliability of data extraction and storage.
- Endpoint performance and ability to handle various query parameters.
- Quality of error handling, logging, and documentation.