Skip to content

bharathvikasp-cell/expense-approval-workflow-api

Repository files navigation

Expense Approval Workflow API

Production-style Python/FastAPI backend for employee expense approvals, risk-based routing, decision audit trails, and idempotent workflow operations.

Recruiter Scan

  • FastAPI + SQLAlchemy backend with service/repository architecture
  • Real workflow state machine: draft, pending manager, pending finance, pending director, approved, rejected, changes requested
  • Idempotent expense creation to prevent duplicate submissions
  • Risk scoring and approval routing based on claim amount and suspicious text
  • Audit trail for every workflow decision
  • Request timing middleware, structured JSON logging, Docker, CI, and Pytest coverage

Workflow

flowchart LR
    Draft --> Submitted["pending_manager"]
    Submitted --> Finance["pending_finance"]
    Finance --> Director["pending_director"]
    Submitted --> Approved
    Finance --> Approved
    Director --> Approved
    Submitted --> Rejected
    Finance --> Rejected
    Director --> Rejected
Loading

API Examples

curl -X POST http://localhost:8000/api/v1/expenses \
  -H "Content-Type: application/json" \
  -d '{"employee_id":"E100","department":"Operations","amount":2500,"description":"Client travel","idempotency_key":"claim-001"}'
curl -X POST http://localhost:8000/api/v1/expenses/{claim_id}/decisions \
  -H "Content-Type: application/json" \
  -d '{"actor_id":"M1","actor_role":"manager","action":"approve","comment":"Approved"}'

Local Setup

python3 -m venv .venv
source .venv/bin/activate
make install
make test
make dev

Swagger UI: http://localhost:8000/docs

Why This Project Matters

This project mirrors a real internal enterprise workflow platform: business rules, state transitions, auditability, idempotency, persistence, APIs, and tests. It is designed to be explainable in interviews while still showing backend engineering maturity.

About

FastAPI expense approval workflow API with SQLAlchemy models, idempotency, approval routing, audit events, structured logging, Docker, CI, and tests.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors