Automated Action 2c6298ca4b Implement fintech payment service backend with FastAPI and SQLite
- Set up project structure with FastAPI
- Implement user and account management
- Add send and receive money functionality
- Set up transaction processing system
- Add JWT authentication
- Configure SQLAlchemy with SQLite
- Set up Alembic for database migrations
- Create comprehensive API documentation
2025-06-17 11:53:41 +00:00
2025-06-17 11:43:41 +00:00

Fintech Payment Service

A FastAPI backend for fintech payment services, providing APIs for users, accounts, and money transfer operations.

Features

  • User Management: Create and manage user accounts
  • Account Management: Create and manage financial accounts
  • Transaction Processing:
    • Send money to external accounts
    • Receive money from external sources
    • Make internal transfers between accounts
    • View transaction history
  • Security: JWT authentication for secure API access

Tech Stack

  • Framework: FastAPI
  • Database: SQLite
  • ORM: SQLAlchemy
  • Migrations: Alembic
  • Authentication: JWT (JSON Web Tokens)
  • Password Hashing: Bcrypt

API Endpoints

Authentication

  • POST /api/v1/login/access-token - Get access token

Users

  • POST /api/v1/users/ - Create a new user
  • GET /api/v1/users/me - Get current user info
  • PUT /api/v1/users/me - Update current user info
  • GET /api/v1/users/{user_id} - Get user by ID

Accounts

  • GET /api/v1/accounts/ - List user accounts
  • POST /api/v1/accounts/ - Create a new account
  • GET /api/v1/accounts/{account_id} - Get account details
  • PUT /api/v1/accounts/{account_id} - Update account details
  • DELETE /api/v1/accounts/{account_id} - Delete an account

Transactions

  • GET /api/v1/transactions/ - List user transactions
  • GET /api/v1/transactions/account/{account_id} - List account transactions
  • POST /api/v1/transactions/deposit - Create a deposit
  • POST /api/v1/transactions/withdrawal - Create a withdrawal
  • POST /api/v1/transactions/transfer - Transfer between accounts
  • POST /api/v1/transactions/receive - Receive money from external source
  • POST /api/v1/transactions/send - Send money to external destination
  • GET /api/v1/transactions/{transaction_id} - Get transaction details

Health Check

  • GET /api/v1/health - Check API health

Setup Instructions

Prerequisites

  • Python 3.8+
  • pip

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd fintechpaymentservice
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Set up environment variables:

    # Create a .env file with the following variables
    SECRET_KEY=your_secret_key_here
    ALGORITHM=HS256
    ACCESS_TOKEN_EXPIRE_MINUTES=30
    
  4. Run database migrations:

    alembic upgrade head
    
  5. Start the server:

    uvicorn main:app --reload
    
  6. Access the API documentation:

Usage Examples

Create a User

curl -X POST "http://localhost:8000/api/v1/users/" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "password": "securepassword"
  }'

Get Access Token

curl -X POST "http://localhost:8000/api/v1/login/access-token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=user@example.com&password=securepassword"

Create an Account

curl -X POST "http://localhost:8000/api/v1/accounts/" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "account_type": "savings",
    "currency": "USD"
  }'

Receive Money

curl -X POST "http://localhost:8000/api/v1/transactions/receive" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "receiver_account_id": 1,
    "external_sender_info": "Bank XYZ - Account 12345",
    "amount": 500.00,
    "currency": "USD",
    "description": "Salary payment"
  }'

Send Money

curl -X POST "http://localhost:8000/api/v1/transactions/send" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "sender_account_id": 1,
    "external_receiver_info": "Bank ABC - Account 67890",
    "amount": 100.00,
    "currency": "USD",
    "description": "Utility bill payment"
  }'

Development

Running Tests

pytest

Code Linting

ruff check .

Code Formatting

ruff format .
Description
Project: Fintech Payment Service
Readme 51 KiB
Languages
Python 99.1%
Mako 0.9%