Inspiration
I learnt about saving from my Kenyan grandmother. And I learnt about the dynamics of smart borrowing to accelerate my goals from my grandfather. Both of whom were members of various Sacco societies in Kenya.
There are approximately 5,000 registered SACCOs in Kenya. These SACCOs play a significant role in the country's economy, with over 14 million Kenyans being members.
However, Sacco societies face significant challenges when it comes to lending:
Kuscco, the apex SACCO union, recorded NPLs (Non‑Performing Loans) of KSh 5.3 billion as of December 2023. Many loans were issued without adequate collateral or due diligence. In a country ridden with corruption issues, SmartSacco had the potential to change the system.
Additionally, slow loan approval and disbursement processes, often due to outdated or manual systems, delay services and frustrate members.
This occurred to my grandparents as they were paying my school fees, this delay caused me to be sent out of school for a while before they could find any money.
Thus the birth of SmartSacco.
An AI powered system that aims to help Sacco societies make smarter lending decisions, faster.
What it does
Smart SACCO is a people-centered tool designed to help Savings and Credit Cooperative Organizations (SACCOs) make better, faster, and fairer loan decisions while keeping the needs of their members at the heart of every step.
How I built it
This project, "SmartSacco Loan Eligibility," was built using a combination of Python, Streamlit, TiDB Cloud, and Ollama to create an agentic AI solution for loan assessment.
The development began with setting up a VS Code environment, installing dependencies like SQLAlchemy, LangChain, and Streamlit, and configuring a virtual environment. TiDB Serverless,( a distributed SQL database with vector search,) was integrated to store and query member data (e.g., member_id, investments, loans) via a secure SSL connection using environment variables for credentials.
The backend logic, housed in agents.py, includes a retrieval tool to fetch data, an authentication function for admin logins, and an analysis chain using the Mistral 7B LLM from Ollama to predict loan eligibility based on criteria like credit score , no defaults, and loan amount (≤3x invested).
The prompt was refined to enforce JSON output, with error handling for parsing issues. The Streamlit app (app.py) provides a UI for login and loan requests, displaying results and sending reminders if due dates are near (within 7 days from 2025-09-10 for example).
The project was iteratively tested and debugged, ensuring compatibility across components, and deployed locally for the TiDB AgentX Hackathon 2025.
Given the sensitive nature of real Sacco data, I generated mock datasets using Mockaroo. In a real world scenario, the project will make use of real world data.
Challenges I ran into
This project presented many 'firsts' for me. My first hackathon, my first AI agent project, my first solo attempt at stepping out of my comfort zone in the tech world. In building and developing this project, a major challenge was the fact that a project of this nature requires substantial computing power, which my laptop has in limited quantities. I also started developing this project while going to work every day and I therefore had to make time to focus on this project.
Accomplishments that I'm proud of
I was able to put together a functional AI solution that can be scaled in the future to help local communities in my country. In submitting a complete project in this manner, I have proved to myself that I can achieve anything I put my head to, and I'm very proud of myself for this.
What I learned
I was able to put my python coding skills to test. I also learnt how to source and clean data, which is essential for building an AI Agent. I got acquainted with new tools for development such as TiDB, Ollama, and Streamlit, all which gave me good practice on AI development and data management.
What's next for SmartSacco
The next goal is to fine-tune the application with real-life data, equip it with more robust security measures, and make it more accessible for potential users with special needs.
Meeting the Requirements
email used for TiDB Cloud account: kitoelsie5@gmail.com
- Innovative, Multi-Step, Agentic Solution
Innovation: The project introduces an AI-driven approach to loan eligibility assessment for SACCOs, automating a traditionally manual process. By integrating an LLM (Mistral 7B via Ollama) with TiDB data, it provides a narrative explanation of eligibility, enhancing decision-making transparency, an innovative feature for cooperative financial systems.
Multi-Step Nature: The solution involves multiple stages, making it agentic:
- Input Collection: Users input member ID and loan amount via the Streamlit interface.
- Data Processing: The agent retrieves and processes data from TiDB.
- Analysis: The LLM evaluates eligibility based on predefined rules.
- Action: Notifications are inserted into the database if due dates are near. This multi-step flow demonstrates an agentic design where the system autonomously progresses from user input to a final action.
- Chaining at Least Two Building Blocks in a Single Automated Workflow The project chains the following two building blocks in an automated workflow:
Search Your Data: The retrieve_member_data function queries TiDB Serverless using SQL to fetch relevant records (e.g., member_id, credit_score, total_invested, amount_due) based on the input member_id. This step searches the indexed database tables, retrieving data critical for eligibility assessment. Although vector search isn’t currently active, the SQL-based search fulfills this block by finding relevant member records.
Chain LLM Calls: The retrieved data is passed to the Mistral 7B LLM via the analysis_chain in agents.py. The LLM analyzes the data against rules (e.g., amount_due = 0, loan ≤ 3x total_invested, credit_score > 200) and generates a detailed narrative response. This chaining occurs seamlessly within the process_loan_request function, where the search results are analyzed without manual intervention.
- Build a Multi-Step Flow: The workflow is fully automated: Input: User submits member_id and amount via app.py. Search: retrieve_member_data queries TiDB. LLM Analysis: analysis_chain processes the data. Action: process_notification inserts a reminder into the notifications table if a due date is within 7 days (e.g., before 2025-09-19, given today’s date of 2025-09-12). This end-to-end process, triggered by a single button click ("Predict Eligibility"), meets the requirement for a single automated workflow.
- Working Software Application The project is a functional application, as evidenced by the Streamlit frontend (app.py) that allows login, form submission, and display of eligibility results. The backend (agents.py) interacts with TiDB Cloud and the LLM, producing outputs like "Eligible: Yes" with reasons and notifications. Testing with sample data (e.g., member_id=300, amount=4000) confirms its operational status, fulfilling the "working software" criterion.
Built With
- langchain
- mistral
- ollama
- python
- sqlalchemy
- streamlit
- tidb
- vscode

Log in or sign up for Devpost to join the conversation.