https://github.com/rakibhossain72/ctrip
cTrip Crypto Payment Gateway: multi-chain cryptocurrency payment gateway built with FastAPI
https://github.com/rakibhossain72/ctrip
cryptocurrency-payment-gateway fastapi payment-gateway web3py
Last synced: 2 months ago
JSON representation
cTrip Crypto Payment Gateway: multi-chain cryptocurrency payment gateway built with FastAPI
- Host: GitHub
- URL: https://github.com/rakibhossain72/ctrip
- Owner: rakibhossain72
- License: mit
- Created: 2024-02-02T12:30:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-23T21:24:25.000Z (4 months ago)
- Last Synced: 2026-02-24T04:18:18.282Z (4 months ago)
- Topics: cryptocurrency-payment-gateway, fastapi, payment-gateway, web3py
- Language: Python
- Homepage: https://ctrip-docs.readthedocs.io/
- Size: 2.57 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# cTrip Payment Gateway
cTrip is a high-performance, multi-chain cryptocurrency payment gateway built with FastAPI. It supports automated payment detection, confirmation monitoring, and funds sweeping across multiple EVM-compatible blockchains.
## Features
- **Multi-Chain Support**: Native support for BSC, Ethereum, and local testing environments (Anvil).
- **Automated Detection**: Real-time scanning of blockchain blocks to detect incoming payments.
- **Async Architecture**: Fully asynchronous API and database operations using SQLAlchemy and FastAPI.
- **Background Workers**: Async task processing using ARQ and Redis with built-in cron scheduling.
- **Secure Address Management**: HD Wallet integration for generating unique payment addresses.
- **Webhooks**: Automated notifications for payment status changes.
- **Migration System**: Robust database migrations using Alembic with a custom helper script.
## Tech Stack
- **Framework**: [FastAPI](https://fastapi.tiangolo.com/)
- **Database**: [PostgreSQL](https://www.postgresql.org/) / [SQLite](https://www.sqlite.org/) (Dev)
- **ORM**: [SQLAlchemy 2.0](https://www.sqlalchemy.org/)
- **Task Queue**: [ARQ](https://arq-docs.helpmanual.io/) with Redis
- **Blockchain**: [Web3.py](https://web3py.readthedocs.io/)
- **Migrations**: [Alembic](https://alembic.sqlalchemy.org/)
## Prerequisites
- Python 3.10+
- Docker & Docker Compose
- Redis (for background workers)
- PostgreSQL (for production)
## Configuration
1. Create a `.env` file from the environment template.
2. Configure your chains in `chains.yaml`.
3. Set your HD Wallet mnemonic in the environment variables.
## Quick Start
### Using Docker (Recommended)
```bash
docker-compose up --build
```
This will start the API, PostgreSQL, Redis, and background workers.
### Local Development
1. **Install Dependencies**:
```bash
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
2. **Run Migrations**:
```bash
python migrate.py upgrade
```
3. **Start the API**:
```bash
uvicorn server:app --reload
```
4. **Start Workers**:
```bash
python run_worker.py
```
## Project Structure
- `app/api/`: API endpoints and routes.
- `app/blockchain/`: Multi-chain implementation and Web3 logic.
- `app/db/`: Database models, schemas, and session management.
- `app/workers/`: Dramatiq actors for background tasks.
- `app/services/`: Core business logic for scanning and sweeping.
- `migrate.py`: Helper script for managing database migrations.
## Documentation
For more detailed information, see [Documentation](https://ctrip-docs.readthedocs.io/).
## License
This project is licensed under the terms included in the [LICENSE.txt](LICENSE.txt) file.