A service for client verification and order processing with Binance integration. Includes a survey system for preliminary client assessment and integration with an external KYC provider.
- Binance API Integration
- Client Assessment Survey System
- External KYC Provider Integration
- FastAPI REST API
- Asynchronous Request Processing
The service provides APIs for:
- Verifying order existence in Binance
- Client verification through KYC provider
- Managing client surveys
- Storing and processing client data
-
Order Verification
- Validate order existence in Binance
- Extract client data from orders
- Automatic registration of new clients
-
Client Verification
- KYC provider integration
- Survey system for preliminary assessment
- Verification status tracking
- Backend: Python 3.11, FastAPI
- Database: PostgreSQL, SQLAlchemy, Alembic
- Containerization: Docker, Docker Compose
- CI/CD: GitLab CI
- Testing: pytest
- Linting: flake8, black, isort
- Python 3.11+
- PostgreSQL
- Docker and Docker Compose (optional)
- Clone the repository:
git clone https://gitlab.com/aheads-group/fast-api.git
cd fast-api- Create virtual environment:
python -m venv venv
source venv/bin/activate # Linux/MacOS
# or
.\venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Configure environment variables:
cp .env.example .env
# Edit .env file with appropriate values- Build and run containers:
docker-compose up -dMain settings in .env:
# PostgreSQL
POSTGRES_SERVER=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=kyc_service
# API Keys
BINANCE_API_KEY=your_binance_api_key
BINANCE_API_SECRET=your_binance_api_secret
KYC_PROVIDER_API_KEY=your_kyc_provider_api_key
KYC_PROVIDER_API_URL=https://api.kyc-provider.com
# Security
JWT_SECRET_KEY=your_secret_key
JWT_ALGORITHM=HS256GET /api/v1/public/check-order/{order_id}Verifies order existence and client verification requirements
GET /api/v1/public/surveyReturns active survey for client
POST /api/v1/public/survey/submitAccepts survey responses and initiates KYC verification
POST /api/v1/webhooks/kyc-webhookProcesses verification results from KYC provider
# Run all tests with coverage report
pytest --cov=app
# Run specific test
pytest tests/api/test_public.py -v# Style check
flake8 app
# Formatting
black app
# Import sorting
isort app# Create new migration
alembic revision --autogenerate -m "Description"
# Apply migrations
alembic upgrade headThe project uses GitLab CI/CD with the following stages:
- Code linting
- Running tests
- Docker image building
- Deployment (manual trigger)
app/
├── alembic/ # DB migrations
├── api/ # API endpoints
│ └── v1/
│ ├── endpoints/
│ │ ├── public.py # Public endpoints
│ │ └── webhooks.py # Webhooks
├── core/ # Application core
│ ├── config.py # Configuration
│ └── logger.py # Logging settings
├── db/ # Database
│ ├── base.py # Base DB classes
│ └── session.py # Session management
├── models/ # SQLAlchemy models
│ ├── client.py # Client model
│ ├── profile.py # Profile model
│ ├── survey.py # Survey models
│ └── verification.py # Verification model
├── schemas/ # Pydantic schemas
├── services/ # Business logic
└── tests/ # Tests
- All HTTP requests are logged with execution time
- Errors are automatically written to log files
- Log rotation configured through RotatingFileHandler
- Endpoint response time
- Verification status
- Successful/failed request count
- Critical error notifications
- Service status monitoring via /health endpoint
- Check existing issues in GitLab
- Create new issue with problem description:
- Steps to reproduce
- Expected behavior
- Actual behavior
- Logs and screenshots (if available)
- Fork the repository
- Make changes in a separate branch
- Ensure all tests pass
- Create Merge Request