How alangdp/ibovespadata works
• API Layer/Entry Point: Start with the “server.ts” and “app.ts” as the point-of-entry for HTTP requests. This represents the web server that listens for incoming simulation-related API calls.
• Routing and Controllers: Include the “routes” and “controllers” directories. For example, there are routes and controllers for specific functionalities like “bazin”, “graham”, “stock”, “simulation”, and “history”. Each controller handles API requests and delegates the work to the use cases.
• Business Logic / Use Cases: Represent the “useCases” directory (e.g., Fetcher, PontuationDatabase, RankingCsv, stockDataBase, and jsonStockDataBase). This layer performs the simulation calculations, manages investment computation logic, and orchestrates the results.
• Domain Entities and Models: Highlight the “Entities” directory and list each entity such as Bazin, Chart, Graham, History, Pontuation, Simulation, Stock, Transaction, and Variable. These entities encapsulate the core data structures utilized by the business logic.
• Interfaces and Types: Note the “interfaces” and “types” directories that define the contracts and data types used throughout the system, ensuring consistency in communication between components.
• Utility and Helper Modules: Include the “utils” directory, which features modules for API fetching, date formatting, caching (e.g., CacheJson), ranking, and other computational utilities. These support the core business logic.
• Global/Shared Components: Mark the “global” folder which includes shared modules (e.g., MacroInfo, Queue, Redis) that are used for caching, queuing, or managing macro information across the system.
• External dependencies: Don’t forget to represent external systems like Redis (noted by “redis.conf” and “src/global/Redis.ts”), Docker (via “Docker-compose.yml”), and any environment files (e.g., “.env.example”).
Relationships and Data Flow
• How each Controller calls into specific Use Cases (business logic). For example, the simulation controller calls methods from the simulation use case to process investment models.
• That Use Cases interact with the Entities, using them for data representation and business domain logic.
• Role of the Utility modules, which support the Use Cases with independent functionalities like fetching external data or formatting dates.
• If applicable, represent the queue component (e.g., in “src/queues/StockQueue.ts”) for managing asynchronous processing tasks, with annotations showing how tasks are pushed and processed.
Architectural Patterns and Design Principles
• That the overall design follows a layered/MVC approach: the separation of concerns between input (routes/controllers), processing (use cases), and data (entities/models).
• Asynchronous or distributed design elements such as the use of queues and caching (using Redis).
• Mention that the system likely follows strong modular principles with directories clearly demarcated by functional responsibilities, making it easier to extend or swap out components (for example, alternative data fetching methods).