{"id":36442389,"url":"https://github.com/darshitvvora/temporal-agentic-loan-underwriter","last_synced_at":"2026-01-21T16:06:06.568Z","repository":{"id":316235319,"uuid":"1062290176","full_name":"darshitvvora/temporal-agentic-loan-underwriter","owner":"darshitvvora","description":"Temporal + Strands demo for GenAI powered loan underwriter","archived":false,"fork":false,"pushed_at":"2025-10-12T15:47:40.000Z","size":1134,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-18T19:56:06.048Z","etag":null,"topics":["fastapi","python","strands-agent-sdk","strands-agents","streamlit","temporal","temporalio"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/darshitvvora.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T04:19:45.000Z","updated_at":"2025-11-09T05:18:31.000Z","dependencies_parsed_at":"2026-01-18T15:00:33.733Z","dependency_job_id":null,"html_url":"https://github.com/darshitvvora/temporal-agentic-loan-underwriter","commit_stats":null,"previous_names":["darshitvvora/temporal-agentic--loan-underwriter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/darshitvvora/temporal-agentic-loan-underwriter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darshitvvora%2Ftemporal-agentic-loan-underwriter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darshitvvora%2Ftemporal-agentic-loan-underwriter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darshitvvora%2Ftemporal-agentic-loan-underwriter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darshitvvora%2Ftemporal-agentic-loan-underwriter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/darshitvvora","download_url":"https://codeload.github.com/darshitvvora/temporal-agentic-loan-underwriter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/darshitvvora%2Ftemporal-agentic-loan-underwriter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28635927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T15:01:31.228Z","status":"ssl_error","status_checked_at":"2026-01-21T14:42:58.942Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","python","strands-agent-sdk","strands-agents","streamlit","temporal","temporalio"],"created_at":"2026-01-11T22:00:18.248Z","updated_at":"2026-01-21T16:06:06.548Z","avatar_url":"https://github.com/darshitvvora.png","language":"Python","funding_links":[],"categories":["Community Projects"],"sub_categories":["For PyPI Packages"],"readme":"# Agentic Loan Underwriter Demo\n\nThis repository demonstrates an agentic loan underwriting system built with Temporal workflows, Strands agent orchestration, Ollama LLM integration, and a Streamlit UI. The system simulates a loan underwriter copilot with specialist agents and supervisor orchestration for automated loan processing with human review capabilities.\n\n## Architecture\n- **FastAPI Backend**: REST API with endpoints for loan submission, workflow status checking, and human review\n- **Temporal Workflows**: SupervisorWorkflow orchestrates the entire loan processing pipeline with durable execution\n- **Strands HTTP Agents**: Reusable agent classes for intelligent data fetching with error handling and validation\n  - `DataFetchAgent`: Generic HTTP data fetching with validation\n  - `CreditReportAgent`: Specialized credit report validation with multi-provider support\n- **Specialist Activities**: Mock data fetching (bank, documents, credit) and AI-powered assessments (income, expense, credit analysis)\n- **Strands Integration**: Agent orchestration with structured output validation using Ollama models\n- **Provider Fallback**: Temporal-orchestrated fallback from CIBIL to Experian for credit reports\n- **Streamlit UI**: User interface for loan submission and underwriter review workflow\n- **Environment Configuration**: Configurable Ollama and Temporal settings via `.env` file\n\n## Sequence diagram\nThe diagram below shows the end-to-end flow: user submits via Streamlit, Streamlit calls FastAPI which starts a Temporal workflow. A worker executes activities (mock APIs and specialist agents), the workflow calls Ollama for a summary/decision, then the system awaits a human-review signal. The underwriter approves/rejects via the UI which signals the running workflow.\n\n```mermaid\nsequenceDiagram\n\tparticipant User as Applicant / Underwriter\n\tparticipant Streamlit as Streamlit UI\n\tparticipant FastAPI as FastAPI Backend\n\tparticipant Temporal as Temporal Server\n\tparticipant Worker as Temporal Worker\n\tparticipant Supervisor as SupervisorWorkflow\n\tparticipant DataAgent as DataFetchAgent\n\tparticipant CreditAgent as CreditReportAgent\n\tparticipant Mockoon as Mock APIs\n\tparticipant Ollama as Ollama (LLM)\n\n\tUser-\u003e\u003eStreamlit: Submit loan application\n\tStreamlit-\u003e\u003eFastAPI: POST /submit (application data)\n\tFastAPI-\u003e\u003eTemporal: start_workflow(\"SupervisorWorkflow\", data, workflow_id)\n\tTemporal-\u003e\u003eWorker: schedule activities on task queue\n\n\tNote over Worker, Supervisor: PHASE 1: Data Acquisition (Sequential)\n\tWorker-\u003e\u003eDataAgent: fetch_bank_account(applicant_id)\n\tDataAgent-\u003e\u003eMockoon: HTTP GET /bank?applicant_id=X\n\tMockoon--\u003e\u003eDataAgent: bank account data\n\tDataAgent--\u003e\u003eWorker: validated bank data\n\n\tWorker-\u003e\u003eDataAgent: fetch_documents(applicant_id)\n\tDataAgent-\u003e\u003eMockoon: HTTP GET /documents?applicant_id=X\n\tMockoon--\u003e\u003eDataAgent: document metadata\n\tDataAgent--\u003e\u003eWorker: validated documents\n\n\tWorker-\u003e\u003eCreditAgent: fetch_credit_report_cibil(applicant_id)\n\tCreditAgent-\u003e\u003eMockoon: HTTP GET /cibil?applicant_id=X\n\talt CIBIL Success\n\t\tMockoon--\u003e\u003eCreditAgent: credit report data\n\t\tCreditAgent--\u003e\u003eWorker: validated credit (provider: CIBIL)\n\telse CIBIL Failure (after 2 retries)\n\t\tNote over Supervisor: Temporal orchestrates fallback\n\t\tWorker-\u003e\u003eCreditAgent: fetch_credit_report_experian(applicant_id)\n\t\tCreditAgent-\u003e\u003eMockoon: HTTP GET /experian?applicant_id=X\n\t\tMockoon--\u003e\u003eCreditAgent: credit report data\n\t\tCreditAgent--\u003e\u003eWorker: validated credit (provider: Experian)\n\tend\n\n\tNote over Worker, Supervisor: PHASE 2: Parallel Specialist Assessments\n\tpar Income Assessment\n\t\tWorker-\u003e\u003eWorker: income_assessment(app, bank, credit)\n\t\tNote over Worker: Heuristic: income/amount ratio \u003e 2\n\t\tWorker-\u003e\u003eWorker: income_ok + income value\n\tand Expense Assessment\n\t\tWorker-\u003e\u003eWorker: expense_assessment(app, bank)\n\t\tNote over Worker: Heuristic: disposable income check\n\t\tWorker-\u003e\u003eWorker: affordability_ok + expenses\n\tand Credit Assessment\n\t\tWorker-\u003e\u003eWorker: credit_assessment(app, credit)\n\t\tNote over Worker: Heuristic: score \u003e 620\n\t\tWorker-\u003e\u003eWorker: credit_ok + score\n\tend\n\n\tNote over Worker, Supervisor: PHASE 3: Decision Aggregation with LLM\n\tWorker-\u003e\u003eOllama: aggregate_and_decide(all data)\n\tNote over Ollama: Strands Agent + Ollama Model\n\tOllama--\u003e\u003eWorker: AI summary + recommendation\n\tWorker--\u003e\u003eSupervisor: Store summary with suggested decision\n\n\tNote over Supervisor: PHASE 4: Human-in-the-Loop Review\n\tNote over Supervisor: Workflow pauses, exposes queries\n\n\tUser-\u003e\u003eStreamlit: Navigate to Review tab\n\tStreamlit-\u003e\u003eFastAPI: GET /workflow/{id}/summary\n\tFastAPI-\u003e\u003eTemporal: query(\"get_summary\")\n\tTemporal-\u003e\u003eSupervisor: get_summary query\n\tSupervisor--\u003e\u003eTemporal: summary with assessments + AI decision\n\tTemporal--\u003e\u003eFastAPI: complete summary\n\tFastAPI--\u003e\u003eStreamlit: display summary JSON\n\tStreamlit--\u003e\u003eUser: Show AI analysis + recommendation\n\n\tUser-\u003e\u003eStreamlit: Click Approve/Reject\n\tStreamlit-\u003e\u003eFastAPI: POST /workflow/{id}/review {\"action\": \"approve/reject\"}\n\tFastAPI-\u003e\u003eTemporal: signal(\"human_review\", decision)\n\tTemporal-\u003e\u003eSupervisor: receive human_review signal\n\tNote over Supervisor: Workflow continues and completes\n\tSupervisor--\u003e\u003eTemporal: finalize with human decision\n\n\topt Final Status Check\n\t\tStreamlit-\u003e\u003eFastAPI: GET /workflow/{id}/final\n\t\tFastAPI-\u003e\u003eTemporal: query(\"get_final_result\")\n\t\tTemporal-\u003e\u003eSupervisor: get_final_result query\n\t\tSupervisor--\u003e\u003eTemporal: complete result\n\t\tTemporal--\u003e\u003eFastAPI: summary + human decision\n\t\tFastAPI--\u003e\u003eStreamlit: display final outcome\n\tend\n```\n\n## Prerequisites\n- **Temporal Server**: Running locally (default at localhost:7233)\n- **Ollama**: Local installation with model (default: `llama3.2:1b`, configurable via `.env`)\n- **Mockoon**: Mock API server running on port 3233 (configuration available in `mockoon` folder)\n- **Python 3.9+**: Required for all dependencies\n- **Dependencies**: Install from `requirements.txt`\n\n## Setup \u0026 Installation\n\n1. **Clone and setup environment:**\n```bash\ngit clone \u003crepository-url\u003e\ncd temporal-agentic--loan-underwriter\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\npip install -r requirements.txt\n```\n\n2. **Configure environment variables:**\n```bash\ncp .env.example .env\n# Edit .env to customize Ollama URL, model, and Temporal settings\n```\n\n3. **Start required services:**\n   - Start Temporal server (see [Temporal docs](https://docs.temporal.io/dev-guide/))\n   - Start Ollama with your preferred model (e.g., `ollama run llama3.2:1b`)\n   - Start Mockoon with the configuration from the `mockoon` folder (import the JSON config file into Mockoon and start the mock API on port 3233)\n\n4. **Launch the application:**\n\n   **Terminal 1 - Temporal Worker:**\n   ```bash\n   python backend/worker.py\n   ```\n\n   **Terminal 2 - FastAPI Backend:**\n   ```bash\n   uvicorn backend.main:app --reload --port 8000\n   ```\n\n   **Terminal 3 - Streamlit UI:**\n   ```bash\n   streamlit run ui/streamlit_app.py\n   ```\n\n5. **Access the application:**\n   - Streamlit UI: http://localhost:8501\n   - FastAPI docs: http://localhost:8000/docs\n\n## Key Features\n- **Structured Data Validation**: Strands integration provides automatic validation of loan applications\n- **Mock Data Services**: Simulated bank account, document, and credit report fetching\n- **AI-Powered Analysis**: Specialist agents for income, expense, and credit assessment using Ollama\n- **Human-in-the-Loop**: Workflow pauses for human underwriter review and decision\n- **Durable Execution**: Temporal ensures reliable workflow execution with automatic retries\n- **Real-time UI**: Streamlit interface for application submission and review workflow\n\n## Project Structure\n```\n├── backend/\n│   ├── main.py                              # FastAPI application and API endpoints\n│   ├── workflows.py                         # Temporal SupervisorWorkflow definition\n│   ├── activities.py                        # Temporal activities (data fetching \u0026 AI assessments)\n│   ├── worker.py                            # Temporal worker process\n│   └── classes/\n│       └── agents/\n│           ├── data_fetch_agent.py          # Strands agent for HTTP data fetching\n│           └── credit_report_agent.py       # Strands agent for credit report validation\n├── ui/\n│   └── streamlit_app.py                     # Streamlit user interface\n├── mockoon/                                 # Mock API configuration for local development\n├── .env.example                             # Environment configuration template\n└── requirements.txt                         # Python dependencies\n```\n\n## Development Notes\n- **Mock Data Services**: Uses Mockoon for simulating bank, document, and credit bureau APIs\n- **Agent Architecture**: Strands agents are organized in reusable classes under `backend/classes/agents/`\n- **Separation of Concerns**:\n  - Temporal activities handle durable execution and retry logic (outer loop)\n  - Strands agents handle intelligent data fetching and validation (inner loop)\n- **Provider Fallback Pattern**: Temporal workflow orchestrates CIBIL → Experian fallback for credit reports\n- **Configurable LLM**: Ollama model selection via environment variables (default: `llama3.2:1b`)\n- **Production Considerations**: Would require secure API integrations, authentication, and real data providers\n- **Human-in-the-Loop**: Workflow supports binary approve/reject decisions with AI-generated explanations\n\n## Contributing\n\nWe welcome contributions to improve this demo! Here's how you can help:\n\n### Getting Started\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/your-feature-name`\n3. Make your changes and test locally\n4. Commit with clear messages: `git commit -m \"Add: description of changes\"`\n5. Push to your fork: `git push origin feature/your-feature-name`\n6. Open a Pull Request with a clear description of your changes\n\n### Contribution Ideas\n- **Enhanced AI Models**: Integration with other LLM providers (OpenAI, Anthropic, etc.)\n- **Real Integrations**: Replace mock activities with actual bank/credit APIs\n- **UI Improvements**: Enhanced Streamlit interface or alternative frontend\n- **Security Features**: Authentication, authorization, and data encryption\n- **Testing**: Unit tests, integration tests, and workflow testing\n- **Documentation**: API documentation, deployment guides, or tutorials\n- **Performance**: Optimization and monitoring capabilities\n\n### Code Standards\n- Follow existing code style and patterns\n- Add appropriate error handling and logging\n- Update documentation for any new features\n- Ensure all tests pass before submitting\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\nCopyright (c) 2025 Darshit Vora\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarshitvvora%2Ftemporal-agentic-loan-underwriter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarshitvvora%2Ftemporal-agentic-loan-underwriter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarshitvvora%2Ftemporal-agentic-loan-underwriter/lists"}