LedgerGuard is a production-minded fraud detection and transaction categorisation system for a neo-bank setting, delivering an end-to-end ML pipeline that auto-labels merchant transactions and assigns a fraud risk score, surfaced through an Ops Dashboard for ingestion, scoring, review, and feedback, alongside a read-only Customer Dashboard for safe end-user visibility.
- CSV ingestion with validation and schema coercion
- Baseline category prediction (TF-IDF + Logistic Regression)
- Baseline fraud risk scoring (Isolation Forest)
- Unified scoring pipeline with category, confidence, fraud risk, and flagged state
- Ops Dashboard for uploads, KPIs, filtering, and review
- Analyst feedback loop with stable row IDs and exportable edits
- Rules overlay to override model category with audit tags
- Customer Dashboard with minimal exposure and customer flag capture
- Model performance page powered by
model_registry.json - Docker-ready deployment with healthcheck endpoint
- Install dependencies and set env vars:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env- Demo users are not pre-seeded (no fixture or migration ships with accounts). If you want to use demo credentials, create them manually:
Ops admin:
- username: admin
- email: admin@neobank.com
- password: admin
Customer user:
- username: customer1
- password: pass1234
python manage.py migrate
python manage.py createsuperuserCreate a customer user via Django admin or your normal signup flow. Avoid a username that collides with a customer_id in your CSVs to prevent confusion when filtering or selecting a customer dashboard.
-
If you want to create your own admin + customer users, follow the same steps but pick your own credentials.
-
Start the server and upload demo data:
python manage.py runserverUse demo data: data/sample_transactions.csv
- Screenshots and notes:
docs/screenshots - Model registry:
model_registry.json - Rules configuration:
rules/category_overrides.json
dashboard/Ops workflows, ingestion services, scoring orchestration, UIcustomer_site/Customer views and templatesml/Training and inference for baseline modelsrules/Category override definitionsartefacts/Model artefacts and metricsdata/Sample datasetstests/Unit and integration-style tests
Expected CSV columns:
timestampamountcustomer_idmerchantdescription
Contract guarantees:
- Required columns must be present
- Amounts are coerced to numeric
- Text fields are normalized
customer_idmust be non-empty
Prerequisites:
- Python 3.11
- PostgreSQL
Setup:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envUpdate .env with your local database values, then run:
python manage.py migrate
python manage.py runserverOps Dashboard: http://127.0.0.1:8000/ops/
Customer Dashboard: http://127.0.0.1:8000/customer/
docker compose up --buildThe Docker setup includes Postgres and runs Django on port 8000.
Core settings (see .env.example):
DEBUGSECRET_KEYALLOWED_HOSTSDATABASE_URL
PostgreSQL settings (when not using DATABASE_URL):
POSTGRES_DBPOSTGRES_USERPOSTGRES_PASSWORDPOSTGRES_HOSTPOSTGRES_PORT
Optional integrations (present in .env.example):
REDIS_URLCELERY_BROKER_URLCELERY_RESULT_BACKENDEMAIL_HOSTEMAIL_PORT
- Upload a CSV file.
- Set a fraud threshold.
- Review KPIs and scored results.
- Filter rows by flags, customer, merchant, category, or fraud risk.
- Edit categories and export feedback.
Category provenance is explicit:
modelfor model outputrulefor rule-based overrideeditfor analyst override
Precedence: edit > rule > model.
The customer site is a read-only surface that exposes a limited transaction view and allows customers to flag a transaction with an optional note. It deliberately hides any fraud scores, thresholds, or model output.
Rules are stored in rules/category_overrides.json and applied using case-insensitive substring matching against merchant and description. This keeps overrides auditable and fast to change.
GET /health/- Returns
{ "ok": true }
Run the test suite:
pytest -qCoverage:
coverage run -m pytest -q
coverage reportCI enforces an 80% minimum coverage threshold.
The project ships with a production Dockerfile and a gunicorn entrypoint. For a container platform:
- Set
DEBUG=False - Configure
ALLOWED_HOSTS - Provide
DATABASE_URL - Run database migrations
Example gunicorn start command:
gunicorn neobank_site.wsgi:application --bind 0.0.0.0:$PORTRender is supported out of the box via the existing render.yaml.
High-level flow:
- Create a new Render service from this repo.
- Add a managed PostgreSQL database and set
DATABASE_URL. - Set
DEBUG=Falseand configureALLOWED_HOSTS. - Trigger a deploy and run migrations if needed.
MIT. See LICENSE.
Adrian Adewunmi
https://github.com/AAdewunmi/Neo-Bank-Fraud-Detection-Project