Skip to content

FalconWallet is an ASP.NET Core backend service for managing e-commerce digital wallets, using Vertical Slice Architecture

Notifications You must be signed in to change notification settings

emaadgh/FalconWallet

Repository files navigation

FalconWallet: E-commerce Digital Wallet Backend Service

Overview

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.

Features

  • 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.

Technology Stack

  • Framework: ASP.NET Core
  • Database: SQL Server
  • API Design: Minimal APIs
  • Validation: Fluent Validation
  • Object Mapping: AutoMapper
  • Containerization: Docker
  • Container Orchestration: Docker Compose

Diagrams

Currency Management

Transaction Handling

Wallet Management

Getting Started

Prerequisites

  • .NET SDK 8: Ensure you have the latest .NET SDK installed.

Installation

  1. Clone the Repository:

    git clone https://github.com/emaadgh/FalconWallet.git
  2. Install Dependencies:

    • Open a terminal and navigate to the project folder:
      cd FalconWallet
    • Restore dependencies:
      dotnet restore

Running the Application

  1. Run the Application:

    • Start the API by running the following command in your terminal:
      dotnet run
  2. Database Migration:

    • After building the project, run the following command to create or update the database based on migration files:
      dotnet ef database update
      If you don't have the Entity Framework Core tools (dotnet ef) installed globally, you can install them by running the following command:
      dotnet tool install --global dotnet-ef
  3. 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.
  4. 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.

Dockerizing with Dockerfile and Docker Compose

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:

  1. Ensure you have Docker installed on your system.
  2. Navigate to the root directory of the FalconWallet project.
  3. Create a .env file beside the docker-compose.yml file.
  4. Add the following environment variable to the .env file:
SA_PASSWORD=preferedpassword

Replace preferedpassword with your preferred SQL Server SA password.

AppSettings.json Configuration

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.

Example appsettings.json

{
  "ConnectionStrings": {
    "WalletDbContextConnection": "Server=(localdb)\\MSSQLLocalDB;Initial Catalog=FalconWalletDB;Integrated Security=true"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  }
}

Database Reset for Testing Purposes

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.

Creator

Contributing

Contributions are welcome! If you'd like to enhance FalconWallet, you can submit pull requests or open issues.

License

This project is licensed under the MIT License. Inspired by lessons from ThisIsNabi's live coding sessions.

About

FalconWallet is an ASP.NET Core backend service for managing e-commerce digital wallets, using Vertical Slice Architecture

Topics

Resources

Stars

Watchers

Forks