A complete loan origination system built with Go, Temporal, and a simple SPA frontend. This system demonstrates human-in-the-loop workflows with Temporal signals for document verification, appraisal, and underwriting processes. All state is managed within Temporal workflows using queries for data retrieval.
- Backend: Go with Gin framework
- Workflow Engine: Temporal for reliable, durable execution
- State Management: All data stored in Temporal workflow state (no database required)
- Frontend: Vanilla JavaScript SPA with role-based interface
- Human-in-the-Loop: Manual processes with signals for document verification and underwriting
- Queries: Temporal workflow queries for data retrieval
The system includes 6 personas:
- Loan Officer - Create loan applications
- Customer - Upload documents
- Loan Processor - Verify documents
- Appraiser - Complete property appraisals
- Underwriter - Make loan decisions
- Fund Manager - Process funding
- Go 1.21 or later
- Temporal CLI
Install the Temporal CLI from: https://docs.temporal.io/cli#installation
temporal server start-devgo run cmd/worker/main.gogo run cmd/server/main.goOpen your browser and navigate to:
- Frontend: http://localhost:8082
- Temporal Web UI: http://localhost:8233
-
Loan Officer:
- Switch to "Loan Officer" role
- Create a new loan application using the form
- View your created applications
-
Customer:
- Switch to "Customer" role
- Upload documents for pending applications
- Upload at least 2 documents (income statement, bank statement)
-
Loan Processor:
- Switch to "Loan Processor" role
- Verify uploaded documents by clicking "Verify Documents"
- Approve or reject each document
-
Appraiser:
- Switch to "Appraiser" role
- Complete property appraisal for applications
- Enter property value and notes
- Trigger Credit score check API automatically. It will fail twice snd succeed 3rd time (simulated)
-
Underwriter:
- Switch to "Underwriter" role
- Review applications with completed appraisals
- Make approve/reject decisions
-
Fund Manager:
- Switch to "Fund Manager" role
- Process funding for approved loans
You can simulate third-party document verification using curl:
# Get the loan ID and document ID from the frontend first
curl -X POST http://localhost:8082/api/v1/loans/{loan-id}/verify-documents \
-H "Content-Type: application/json" \
-d '{
"document_id": "{document-id}",
"verification_status": "verified",
"verification_details": {
"verified_by": "third-party-service",
"confidence_score": 0.95
}
}'POST /api/v1/loans- Create loan applicationGET /api/v1/loans- Get all loan applicationsGET /api/v1/loans/:id- Get specific loan applicationGET /api/v1/loans/:id/status- Get workflow statusPOST /api/v1/loans/:id/documents- Upload documentPOST /api/v1/loans/:id/verify-documents- Verify documentPOST /api/v1/loans/:id/appraisal- Complete appraisalPOST /api/v1/loans/:id/underwriting- Make underwriting decisionPOST /api/v1/loans/:id/funding- Process funding
- Long-running workflows - Loan origination process can take days/weeks
- Human-in-the-loop - Manual steps for document upload, verification, and underwriting
- Signal handling - External events trigger workflow progression
- Workflow state management - All data stored in workflow state
- Workflow queries - Real-time data retrieval from running workflows
- Timeout management - Workflows have timeouts for each step
- Workflow history - Complete audit trail of all actions