OfferHub is a purpose-built platform for financial services companies to create, manage, and optimize personalized offers. It enables banks and financial institutions to deliver targeted promotions that enhance customer engagement, drive retention, and fuel growth.
- 📊 Centralized dashboard for managing offers and promotions
- 🧩 Personalized offer creation tailored to customer segments
- 📈 Real-time monitoring of offer performance and conversion rates
- 🧠 Actionable insights to refine marketing strategies and outreach
Financial institutions leverage OfferHub to craft and deliver highly relevant offers that resonate with individual customers. This improves the overall customer experience and increases customer lifetime value (CLTV).
This repository contains a full-stack web application with the following components:
- 🐘 PostgreSQL – Relational database for storing offer data
- 🧠 FastAPI – Backend API service
- 🌐 Frontend App – User interface for managing offers
All services are containerized using Docker Compose.
Service | Description | Port |
---|---|---|
postgres-db | PostgreSQL database | 5432 |
backend-apis | FastAPI backend APIs | 8000 |
frontend-app | Frontend web client | 3000 |
Build and run all containers in the background:
docker-compose up -d --build
Or in the foreground:
docker-compose up --build
docker-compose down
docker-compose logs -f
dos2unix ./database-init/00-init-db.sh
-
Create a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up your PostgreSQL database.
-
Create a
.env
file from.env.example
and update theDATABASE_URL
andSECRET_KEY
.cp .env.example .env # Then edit .env
-
Initialize the database (if using Alembic, run migrations):
# (Assuming Alembic is set up) # alembic upgrade head
uvicorn app.main:app --reload
The API will be available at http://127.0.0.1:8000
.
- Swagger UI:
http://127.0.0.1:8000/docs
- ReDoc:
http://127.0.0.1:8000/redoc
The API follows RESTful principles and is organized into the following main sections:
POST /api/v1/auth/token
- OAuth2 compatible token loginGET /api/v1/auth/me
- Get current authenticated userPOST /api/v1/auth/change-password
- Change user's password
GET /api/v1/users/me
- Get current user profileGET /api/v1/users/me/tenants
- Get tenants and roles for current user
POST /api/v1/sa/tenants/
- Create new tenantGET /api/v1/sa/tenants/
- List all tenantsGET /api/v1/sa/tenants/{tenant_name}
- Get specific tenantPUT /api/v1/sa/tenants/{tenant_name}
- Update tenant detailsDELETE /api/v1/sa/tenants/{tenant_name}
- Delete tenant
POST /api/v1/sa/users/
- Create new userGET /api/v1/sa/users/
- List all usersGET /api/v1/sa/users/{username}
- Get specific userPUT /api/v1/sa/users/{username}
- Update user detailsDELETE /api/v1/sa/users/{username}
- Delete user
For complete API documentation, visit the Swagger UI at http://127.0.0.1:8000/docs
when the application is running.
A comprehensive test suite has been set up to test all API endpoints. Tests use pytest and are located in the tests/api/v1/
directory.
Run the tests directly with pytest:
pytest -xvs tests/api/v1/ --cov=app --cov-report=term-missing
This command will:
- Run all tests in the
tests/api/v1/
directory - Show verbose output (-v)
- Show each test case as it executes (-x)
- Show stdout for failed tests (-s)
- Generate a coverage report for the app directory (--cov=app)
- Show missing lines in the coverage report (--cov-report=term-missing)
The tests are organized by resource type:
test_auth.py
- Authentication endpoints (login, token verification)test_users.py
- User profile managementtest_tenants.py
- Tenant management and user-tenant relationshipstest_offers.py
- Offer creation, approval workflows, and management
When adding new API features, add corresponding tests by:
- Create a new test file in
tests/api/v1/
if testing a new resource - Use the existing fixtures from
conftest.py
for database access, authentication, etc. - Follow the pattern of existing tests for consistency
Tests use an in-memory SQLite database by default to keep tests isolated and fast.