Skip to content
fdeniz07Public

About

Credit application platform (individual/corporate) with .NET Clean Architecture API and React frontend.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

BankApp

Türkçe README · Deutsche README

BankApp is a full-stack educational banking sample for individual and corporate credit applications.
Backend: .NET 10 Clean Architecture + CQRS (MediatR), Modular Monolith (Identity / Customers / Credit / Notification), Domain Events + Outbox, Idempotency-Key, Saga, SignalR.
Frontend: React (Vite + TypeScript) with TR / EN / DE i18n and live credit notifications (SignalR).
Local stack: Docker Compose (SQL Server, Redis, Seq, RabbitMQ, Vault lab, Keycloak lab, ELK, WebApi, client).

Docs: Roadmap · Tech learning · Learning library · Architecture notes · History · Changelog · Test notes · Infra


Table of contents

  1. Demo logins
  2. Features
  3. Screenshots (EN)
  4. Tech stack
  5. Solution structure
  6. Architecture diagrams
  7. Domain model
  8. Business rules
  9. API overview
  10. Lab tools
  11. SmartEnum
  12. Data seeding
  13. Getting started
  14. Example requests

Demo logins

Shared password: Demo123!. Roughly 1 manager + 3 staff per branch (top-up seed).

Role Example email Branch
SuperAdmin [email protected] —
Manager manager.ist@ / manager.tr@ (ANK) / manager.ber@ / manager.nyc@ / [email protected] IST / ANK / BER / NYC / CHI
Staff staff.tr@, staff.ank@, staff.de@, staff.nyc@, staff.chi@ (+ .analyst / .rm / .ops variants) same
Customer customer.tr@ / customer.en@ / [email protected] (+ customer@) by locale

Legacy aliases still work: staff@, manager@, manager.en@, staff.en@, …

Roles: Customer, BankStaff, BankManager, SuperAdmin (manager also has BankStaff; SuperAdmin can CRUD branches).


Features

Backend

  • Individual / corporate customers (TPT), credit types & sub-types, applications
  • JWT auth + RBAC; public individual registration with email confirmation (RabbitMQ)
  • Approve / reject / cancel (status change — not soft-delete for cancel)
  • Editable customer decision letters (approve/reject templates; stored in notes)
  • Domain Events + Transactional Outbox (credit lifecycle → domain-events queue)
  • Idempotency-Key (create / approve / reject / cancel; Redis, 24h)
  • Saga / Process Manager (CreditApplicationSagas; Created → decision → onboarding stubs)
  • SignalR (/hubs/credit-applications; staff + customer groups; publish after Outbox consumer)
  • Decision letter email / SMS (lab) — after approve/reject, queues decision-letter + decision-letter-sms → Seq/log (no SMTP/SMS gateway)
  • Rate limiting — policies auth / write / fixed (429); health + SignalR exempt
  • Vault lab — JWT SecurityKey (+ dual-key SecurityKeyPrevious) overlay from secret/bankapp; rotate script; env fallback
  • Keycloak lab — Compose realm; dual JwtBearer + claim enrich; SPA PKCE (“Sign in with Keycloak”); Google/GitHub IdP script (off without secrets)
  • Branch model + DoA (Branch.MaxApprovalAmount + currency; position × branch cap)
  • ApproveGateMode (None/Soft/Hard) + document soft/hard gate
  • Application document upload (lab: identity / income / other; PDF/JPEG/PNG ≤5 MB; App_Data)
  • ELK lab — ES live search/facets (applications, staff, customers, credit types); Seq remains for logs
  • Payment plan (amortization) + PDF export/print
  • Dashboard summary + Admin Tailwind dashboard (/dashboard)
  • Staff management, profile + avatar (≤ 2 MB); credit type CRUD (BankManager)
  • Serilog → Seq, Redis cache, FluentValidation, ProblemDetails
  • OpenTelemetry → collector → Tempo / Prometheus / Grafana

Frontend (client/)

  • Login / register / email confirm, applications, customers, credit types, staff, branches, profile
  • Stats strip, FX ticker, accessibility panel (theme / font size / contrast)
  • Privacy / cookie banner; locale switcher TR / EN / DE
  • Idempotency-Key (UUID) on credit write requests
  • SignalR: application-status toast + list/detail refresh; missing-doc badge
  • Application detail: document upload / list / download (Pending); ES filter/facets (manager)
  • Payment plan: collapsible installment table, PDF download and print
  • Staff decision forms: reloadable approve/reject message templates

CI/CD

  • GitHub Actions: restore/build WebApi, run unit + integration tests, build React client
  • Docker Compose stack (infra/) for local multi-service runs (healthchecked chain)

Test

  • xUnit Application.UnitTests (domain rules, saga, handlers)
  • xUnit WebApi.IntegrationTests (API + auth/credit flows)
  • Client production build (tsc + Vite) in CI

Screenshots (EN)

UI captures under docs/assets/screenshots/en/ (English locale for now).
Role walkthroughs: Customer · Bank staff · Bank manager · SuperAdmin

Auth, privacy & accessibility

Login & privacy banner — Sign-in with TR/EN/DE switcher, remember-me, demo credentials on the card, and cookie/privacy consent before using the SPA.

Login page and privacy banner

Dark theme login — Same login card with accessibility dark theme.

Login dark theme

Register — Individual customer self-registration form.

Register page

Keycloak login — SPA “Sign in with Keycloak” / IdP hosted login.

Login with Keycloak

403 Permission denied — Cross-role / cross-branch denial surface.

403 permission denied

Accessibility panel — Floating controls for light/dark theme, font scale, and high contrast (persisted in the browser).

Accessibility settings

Dashboards (by role)

Customer — Welcome by display name; own application counters. More: customer gallery.

Customer dashboard

Bank staff — Global stats, FX ticker, SignalR lifecycle toasts. More: staff gallery.

Bank employee dashboard

Bank manager — Same overview with staff + credit-type admin. More: manager gallery.

Bank manager dashboard

SuperAdmin — Cross-branch admin + Branches CRUD. More: SuperAdmin gallery.

SuperAdmin dashboard

Infrastructure & observability

Docker Compose — Full lab stack (SQL, Redis, Seq, RabbitMQ, Vault, Keycloak, ELK, OTel, Prometheus, Grafana, WebApi, client).

Docker containers

Scalar API reference — Interactive OpenAPI UI for WebApi (/scalar/v1).

Scalar API docs

Seq — Structured application logs (Serilog), correlatable with TraceId when OTel is on.

Seq logs

Redis Insight — Cache browser for the Compose Redis instance (:5540).

Redis Insight cache

Prometheus & Grafana — Metrics scrape + dashboards/traces UI (:9090 / :3001).

Prometheus

Grafana metrics

Grafana metrics panel 2

Grafana additional metrics

RabbitMQ — Queues for email confirmation, domain-events (Outbox consumer), decision-letter and decision-letter-sms (lab).

RabbitMQ queues

Vault (lab) — Dev-mode KV secret/bankapp; WebApi startup overlay (JWT current + previous dual-key).

HashiCorp Vault secrets

Keycloak admin — Realm / users console (:8180).

Keycloak management

Kibana — Elasticsearch Discover / Lens over bankapp-credit-applications and bankapp-logs-*.

Kibana Elasticsearch results


Tech stack

Area Technology
API .NET 10, ASP.NET Core, MediatR, FluentValidation, AutoMapper, EF Core 10
Domain AggregateRoot, Domain Events (CreditApplication*), Ardalis SmartEnum (name)
DB / cache / logs SQL Server, Redis, Serilog + Seq
Observability OpenTelemetry (OTLP) → collector → Tempo + Prometheus + Grafana :3001
Messaging RabbitMQ (email-confirmation, domain-events, decision-letter, decision-letter-sms) + Outbox
Idempotency Header Idempotency-Key + Redis (credit write APIs, 24h)
Saga CreditApplicationProcessManager + table CreditApplicationSagas
Realtime SignalR hub /hubs/credit-applications (JWT access_token)
Secrets (lab) HashiCorp Vault dev (overlay + dual-key rotate); optional Raft overlay :8210+
Auth JWT + roles; Keycloak lab (dual JwtBearer + SPA PKCE)
Search (lab) Elasticsearch (applications / staff / customers / credit types) + Kibana
Client React, Vite, TypeScript, Tailwind (admin dashboard), react-i18next, SignalR
Docs (Dev) OpenAPI + Scalar (/scalar/v1)
Test / CI xUnit (Application + WebApi.IntegrationTests), GitHub Actions
Seed Bogus — per-branch customer/staff/application top-up
Infra Docker Compose (infra/) — healthchecked service chain

Solution structure

BankApp/
├── BankApp.slnx
├── README.md / README.tr.md / README.de.md
├── client/              # React SPA
├── docs/                # roadmap, tech learning, architecture notes, changelog, history
├── infra/               # docker-compose, .env.example, scripts/vault-seed.sh
├── tests/               # Application.UnitTests, WebApi.IntegrationTests
└── src/
    ├── WebApi/          # Host + Modules/{Identity,Customers,Credit,Notification}
    ├── Application/     # Modules/{Identity,Customers,Credit,Notification} + shared Services
    ├── Domain/          # Entities, Events, SmartEnums, CreditApplicationSaga
    ├── Persistence/     # DbContext (outbox harvest), migrations, repositories, seed
    └── Core/            # Entity, AggregateRoot, paging, security helpers, pipelines

Dependency direction: WebApi → Application / Persistence → Domain / Core.


Architecture diagrams

Layer dependencies

flowchart TB
    Client[React client]
    WebApi[WebApi]
    Application[Application]
    Persistence[Persistence]
    Domain[Domain]
    Core[Core]

    Client --> WebApi
    WebApi --> Application
    WebApi --> Persistence
    Application --> Domain
    Application --> Core
    Persistence --> Application
    Persistence --> Domain
    Persistence --> Core
    Domain --> Core
Loading

Request flow (CQRS)

sequenceDiagram
    participant Client
    participant Controller
    participant MediatR
    participant Validation as RequestValidationBehavior
    participant Handler
    participant Rules as BusinessRules
    participant Repo as Repository / EF Core
    participant Db as SQL Server

    Client->>Controller: HTTP + JWT
    Controller->>MediatR: Send(Request)
    MediatR->>Validation: FluentValidation
    Validation->>Handler: Handle
    Handler->>Rules: Domain checks
    Handler->>Repo: Query / command
    Repo->>Db: SQL
    Db-->>Repo: Data
    Repo-->>Handler: Entity / page
    Handler-->>Controller: Response DTO
    Controller-->>Client: JSON / ProblemDetails
Loading

Credit application lifecycle

stateDiagram-v2
    [*] --> Pending: Create
    Pending --> Approved: Approve
    Pending --> Rejected: Reject
    Pending --> Cancelled: Cancel
    Pending --> Pending: Update (Pending only)
    Approved --> [*]
    Rejected --> [*]
    Cancelled --> [*]
Loading

Domain model

Customers (TPT)

Entity Notes
Customer Shared: number, email, phone, address, IsActive, soft-delete
IndividualCustomer Name, national id, DOB, gender, …
CorporateCustomer Company, tax, authorized person, …

Credit catalog & applications

Entity Role
CreditType Product (category, risk, currency, locale, active)
CreditSubType Package (amount/term ranges, rates)
CreditApplication Request + status + decision fields

Soft delete vs active

Flag Meaning
IsActive Business: usable for new operations
IsDeleted Technical soft delete (DeletedDate)

Application cancel sets status to Cancelled via dedicated command (not soft-delete).


Business rules

Customers

  • Unique national id / tax / registration / customer number / email (per rules).
  • Soft delete of customers: BankManager only; customer must be inactive and have no open Pending/Approved applications.

Credit types & sub-types

  • Unique codes; amount/term range consistency.
  • New applications require active parent credit type and sub-type.
  • Category match: individual ↔ Individual, corporate ↔ Corporate.
  • Manager-only mutating APIs for credit types (create / update / delete / set active).

Credit applications

  • Amount/term within sub-type package (and packaging constraints where applied).
  • Only Pending can be updated, approved, rejected, or cancelled.

API overview

Service (Docker lab) URL / endpoint Lab credentials / notes
WebApi http://localhost:8080 JWT after login (see Demo logins)
Scalar http://localhost:8080/scalar/v1 Dev OpenAPI UI
Client http://localhost:3000 Demo users on login card
SQL Server localhost,11433 sa / MSSQL_SA_PASSWORD (default in .env.example: 1q2w3e4r!)
Redis localhost:6379 No password (lab)
Redis Insight (UI) http://localhost:5540 No login; add DB host redis, port 6379 (Compose DNS)
Seq (logs) http://localhost:5341 No login (lab; open UI directly)
Grafana (metrics/traces UI) http://localhost:3001 admin / admin (GRAFANA_ADMIN_*)
Prometheus http://localhost:9090 No login (lab)
OTLP gRPC (collector) localhost:4317 App → collector (not a browser UI)
RabbitMQ UI http://localhost:15672 guest / guest
Vault UI (lab) http://localhost:8200 Token = VAULT_DEV_ROOT_TOKEN_ID (default bankapp-vault-root-token); KV secret/bankapp
Keycloak (lab) http://localhost:8180 Realm bankapp; SPA PKCE login; admin console
Vault Raft (optional) http://localhost:8210 docker-compose.vault-raft.yml; daily vault stays on :8200
Elasticsearch http://localhost:9200 Lab search indexes
Kibana http://localhost:5601 ELK UI

Most endpoints require JWT (Authorization: Bearer …) except login / public register / confirm-email.
Credit writes (POST create/approve/reject/cancel): required header Idempotency-Key.

Controller Highlights
Auth POST login, register, register-individual, confirm-email
IndividualCustomers / CorporateCustomers CRUD + inactive / deleted lists
CreditTypes List/get; mutate + PUT {id}/active (manager)
CreditSubTypes CRUD
CreditApplications approve / reject / cancel (+ Idempotency-Key); payment-plan; payment-plan/export?format=pdf
Dashboard GET summary
StaffUsers List / create / update (manager); ES search
Branches Branch CRUD (SuperAdmin); DoA cap + currency
Profile Get mine; update staff profile; upload avatar

Interactive details: Scalar UI.

Lab tools

How to watch the stack (Scalar, Seq, Redis Insight, RabbitMQ, Grafana, Vault, Keycloak, Kibana, SQL, Docker) — setup, Compose DNS, cautions, best practices → docs/learning/tr/24-lab-tools.md (Turkish chapter; URLs match this README).

Short debug chain: Scalar request → Redis Insight / RabbitMQ → Seq logs → (optional) Grafana traces.


SmartEnum

Stored and serialized by name (e.g. "Pending"), not integer ordinals.

Type Values (examples)
CreditCategory Individual, Corporate
CreditRiskLevel Low, Medium, High
CreditApplicationStatus Pending, Approved, Rejected, Cancelled
Gender Female, Male, PreferNotToSay
PersonTitle Dr, Prof
StaffPosition CreditAnalyst, RelationshipManager, BranchOfficer, RiskOfficer, OperationsSpecialist, BranchManager

Data seeding

Runs when configured (Database__RunSeed, typical in Docker / Development). Top-up strategy: fill up to targets if short.

Seed Approx. target
Branches 5 (IST / ANK / BER / NYC / CHI) + DoA cap/currency
Individual customers 12 / branch (~60)
Corporate customers 8 / branch (~40)
Credit types / subs 16 types + packaged sub-types (TRY/USD/EUR)
Credit applications ~100 (mixed status; fake docs on Pending)
Identity ~1 manager + 3 staff / branch; SuperAdmin; customers

Note: Seed creates only BranchSeed.DemoBranches. Manually added branches (e.g. DOR-01) may receive customer top-up but no staff map. Remove or deactivate orphans via SuperAdmin → Branches UI.


Getting started

Option A — Docker (recommended)

# from repo root
copy infra\.env.example infra\.env
docker compose -f infra/docker-compose.yml --env-file infra/.env up -d --build

See infra/README.md for volumes, ports, and teardown.

Option B — API + client locally

Prerequisites: .NET 10 SDK, SQL Server (or Docker SQL), Node.js 20+, Redis/Seq optional.

dotnet ef database update --project src/Persistence/Persistence.csproj --startup-project src/WebApi/WebApi.csproj
dotnet run --project src/WebApi/WebApi.csproj
cd client
copy .env.example .env
npm install
npm run dev

Configure ConnectionStrings__BankingConnectionString and JWT TokenOptions__SecurityKey via appsettings / User Secrets / env.

Tests & CI

dotnet test tests/Application.UnitTests/Application.UnitTests.csproj
dotnet test tests/WebApi.IntegrationTests/WebApi.IntegrationTests.csproj

GitHub Actions (.github/workflows/ci.yml) runs backend build + both test projects and the React client build on push/PR to main/master.


Example requests

Login

POST /api/Auth/login
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "Demo123!"
}

Use returned access token as Authorization: Bearer <token>.

Create credit application

POST /api/CreditApplications
Authorization: Bearer <token>
Content-Type: application/json

{
  "creditSubTypeId": "<guid>",
  "requestedAmount": 50000,
  "requestedTermMonths": 24,
  "monthlyIncome": 45000,
  "existingDebtAmount": 5000,
  "purpose": "Personal expenses",
  "notes": null
}

Approve

POST /api/CreditApplications/{id}/approve
Authorization: Bearer <token>
Content-Type: application/json

{
  "approvedAmount": 45000,
  "approvedTermMonths": 24,
  "approvedInterestRate": 2.45,
  "notes": "Approved with conditions"
}

Cancel (Pending)

POST /api/CreditApplications/{id}/cancel
Authorization: Bearer <token>
Content-Type: application/json

{}

License / purpose

Educational Clean Architecture + full-stack credit workflow sample.
Adapt connection strings, secrets, and hardening before any production use.

About

Credit application platform (individual/corporate) with .NET Clean Architecture API and React frontend.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages