A simple ASP.NET Web API project to manage user wallets using an in-memory data store. Supports wallet creation, fund addition, and withdrawal

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:

  • GET /api/wallet – Welcome message
  • POST /api/wallet/create – Create new wallet
  • GET /api/wallet/{id} – Retrieve wallet details
  • POST /api/wallet/{id}/add – Add funds
  • POST /api/wallet/{id}/remove – Withdraw funds

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.

Production Considerations

While this project uses in-memory storage for simplicity, the following would be required for production readiness:

  • Durable backend: SQL Server, MongoDB, or similar
  • Concurrency control: Optimistic/Pessimistic DB locking
  • Redis caching: Improve read performance
  • Retry/Circuit Breakers: Using libraries like Polly
  • Logging/Monitoring: Cloudwatch, Grafana, or Application Insights
  • Load balancing: Behind an ALB with Auto Scaling

Tools and Libraries

Image placeholder

Simone Riggi

Software engineer with 5 years of experience. Experienced in Desktop Apps, Web Apps, APIs development and interested in everything related to coding and web technologies.