How quangngonz/isph-se-pubsub-services works
Main Components
• Engine & Event Processing:
• engine.js is the “heartbeat” of the system, simulating and triggering stock market events at random intervals.
• Under the functions directory, several modules (e.g., manipulateStockPrices.js, proccessEvent.js, saveCurrentPortfolioValue.js) handle evaluation and data processing.
• API and Server:
• server.js serves as the entry point, handling HTTP requests (such as the /trigger-task endpoint) and interfacing with other components.
• Services Layer:
• The services directory contains specific business logic. For example, services/evaluation (eventEvaluation.js, priceProjectionTransactions.js) implements AI-driven evaluation and projection.
• services/firebaseService.js represents integration with Firebase for real-time data management.
• External Integrations:
• The system integrates with third-party APIs (OpenAI and Google Gemini) for analytical tasks, as indicated in the README.
• There’s also a Redis integration (configured via the environment variable REDIS_URL) likely for caching or message brokering.
• Deployment and CI/CD:
• The presence of Heroku-related configuration (heroku_config.py, Procfile) indicates deployment automation.
• GitHub workflows (in .github/workflows) show automated quality checks.
• Test Suite:
• The test directory includes Python scripts for firing events, generating test data (both CSV and JSON formats), and pushing data to Firebase. This indicates a robust testing framework for simulation and validation.
Out Relationships and Interactions
• The engine (engine.js) continuously triggers event processing functions in the functions directory.
• API endpoints (defined in server.js) allow external triggering of tasks (e.g., via POST /trigger-task).
• These tasks interact with the services layer:
• The evaluation services process and project stock prices.
• The Firebase service updates the real-time database.
• Scheduled and background tasks (like saving portfolio values via saveCurrentPortfolioValue.js) run at fixed intervals.
• Data flows from historical and current event data into the evaluation modules and then outputs back to both Firebase (for real-time data) and potential external consumers (through API responses).
Architectural Patterns and Design Principles
• Modularization: The design clearly separates various concerns into discrete modules (functions, services, tests).
• Pub/Sub and Event-Driven Design: The system uses an event-based approach to trigger stock evaluations and projections.
• External API Integration: The usage of AI-based evaluations highlights integration patterns with external services (OpenAI, Gemini).
• Deployment and Automation: CI/CD practices via GitHub workflows and Heroku configuration illustrate adherence to modern DevOps practices.
Relevant Technologies, Frameworks, and Libraries
• Node.js for the runtime environment.
• Firebase for real-time data handling.
• Heroku for deployment.
• CI tools as seen in the Qodana and GitHub Actions workflow.
• Python scripts for auxiliary testing and data generation.
• External APIs (OpenAI and Google Gemini) to drive the AI logic.