How joinreinvest/reinvest-api works
Project Type and Purpose
• Recognize that this is a full-fledged API backend serving a sophisticated investment platform.
• It integrates many independent modules (each behaving like a microservice) with their own databases/migrations and communication channels.
• The API gateways (AdminApiGateway and ApiGateway) are the main entry points, and additional responsibilities (identity management, archiving, notifications, etc.) are housed in dedicated modules.
• Serverless functions and AWS integrations (e.g., Cognito for identity, SNS for notifications, Lambda functions for preSignUp, postSignUp, cron jobs, etc.) form an important part of the infrastructure.
Analyzing the File Structure
• Notice the top-level “Reinvest” folder that contains modules such as AdminApiGateway, ApiGateway, Archiving, Documents, Identity, InvestmentAccounts, Investments, LegalEntities, Notifications, Portfolio, Registration, Trading, etc. Each of these modules adheres to a consistent structure (migrations, src, and tests).
• Each module is isolated and usually has its own “infrastructure” (database adapters, repository implementations), “domain” (business rules and entities), and “application” (use case implementations).
a. Main Components:
• API Entry Points:
• API Gateway (GraphQL) and Admin API Gateway.
• Serverless functions (organized under devops/functions) serving as individual entry points for operations like preSignUp, postSignUp, cron jobs for sync and document generation, etc.
• Modules (each a microservice):
• Archiving, Documents, Identity, Inbox, InvestmentAccounts, Investments, LegalEntities, Notifications, Portfolio, Registration, Trading, SharesAndDividends, Verification, Withdrawals.
• Databases:
• Each module maintains its own PostgreSQL database (as signified by individual migrations and database adapters).
• External Services:
• AWS services: Cognito for user identity and authentication, SNS for notifications, S3 for file/document storage, VPC, SES for emails.
• Shared Infrastructure and Libraries:
• Shared libraries in the “shared” folder for logging, PostgreSQL connections, templates, and simple aggregator patterns.
• Client Interaction:
• Clients (Postman, API explorer) interact with the API gateways.
b. Relationships and Data Flow:
• Serverless functions as separate nodes that handle specific hooks (pre/post sign-up, cron jobs, migration operations) that assist in keeping financial operations, notifications, and synchronization tasks up-to-date.
• Relationship between the modules and the AWS environment (mentioning Cognito, S3, SNS, and Lambda) as well as CI/CD elements (e.g., GitHub workflows, serverless deployment commands).
c. Architectural Patterns:
• Clean Architecture / Hexagonal architecture pattern used in each module (with separation among domain, application, and infrastructure layers).
• Microservice/multi-module approach. Although not “share-everything,” modules communicate with each other via APIs and sometimes use queues or event handlers (for example, event-driven design is visible in the ‘EventHandler’ directories).
• Important role of dependency injection (hinted by the “getClassName” and “Module” interface definitions) and how modules are registered together in the system bootstrap.
d. Relevant Technologies and Frameworks:
• Node.js ecosystem with TypeScript.
• PostgreSQL driven by migrations in each module.
• AWS tools and serverless deployment (Cognito, Lambda, S3, SNS, CloudFormation/VPC).
• Docker Compose for local development.
• CI/CD processes using GitHub Actions, as indicated by the workflow files.
• GraphQL for the API gateways.
• Shared libraries indicate custom implementations for logging, PostgreSQL operations, and templating.
Summary Procedure for the Principal Software Engineer
• Serverless functions as separate nodes (with periodic tasks and hooks) that interact with both the API layer and the modules.