This API allows the creation and management of user wallets. The project follows a clean architecture with layers for controllers, services, repositories, and models. All data is stored in-memory, ensuring fast development cycles and easy testing.
Thread-safe operations are used to manage concurrent fund updates, and all services are injected using dependency injection for flexibility and testability.
The API exposes endpoints for wallet actions such as:
Each request is validated for correctness. For example, adding or removing funds requires a valid positive amount and an existing wallet ID. Error responses are wrapped with a consistent exception filter for API clarity.
Sample cURL request:
curl --location 'https://localhost:44388/api/wallet/create' \
--header 'Content-Type: application/json' \
--data '{"UserId": "user123", "Currency": "EUR"}'
In real-world use cases, this structure can be extended with persistent storage, such as SQL Server or MongoDB, and connected to a distributed cache like Redis.
While this project uses in-memory storage for simplicity, the following would be required for production readiness: