Swipe is a production-ready backend for digital wallets, card issuing, invoicing, and notifications. The service is built with Flask, secured with JWT, supports TOTP 2FA, integrates Stripe for payments, and ships with a polished Swagger UI plus a curated Postman collection.
- Features
- Architecture
- Requirements
- Setup
- Running the Application
- Live Demo
- Docker
- Environment Variables
- Database Migrations
- API Documentation
- Testing
- Tooling & Integrations
- Contributing
- License
- Contact
- Authentication & Security: JWT auth, password reset emails, and full TOTP-based two-factor authentication with backup codes (
app/routes/auth.py,app/routes/two_factor_auth.py). - Accounts & Wallets: Multi-currency accounts, balance aggregation, FX rates with margin controls (
app/routes/account.py). - Virtual Cards & Spending: Card issuance, card funding, transaction history, Stripe payment method linking, and spending limits (
app/routes/card.py,app/routes/card_payments.py). - Invoices & Payments: Invoice lifecycle management, Stripe Checkout sessions, hosted payment redirects, and status tracking (
app/routes/invoice.py,app/routes/invoice_payments.py,app/routes/payment_redirects.py). - Notifications: In-app and email notifications, preference management, bulk broadcast tooling, and admin maintenance endpoints (
app/routes/notifications.py,app/routes/admin_notifications.py). - Documentation & Testing Utilities: Swagger UI served via
app/swagger.py, Postman collectionSwipe.json, and scripts for exercising 2FA and webhook flows. - Landing Experience: Responsive marketing page at the root route highlighting the product (
app/routes/base_route.py).
swipe/
βββ app/
β βββ __init__.py
β βββ config/
β βββ docs/ # Swagger resource declarations
β βββ models/
β βββ routes/
β βββ schema/
β βββ services/
β βββ utils/
β βββ extensions.py
β βββ swagger.py
βββ migrations/
βββ run.py # Dev/prod entry point (Flask vs Waitress)
βββ requirements.txt
βββ Swipe.json # Postman collection
βββ NOTIFICATION_SYSTEM.md # Deep dive documentation
βββ README.md
- Python 3.10+
- Virtualenv / Conda
- SQLite (default) or PostgreSQL for production
- Stripe test keys for payment flows
-
Clone
git clone https://github.com/yourusername/swipe.git cd swipe -
Create virtual environment
python3 -m venv .venv source .venv/bin/activate -
Install dependencies (pinned in
requirements.txt)pip install -r requirements.txt
-
Environment files
cp .env.example .env
Populate
.envusing the variables listed below.
-
Development (Flask auto-reload)
source .venv/bin/activate export FLASK_ENV=development python run.py
-
Production-like (Waitress WSGI server)
source .venv/bin/activate export FLASK_ENV=production export HOST=0.0.0.0 export PORT=8000 python run.py
Waitress is bundled via
waitress==3.0.2after the dependency freeze.
Application default URL: http://127.0.0.1:5000
- Landing Page: https://swipe-bczl.onrender.com
- Swagger Docs: https://swipe-bczl.onrender.com/docs
This Render deployment mirrors the configuration described above and provides quick access to the marketing site and interactive API documentation.
-
Build & Run
docker compose up --build
-
Teardown
docker compose down
The Compose setup runs a single container (swipe-web) using SQLite for storage. On boot, docker-entrypoint.sh loads .env, applies flask db upgrade, and then launches the server via run.py.
Tip: SQLite stores its database file inside the mounted project directory (default
swipe.db). If you need a clean start, remove that file before restarting the container. To switch to Postgres later, add a database service todocker-compose.ymland setDATABASE_URLaccordingly beforedocker compose up.
| Key | Purpose |
|---|---|
SECRET_KEY |
Flask secret key for sessions and JWT signing |
DATABASE_URL |
SQLAlchemy URI (sqlite:///swipe.db or PostgreSQL URI) |
JWT_SECRET_KEY |
JWT signing key (fallbacks to SECRET_KEY if omitted) |
STRIPE_SECRET_KEY / STRIPE_PUBLISHABLE_KEY |
Stripe integration |
MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD, MAIL_USE_TLS |
Email delivery |
NOTIFICATION_BROADCAST_LIMIT |
Safety guard for admin broadcasts |
FRONTEND_BASE_URL |
Used by payment redirect routes |
FX_API_KEY |
Optional foreign exchange API key |
Consult .env.example for the full list plus sensible defaults.
flask db upgrade
# Create new migration
flask db migrate -m "describe change"
flask db upgradeInitial migrations live in migrations/versions/.
- Swagger UI: visit
http://127.0.0.1:5000/docs/ - Namespaces: Authentication, Accounts, Wallets, Transactions, Cards, 2FA, Invoices, Invoice Payments, Notifications, Admin Notifications.
- Postman: Import
Swipe.jsonfor preconfigured environments covering 2FA, invoice, payment, and webhook flows.
Helper scripts: direct_2fa_test.py, test_endpoint.py, test_webhook.py demonstrate common workflows.
source .venv/bin/activate
pytestTargeted smoke scripts also live at the project root for manual verification.
- Flask ecosystem: Flask, Flask-JWT-Extended, Flask-Migrate, Flask-SQLAlchemy, Flask-Mail, Flask-RESTX.
- Data & Serialization: Marshmallow, Marshmallow-SQLAlchemy.
- Payments: Stripe SDK, custom
PaymentService(app/services/payment_service.py). - Notifications: Email + in-app via
NotificationServiceandEmailService. - Security: Passlib for hashing, PyOTP for TOTP, quiet-hours aware notification settings.
- Production: Waitress WSGI server; configurable host/port via environment variables.
Pinned dependencies are maintained through pip freeze (see requirements.txt).
- Fork the repository
- Create a feature branch (
git checkout -b feature-name) - Commit changes (
git commit -m "feat: add awesome thing") - Push and open a pull request
Please include tests and Swagger doc updates where relevant.
This project is licensed under the MIT License.
- Project Lead: Onyedikachi Onu
- Email: okc4pardon@gmail.com
- GitHub: github.com/St-Pardon