How albertobas/bank-microservices works
Project’s Type and Purpose
• The project is a full-scale bank application that uses a microservices architecture.
• Its purpose is to manage banking operations like creating, updating, and deleting accounts, customers, and loans; integrating on-chain data via smart contracts; running predictive analytics on loan defaults; and exposing data via APIs and GraphQL.
• As stated in the README, it leverages multiple technologies (MERN stack for front-end, Express.js and Flask for back-end, Solidity smart contracts, ML pipelines with scikit-learn, and TheGraph for blockchain data querying). This ensures you capture both traditional web service components as well as blockchain and machine learning components.
File Structure for Architectural Components
• The top-level directories include:
• packages/: Contains shared npm packages (utilities, logger, ESLint configs, and common TypeScript configurations) used across various microservices.
• services/: Contains the microservices. Several distinct services are evident:
▸ services/accounts: Contains Express API logic (controllers, interactors, repositories), Docker configuration, and Mongo initialization scripts.
▸ services/requests: Defines operations for handling requests.
▸ services/client: Contains the front-end Next.js application, including UI components and feature-specific code.
▸ Other supporting services (like graph-node and loans-model) add components such as a local GraphQL node and Python-powered loan prediction models.
• Each microservice typically follows a hexagonal architecture:
• Controllers (API entry points) forward requests to business logic (interactors/core) which interfaces with data sources (repositories, data-sources) to read or write information.
• Infrastructure components like Docker configuration files (Dockerfile, docker-compose.yaml) and environment templates indicate containerized deployment.
a. Main Components:
• Front-end Application: The Next.js based client found under services/client.
• Back-end Microservices: Separate services for accounts, customers, loans, and requests. Each service has API controllers, core interactors, and repository/data-source layers.
• Shared Packages: Common libraries (bank-utils, logger, custom ESLint configurations, tsconfigs) that are used across services.
• ML & Prediction Component: The loans-model service which includes Python components, Jupyter notebooks, and ML pipelines (integrating scikit-learn and PyTorch).
• Infrastructure & Orchestration: Docker Compose definitions, Dockerfiles for each service, and environment configuration files.
• Data Storage and Query Services: MongoDB (for persistent data storage), and TheGraph/graph-node for querying chain data.
b. Relationships and Interactions:
• The front-end interacts with back-end services via RESTful APIs (and possibly GraphQL for chain querying).
• Each microservice encapsulates its own domain (accounts, customers, loans, requests), with defined interactions:
• API Controllers feed into interactors (hexagonal architecture) which in turn interact with repositories.
• Data sources for MongoDB are invoked at the repository level.
• The loans-model service acts as a backend analytics engine that interfaces with loan data and potentially sends predictions to the user interface.
c. Important Architectural Patterns:
• Microservices Architecture: Each service is containerized and communicates over defined API boundaries.
• Hexagonal Architecture: Separation between the core business logic (interactors) and the infrastructure (controllers, repositories).
• Separation of Concerns: Front-end, back-end, smart contracts, and machine learning components are clearly separated.
• CI/CD Integration: Presence of linting (eslint, prettier), commit hooks (husky), and automated deployment signals a disciplined development pipeline.
d. Relevant Technologies:
• Front-end: Next.js, React, TypeScript.
• Back-end: Express.js (TypeScript), Flask (Python), RESTful APIs.
• Data Storage: MongoDB.
• ML: scikit-learn, PyTorch, Skorch.
• Infrastructure: Docker (Docker Compose), pnpm-managed workspace.
Elements
• Drill down into each microservice if needed, showing internal separations (API controllers, interactors, repositories).
• Infrastructure elements such as Docker Compose orchestration and shared configuration under packages.
• Major components from the file tree and mentioned in the README are represented and their interactions depicted.