FalconWallet is a backend service built with ASP.NET Core, specifically designed to handle e-commerce digital wallets. It uses Vertical Slice Architecture to keep the code organized and easy to maintain.
- Create and Manage Currencies: Add new currencies and update their conversion rates.
- Wallet Management: Create, suspend, and update wallets.
- Transaction Handling: Deposit, withdraw, and track wallet transactions.
- Atomic Transactions: Ensure transactional integrity with atomic operations.
- Framework: ASP.NET Core
- Database: SQL Server
- API Design: Minimal APIs
- Validation: Fluent Validation
- Object Mapping: AutoMapper
- Containerization: Docker
- Container Orchestration: Docker Compose
- .NET SDK 8: Ensure you have the latest .NET SDK installed.
-
Clone the Repository:
git clone https://github.com/emaadgh/FalconWallet.git
-
Install Dependencies:
- Open a terminal and navigate to the project folder:
cd FalconWallet
- Restore dependencies:
dotnet restore
- Open a terminal and navigate to the project folder:
-
Run the Application:
- Start the API by running the following command in your terminal:
dotnet run
- Start the API by running the following command in your terminal:
-
Database Migration:
- After building the project, run the following command to create or update the database based on migration files:
If you don't have the Entity Framework Core tools (
dotnet ef database update
dotnet ef
) installed globally, you can install them by running the following command:dotnet tool install --global dotnet-ef
- After building the project, run the following command to create or update the database based on migration files:
-
Access the API:
- By default, the API will be hosted on
localhost
with a randomly assigned port. You can access the API using the following URL format:https://localhost:<PORT>/api
- Replace
<PORT>
with the port number assigned to the API during startup.
- By default, the API will be hosted on
-
Explore the API:
- Once the API is running, you can use tools like Swagger or Postman to interact with the endpoints.
- Visit the Swagger UI at
https://localhost:<PORT>/swagger/index.html
to explore the API documentation interactively.
The FalconWallet can be easily containerized using DockerFile and Docker Compose to orchestrate multiple containers. Docker provides a consistent environment across different systems, making deploying and managing applications easier.
To Dockerize the FalconWallet and run it with Docker Compose, follow these steps:
- Ensure you have Docker installed on your system.
- Navigate to the root directory of the FalconWallet project.
- Create a
.env
file beside thedocker-compose.yml
file. - Add the following environment variable to the
.env
file:
SA_PASSWORD=preferedpassword
Replace preferedpassword
with your preferred SQL Server SA password.
Please note that appsettings.json
files are not included in the Git repository. These files typically contain sensitive information such as database connection strings, API keys, and other configuration settings specific to the environment.
For local testing, you can create your own appsettings.json
file in the root directory of the FalconWallet project and add the necessary configurations.
{
"ConnectionStrings": {
"WalletDbContextConnection": "Server=(localdb)\\MSSQLLocalDB;Initial Catalog=FalconWalletDB;Integrated Security=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
For testing purposes, you can add the following code snippet to your Program.cs
file. This code will reset the database and its data every time the application is run:
using (var scope = app.Services.CreateScope())
{
try
{
var context = scope.ServiceProvider.GetService<WalletDbContext>();
if (context != null)
{
await context.Database.EnsureDeletedAsync();
await context.Database.MigrateAsync();
}
}
catch (Exception ex)
{
// Handle any exceptions if necessary
}
}
Make sure to replace WalletDbContext
with your actual DbContext class if it's named differently.
Contributions are welcome! If you'd like to enhance FalconWallet, you can submit pull requests or open issues.
This project is licensed under the MIT License. Inspired by lessons from ThisIsNabi's live coding sessions.