Repository navigation
feat: add wallets model - #41
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Wallet domain model with persistence (in-memory + PostgreSQL) and wires automatic default wallet creation into the user registration flow, including a DB migration and test updates to validate the behavior.
Changes:
- Added
Walletentity plus wallet repository interface and implementations (Postgres + in-memory). - Added migration to create the
walletstable, including indexes/constraints. - Updated user creation flow (and tests) to create a default wallet for each new user.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/entities/wallet/wallet.entity.ts | Introduces the Wallet domain entity and its properties. |
| src/repositories/wallets/wallets.repository.interface.ts | Defines wallet persistence contract (save, findByUserId). |
| src/repositories/wallets/wallets-in-memory.repository.ts | Adds in-memory wallet persistence for tests/local usage. |
| src/repositories/wallets/wallets-postgres.repository.ts | Adds PostgreSQL wallet persistence using DatabaseService. |
| src/infra/database/migrations/1784669759347_create-wallets-table.js | Creates the wallets table and related indexes/constraints. |
| src/repositories/providers.enum.ts | Adds DI token for wallets repository. |
| src/models/users/users.module.ts | Registers WalletsPostgresRepository provider in Users module. |
| src/models/users/use-cases/create-user/create-user.service.ts | Creates a default wallet during user registration. |
| src/models/users/use-cases/create-user/create-user.service.spec.ts | Extends create-user test to assert wallet creation and fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
daniloamsilva
force-pushed
the
feat/add-wallets-model
branch
from
July 22, 2026 02:19
141f4b3 to
e671104
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new Wallet domain model and integrates wallet creation into the user registration flow. It adds the necessary entity, repository interfaces and implementations (in-memory and PostgreSQL), a migration for the
walletstable, and updates the user creation logic and tests to ensure each new user receives a default wallet.Wallet Domain Model and Persistence
Walletentity with properties such asuserId,name,initialBalance,isDefault, and timestamps (createdAt,updatedAt,deletedAt). (src/entities/wallet/wallet.entity.ts)WalletsRepositoryInterface) and both in-memory and PostgreSQL implementations for wallet persistence. (src/repositories/wallets/wallets.repository.interface.ts,src/repositories/wallets/wallets-in-memory.repository.ts,src/repositories/wallets/wallets-postgres.repository.ts) [1] [2] [3]walletstable with relevant fields, constraints, and indexes, including a unique constraint for default wallets per user. (src/infra/database/migrations/1784669759347_create-wallets-table.js)User Creation Flow Updates
CreateUserServiceto inject theWalletsRepositoryInterfaceand automatically create a default wallet ("Carteira") for each new user during registration. (src/models/users/use-cases/create-user/create-user.service.ts,src/models/users/users.module.ts,src/repositories/providers.enum.ts) [1] [2] [3] [4] [5] [6]Testing Enhancements
src/models/users/use-cases/create-user/create-user.service.spec.ts) [1] [2] [3]