Skip to content

rcsofttech85/Fund-transfer-api

Repository files navigation

Funds Transfer Feature

This repository contains a funds transfer feature built with Symfony 7, PHP 8.4, Doctrine ORM, and Redis for caching and idempotency.

It demonstrates secure, idempotent, and concurrency-safe transfers between accounts.


Features

  • Account Balances: Each account's balance is accurately tracked in the database.
  • Transfers: Securely create a transfer from a source account to a destination account.
  • Idempotency: Repeated requests with the same idempotency key return the same, correct result, preventing accidental duplicate transfers.
  • Concurrency Safety: Prevents race conditions and double-spending using Symfony Lock component.
  • Database Transactions: Ensures atomicity and consistency of account balances during the transfer process.
  • Redis Caching: Utilized to store idempotency responses for enhanced performance and safety checks.

Architecture Diagram

Fund Transfer Architecture


Set up

Follow these steps to get the project running locally using Docker.

  1. Clone the Repository:
    git clone git@github.com:rcsofttech85/simple-payment-system.git
  2. Change Directory:
    cd simple-payment-system
  3. Container Set Up: Start the Docker containers (PHP, MYSQL, Redis).
    docker compose up -d
  4. Install Dependencies: Execute Composer within the PHP container.
    docker exec -it payment_php bash
    run composer install
  5. Database Set up (Create database, run migrations, load fixtures):
    bin/console doctrine:database:create --if-not-exists
    bin/console doctrine:migration:migrate
    bin/console hautelook:fixtures:load --no-interaction
  6. Generate JWT Key Pair:
    bin/console lexik:jwt:generate-keypair

Test Database Setup and Running Tests

To set up the test database and run the unit/functional tests, execute these commands:

APP_ENV=test bin/console doctrine:database:create --if-not-exists
APP_ENV=test   bin/console doctrine:migration:migrate
APP_ENV=test   bin/console hautelook:fixtures:load --no-interaction
APP_ENV=test bin/phpunit tests/

About

Simple funds transfer system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages