/cute-bank

Primary LanguageElixir

Cute Bank

Getting Started

  1. Clone and Install
    • Clone the repository and install the required dependencies.
git clone git@github.com:hnrbs/cute-bank.git
mix deps.get
  1. Build Containers
    • Set up your database configuration and any environment-specific settings.
docker-compose up -d
  1. Database Migration
    • Run database migrations to create the necessary tables.
mix ecto.create
mix ecto.migrate
  1. Running the Application
    • Start the application and ensure it's accessible.
mix phx.server

Authentication

Authentication is required for some of the endpoints. Make sure to include appropriate authentication tokens in your requests when accessing protected routes.

API Endpoints

Health Check

  • GET /api/health_check
    • Endpoint for checking the health status of the system.

User Management

  • POST /api/user/create
    • Create a new user account.
{
  "user": {
    "first_name": "John",
    "last_name": "Doe",
    "cpf": "000.000.000-00",
    "password": "s3cure_pa$sword",
  }
}
  • POST /api/user/login
    • Log in an existing user.
{
  "cpf": "000.000.000-00",
  "password": "s3cure_pa$sword"
}

Transaction Management

  • POST /api/transaction/search
    • Search for transactions between a date range.
{
   "start_date": "2023-10-26T12:23:19Z"
   "end_date": "2023-10-27T15:29:19Z"
}
  • POST /api/transaction/create
    • Create a new transaction.
{
  "transaction": {
    "amount": 5000,
    "receiver_cpf": "000.000.000-00",
  }
}
  • POST /api/transaction/refund
    • Initiate a refund for a transaction.
{
  "transaction_id": "01ec23e3-6a91-4a0a-9b01-291b27f6ee3f"
}
  • GET /api/transaction
    • Retrieve a list of transactions.

Balance Management

  • POST /api/balance/withdraw
    • Withdraw funds from a user's balance.
{
  "amount": 5000
}
  • POST /api/balance/deposit
    • Deposit funds into a user's balance.
{
  "amount": 5000
}
  • GET /api/balance

    • The logged user's balance is displayed.
  • GET /api/balance/check

    • Check if the user's balance is valid based on the sum of the user transactions.