Financial Application is a Python-based banking application that demonstrates the implementation of common banking operations using a layered backend architecture, asynchronous database access, SQLAlchemy and MySQL.
The project separates application workflows, business logic, persistence, models, DTOs, infrastructure and utility components to keep responsibilities organized and maintainable.
- Customer management
- Staff management
- User management
- Account ownership and customer relationships
- Authentication service
- Active account and user validation
- Create and manage customer accounts
- Support different account types
- Retrieve accounts by user
- Retrieve account details by account number
- Track individual account balances
- Calculate total balances across customer accounts
- Fund customer accounts
- Transfer funds between accounts
- Validate sender and receiver accounts
- Prevent transfers with insufficient funds
- Prevent transfers to the same account
- Record debit and credit sides of transfers
- Maintain transaction status, type, and mode
- Retrieve customer transaction history
- Filter transactions by different criteria
- Paginated transaction retrieval
- Python
- SQLAlchemy
- SQLAlchemy AsyncIO
- MySQL
- PyMySQL
- aiomysql
- Alembic
- python-dotenv
- asyncio
The repository is organized into separate layers:
Financial_Application
│
├── Application
│ ├── AccountApplication.py
│ ├── AccountTypesApplication.py
│ ├── CustomerApplication.py
│ ├── StaffApplication.py
│ └── TransactionApplication.py
│
├── ApplicationProcessing
│ ├── ProcessAccount.py
│ └── ProcessTransaction.py
│
├── Dtos
│ └── Request and response models
│
├── Infrastructure
│ └── Application constants and infrastructure configuration
│
├── Repository
│ └── Database access and persistence operations
│
├── Service
│ ├── AccountService.py
│ ├── AccountTypeService.py
│ ├── AuthenticationService.py
│ ├── CustomerService.py
│ ├── StaffService.py
│ ├── UserService.py
│ └── transaction_service.py
│
├── SqlQueries
│ └── SQL-related functionality
│
├── Utility
│ └── Shared application utilities
│
├── models
│ ├── User
│ ├── Customer
│ ├── Staff
│ ├── Account
│ ├── Account Type
│ ├── Transaction
│ ├── Transaction Type
│ ├── Transaction Mode
│ ├── Transaction Status
│ └── Role
│
├── alembic
│ └── Database migration files
│
├── database_orm.py
├── database_orm_async.py
└── main.py
The structure separates application orchestration from business services and persistence logic.
The application uses MySQL with SQLAlchemy.
Both synchronous and asynchronous database configurations are included in the repository, while the asynchronous implementation uses SQLAlchemy's AsyncSession and the aiomysql MySQL driver.
Database configuration is loaded from environment variables.
Expected variables include:
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=localhost
DB_PORT=3306
DB_NAME=your_database_name
The application uses Python's asynchronous programming model for database operations.
The asynchronous database layer creates an SQLAlchemy async engine and manages sessions using AsyncSession.
This allows database operations to be performed without blocking the application's execution flow.
Transactions are handled through the service and repository layers.
When an account is funded, the application:
- Retrieves the account.
- Validates the account and associated user.
- Updates the account balance.
- Creates a credit transaction.
- Records the transaction as completed.
A transfer involves two accounts.
The application:
- Retrieves the sender account.
- Verifies that the sender is active.
- Checks that sufficient funds are available.
- Retrieves the receiver account.
- Ensures the sender and receiver are different.
- Debits the sender.
- Credits the receiver.
- Creates corresponding debit and credit transaction records.
The balance updates and transaction creation are performed within the same database transaction.
The application can retrieve transaction history associated with users and accounts.
Transactions can also be filtered using information such as:
- Account
- Account type
- Transaction type
- Transaction mode
- Transaction status
Pagination support is available for retrieving larger collections of transactions.
The domain model includes entities representing:
- Users
- Customers
- Staff
- Roles
- Accounts
- Account types
- Transactions
- Transaction types
- Transaction modes
- Transaction statuses
These models are mapped to the relational database through SQLAlchemy.
Database operations are separated from the business logic through repository classes.
The service layer communicates with repositories instead of embedding persistence operations directly into application workflows.
This provides a clearer separation between:
Application
↓
Application Processing
↓
Services
↓
Repositories
↓
SQLAlchemy
↓
MySQL
Alembic is included for managing changes to the database schema.
The repository contains:
alembic/
alembic.ini
which can be used to maintain database migrations as the models evolve.
Clone the repository:
git clone https://github.com/Slimcent/Financial_Application.git
cd Financial_ApplicationCreate a .env file containing the required MySQL configuration:
DB_USER=your_database_user
DB_PASSWORD=your_database_password
DB_HOST=localhost
DB_PORT=3306
DB_NAME=your_database_name
Make sure the required Python packages and a MySQL database are available.
Run the application with:
python main.py
The current entry point executes the asynchronous application workflow using asyncio.
This project demonstrates several backend software engineering concepts:
- Python asynchronous programming
- Layered application architecture
- Object-oriented programming
- Repository pattern
- Service layer pattern
- SQLAlchemy ORM
- Asynchronous SQLAlchemy sessions
- Relational database modeling
- MySQL integration
- Environment-based configuration
- Database transactions
- Account balance management
- Financial transaction processing
- Data transfer objects
- Pagination and filtering
- Database migrations with Alembic
This project is a banking application prototype focused primarily on backend architecture, persistence, account management and financial transaction workflows.
It serves as a practical implementation of Python backend development concepts and relational database design.
Obinna Vincent Achara
GitHub: @Slimcent