This repository is a NestJS application organized around a small set of focused modules:
ConfigModulevalidates and structures runtime configuration.IdempotencyModulededuplicates replayable requests and stores cached responses.WalletsModulemanages in-memory balance updates.ActivityFeedModulestores and serves audit-style activity records.
flowchart LR
AppModule["AppModule"] --> ConfigModule["ConfigModule"]
AppModule --> TypeOrmModule["TypeOrmModule"]
AppModule --> BullModule["BullModule"]
AppModule --> IdempotencyModule["IdempotencyModule"]
AppModule --> WalletsModule["WalletsModule"]
WalletsModule --> ActivityFeedModule["ActivityFeedModule"]
IdempotencyModule --> TypeOrmModule
IdempotencyModule --> ScheduleModule["ScheduleModule"]
ActivityFeedModule --> TypeOrmModule
The repository currently does not ship a full auth module, but the expected request flow is:
flowchart LR
Client["Client"] --> Api["API request"]
Api --> JwtGuard["Auth guard / JWT validation"]
JwtGuard --> UserContext["Authenticated user context"]
UserContext --> Controllers["Controllers"]
Controllers --> Services["Services"]
Wallet balance changes and related activity events follow the same general lifecycle:
sequenceDiagram
participant Client
participant WalletsController
participant WalletsService
participant ActivityFeedService
participant Database
Client->>WalletsController: Adjust balance request
WalletsController->>WalletsService: adjustBalance(...)
WalletsService->>Database: Update balance state
WalletsService->>ActivityFeedService: recordActivity(...)
ActivityFeedService->>Database: Persist activity event
WalletsService-->>Client: Updated balance
- Idempotency first: replayable requests are cached so duplicate submissions can reuse a safe response.
- Event-driven hooks: balance changes emit activity records so the feed stays in sync with business events.
- Structured feed items: the activity feed returns consistent fields (
timestamp,type,description,ipAddress,deviceInfo,securityEvent) for UI rendering. - Configuration validation: environment values are validated at startup to fail fast on bad deployment settings.
- Modular boundaries: each domain area stays in its own Nest module to keep growth manageable.