How fintoc-com/fintoc-node works
Project Overview and Purpose
• This project is an SDK that provides a natural, API-parallel interface for interacting with the Fintoc API. Its purpose is to make it simple to manage resources such as links, payment intents, webhook endpoints, and the various sub-resources (accounts, movements, invoices, tax returns, etc.) following Fintoc’s API structure.
• The design is built in TypeScript targeting Node.js (requiring Node 10+), and it is structured to mimic the API endpoints as closely as possible, with “manager” objects for CRUD operations.
Main Components
a. Fintoc Client Object:
• Central entry point of the SDK.
• Responsible for holding references to the various managers (e.g., links, paymentIntents, webhookEndpoints).
b. Manager Components:
• Each manager (located under src/lib/managers) corresponds to a set of API operations for a specific resource.
• Examples include accountsManager, invoicesManager, linksManager, etc.
• The managers generally provide methods such as “all”, “get”, “create”, “update”, “delete” and are sometimes “attached” to a resource (for example, a Link object exposing an accounts manager).
c. Resource Components:
• These are representations of Fintoc entities (resources) such as Link, Account, Movement, etc.
• Each resource encapsulates its data and operations like “update” or “delete” (often by delegating to the appropriate manager).
d. Mixins and Common Functionality:
• The SDK uses mixins (both managerMixin and resourceMixin) for sharing common patterns and code across managers and resources.
• This modular design allows for code reusability for actions such as serialization and error handling.
e. Supporting Utilities and Types:
• Helper functions (in src/lib/utils.ts) and TypeScript interfaces (in src/interfaces and src/types) define consistent contracts across the system.
• They ensure proper serialization, API request construction, and error mapping.
f. Testing Framework:
Relationships and Interactions
• Links Manager
• PaymentIntents Manager
• WebhookEndpoints Manager
• Within the Links Manager, include subordinate managers (as branches) such as:
• Invoices Manager
• TaxReturns Manager
• Subscriptions Manager
• RefreshIntents Manager
• Accounts Manager (which itself connects to the Movements Manager)
Architectural Patterns and Design Principles
• That the SDK mirrors the RESTful design of the Fintoc API, making use of:
• Composition: The client is composed of many managers.
• Delegation: Resource objects delegate operations to their corresponding manager.
• Asynchronous operation: Indicate that the “all” method returns an async generator.
• Extensibility via mixins: Common logic is reused across different managers and resources.
• A third for shared utilities and mixins.