Skip to main content

Sample FSD - Loanmind AI

📌 This is the full, unabbreviated Functional Specification Document DeX generated for Loanmind AI, completing the specification trio alongside the Sample BRD and Sample SRD. It breaks the platform down module-by-module into concrete, testable functional behavior - screen specifications, business rules, API endpoints, state diagrams, and validation rules.

For the trimmed, Contractor Sync version of this document, see Specification - FSD & SRD.


1. Document Information​

Field Details
Project Name Loanmind AI
Version 1.0
Created Date June 09, 2026
Last Updated June 09, 2026
Author DeX AI Generator
Status Draft

2. Introduction​

2.1 Purpose​

This document provides a detailed functional specification for the Loanmind AI platform. It outlines the system's features, capabilities, user workflows, and technical requirements. The purpose is to serve as a comprehensive guide for the development, quality assurance, and project management teams, ensuring a shared understanding of the final product.

2.2 Intended Audience​

This document is intended for:

  • Software Developers & Engineers: To understand the technical requirements, API contracts, and business logic for implementation.
  • Quality Assurance (QA) Team: To create test cases and scenarios for verifying system functionality.
  • Project Managers & Product Owners: To track project scope, features, and progress.
  • System Architects: To ensure the solution design aligns with the specified functional requirements.
  • Stakeholders: To review and approve the planned functionality of the system.

2.3 Document Conventions​

  • Must Have: A mandatory feature for the initial release (MVP).
  • Should Have: A high-priority feature that should be included if time and resources permit.
  • Could Have: A desirable feature that can be postponed to a future release.
  • API Endpoint: Refers to a RESTful API endpoint, e.g., POST /api/v1/applications.
  • User Class: Refers to a specific type of user, e.g., MSME Applicant.

3. Product Overview​

3.1 Product Perspective​

Loanmind AI is a cloud-native, AI-powered Software-as-a-Service (SaaS) platform designed to revolutionize MSME and CMA business loan underwriting. It acts as an intelligent intermediary layer between MSME loan applicants and financial institutions (Banks, NBFCs). The system ingests raw, unstructured applicant data, transforms it into structured, decision-ready credit intelligence, and presents it to underwriters, thereby drastically reducing friction, cost, and time-to-decision. It integrates with external AI services (Google Gemini) for its core intelligence and a robust DMS (Alfresco) for auditable document management.

3.2 Product Features Summary​

Feature Description Module Priority
User Onboarding & Application Creation Allows MSME applicants to register using their mobile number and initiate a new loan application. Application & Document Ingestion Must Have
Multi-Document Upload & Processing Securely upload various business documents (PDF, JPG, PNG). Application & Document Ingestion Must Have
AI-Powered OCR & Classification Automatically identifies document types and extracts key-value pairs into structured JSON. AI Processing & Orchestration Must Have
Dynamic Question Generation AI analyzes uploaded data to generate a contextual Q&A set to fill information gaps. AI Processing & Orchestration Must Have
Interactive Voice Interview A voice-driven interface in the mobile app to guide applicants through the generated questions. Interactive Interview Must Have
Background Report Generation A pipeline of chained AI calls to generate a suite of 6 MSME business health reports. Report Generation & Delivery Must Have
Secure Document Management All application-related artifacts are stored in a structured, hierarchical folder system in Alfresco. Core Infrastructure Must Have
Application Status Tracking Real-time status updates are provided to the applicant via the Flutter mobile app. Application & Document Ingestion Must Have
Report Dashboard & Export Applicants can view, download, and share the generated markdown and PDF reports. Report Generation & Delivery Must Have
CMA Premium Workflow A separate, paid workflow for generating comprehensive CMA reports, including financial projections. Report Generation & Delivery Should Have
Bank/Underwriter Portal A web-based interface for credit officers to view and assess completed application packages. Bank & Admin Portal Should Have

3.3 User Classes & Characteristics​

User Class Description Access Level Technical Level
MSME Applicant A business owner or representative applying for a loan. They primarily interact with the Flutter mobile application. Limited (Own Application Data) Low
Bank Credit Officer An employee of a financial institution responsible for reviewing loan applications. They use a web-based portal to access finalized reports. Role-Based (Assigned Applications) Medium
System Administrator A Loanmind AI technical staff member responsible for system monitoring, user management, and maintenance. Full System Access High

4. Functional Specifications by Module​

4.1 Module: Application & Document Ingestion​

4.1.1 Overview​

This module handles the initial stages of the loan application process, from user registration to the successful upload and initial validation of all required documents. It is the primary interface for the MSME Applicant via the Flutter mobile app.

4.1.2 User Stories​

Story ID As a... I want to... So that... Priority
US-101 New MSME Applicant Register and log in using my mobile number and an OTP. I can securely start and manage my loan application. Must Have
US-102 MSME Applicant Create a new loan application by providing basic details like loan amount and purpose. The system can initiate an application case file for me. Must Have
US-103 MSME Applicant See a dynamic checklist of required documents based on my application type. I know exactly what I need to submit. Must Have
US-104 MSME Applicant Upload multiple documents (PDF, JPG, PNG) simultaneously from my phone. I can complete the submission process efficiently. Must Have
US-105 MSME Applicant See the status of each uploaded document (e.g., "Processing," "Verified," "Error"). I can track progress and correct any issues. Must Have

4.1.3 Functional Flow​

[Start] → [User Enters Mobile Number] → [Request OTP] → [Verify OTP] → [Authenticated]
├── [Create New Application] → [Generate Application Number] → [Display Document Checklist]
└── [View Existing Application] → [Display Document Checklist]

[Display Document Checklist] → [User Selects & Uploads Document(s)] → [API Call to Backend] → [Backend Saves to Alfresco & Triggers AI Processing] → [Poll for Status] → [Update Checklist UI with Checkmark]

4.1.4 Screen Specifications​

Screen: Document Verification Page​
  • URL/Route: /application/{application_number}/documents
  • Access: Authenticated MSME Applicant
  • Layout: A vertically scrolling list view showing required document categories. Each list item displays the document name, an upload button, and a status indicator.

UI Components:

Component Type Behavior Validation
Document List ListView Displays items like "Aadhaar Card," "PAN Card," "Bank Statement." N/A
Upload Button Button Opens the device's file picker. Allows selection of PDF, JPG, PNG files. File size < 10MB per file.
Status Indicator Icon/Text Initially "Pending." Changes to a spinner for "Processing," a green check for "Verified," and a red cross for "Error." N/A
"Proceed to Interview" Button Button Initially disabled. Becomes enabled only when all "Must Have" documents are in "Verified" status. N/A

Actions & Events:

Action Trigger API Call Response Error Handling
Upload Document User taps "Upload" and selects a file. POST /api/v1/msme-application/upload/{application_number}/{doc_type} 202 Accepted with a processing Job ID. Show "Upload Failed" toast message on 4xx/5xx errors.
Check Status Automatic polling every 10 seconds after an upload. GET /api/v1/msme-application/status/{application_number} 200 OK with a JSON object detailing the status of each document. Continue polling silently. If polling fails 3 times, show a "Could not refresh status" message.

4.1.5 Business Rules​

Rule ID Description Condition Action
BR-101 Application State Progression All mandatory documents for the application have a status of DOC_COMPLETE. The application state moves from DOC_PROCESSING to DOC_COMPLETE. The "Proceed to Interview" button is enabled.
BR-102 Document Re-upload A user uploads a document for a type that already exists (e.g., another Aadhaar card). The system versions the old file in Alfresco and replaces the current one. The AI processing pipeline is re-triggered for that document.

4.1.6 API Endpoints​

Endpoint Method Request Body Response Status Codes
/api/v1/auth/otp POST {"mobile": "string"} {"message": "OTP sent"} 200, 400
/api/v1/auth/verify POST {"mobile": "string", "otp": "string"} {"token": "jwt_token"} 200, 401
/api/v1/msme-application POST {"loan_amount": float, "purpose": "string"} {"application_number": "uuid"} 201
/api/v1/msme-application/upload/{app_num}/{doc_type} POST multipart/form-data with file {"job_id": "uuid", "message": "Processing started"} 202, 400, 404
/api/v1/msme-application/status/{app_num} GET N/A {"status": "DOC_PROCESSING", "documents": [...]} 200, 404

4.2 Module: AI Processing & Orchestration​

4.2.1 Overview​

This backend module is the core intelligence of Loanmind AI. It is responsible for receiving uploaded documents, orchestrating calls to external AI services for OCR and analysis, generating contextual questions, and triggering the final report generation pipeline. It has no user-facing interface.

4.2.2 Functional Flow​

[Document Uploaded to Alfresco] → [Webhook/Event Trigger] → [Start AI Processing Job]
└── [1. Classify Document Type (e.g., PAN, Aadhaar)]
└── [2. Call Gemini Vision API for OCR]
└── [3. Extract Key-Value Pairs using Gemini Function Calling]
└── [4. Validate Extracted Data (e.g., PAN format)]
└── [5. Save Extracted JSON to Alfresco]
└── [6. Update Application Status in PostgreSQL]

[All Docs Processed & Status = DOC_COMPLETE] → [Trigger Question Generation]
└── [1. Gather all extracted JSON data]
└── [2. Craft Prompt for Gemini with all context]
└── [3. Gemini returns a set of questions]
└── [4. Save questions.json to Alfresco]
└── [5. Notify Frontend that questions are ready]

4.2.3 Business Rules​

Rule ID Description Condition Action
BR-201 OCR Confidence Threshold The confidence score for a key extracted field (e.g., Aadhaar Number) is below 95%. The document status is marked as "Error: Low Confidence" and prompts the user to re-upload a clearer image.
BR-202 Data Mismatch Detection The name extracted from the PAN card does not match the name extracted from the Aadhaar card. A specific question is added to the generated question set: "We noticed a name discrepancy between your PAN and Aadhaar documents. Please clarify your full legal name."
BR-203 Question Generation Trigger The application state moves to DOC_COMPLETE. The system automatically initiates the question generation workflow.

4.2.4 API Endpoints​

(Primarily internal logic, but exposes endpoints for the frontend to retrieve results)

Endpoint Method Request Body Response Status Codes
/api/v1/msme-application/interview-questions/{app_num} GET N/A {"questions": ["question1", "question2", ...]} 200, 404

4.3 Module: Interactive Interview​

4.3.1 Overview​

This module, implemented in the Flutter application, provides the voice-based Q&A experience for the MSME Applicant. It fetches the dynamically generated questions, captures the user's spoken responses, transcribes them, and submits the final conversation log.

4.3.2 User Stories​

Story ID As a... I want to... So that... Priority
US-301 MSME Applicant Be guided through a series of questions one by one via a voice assistant. I can easily provide nuanced details about my business without typing. Must Have
US-302 MSME Applicant Hear the question read out loud and see it on the screen. I can understand the question clearly. Must Have
US-303 MSME Applicant Record my spoken answer for each question. My detailed operational context is captured. Must Have
US-304 MSME Applicant Review the transcribed text of my answer and edit it before confirming. I can ensure the system captured my response accurately. Should Have
US-305 MSME Applicant Submit the completed interview transcript to the system. The final report generation process can begin. Must Have

4.3.3 Screen Specifications​

Screen: Voice Assistant Interview​
  • URL/Route: /application/{application_number}/interview
  • Access: Authenticated MSME Applicant (application status must be DOC_COMPLETE)
  • Layout: A clean, minimalist interface showing the current question number (e.g., "3 of 8"), the question text, a large microphone button, and navigation buttons ("Next," "Previous").

UI Components:

Component Type Behavior Validation
Question Display Text Shows the current question fetched from the backend. N/A
Microphone Button Button Tapping starts the device's microphone recording. Tapping again stops it. A visualizer indicates that it's listening. Requires microphone permissions from the OS.
Transcript Box Text Area (Optional, for review) Displays the speech-to-text result of the recording. N/A
"Submit Interview" Button Button Appears on the last question. Submits the full conversation. Enabled only when all questions have a recorded answer.

Actions & Events:

Action Trigger API Call Response Error Handling
Start Interview User navigates to the interview screen. GET /api/v1/msme-application/interview-questions/{app_num} 200 OK with JSON array of questions. Show error message and "Try Again" button if API fails.
Submit Transcript User taps "Submit Interview". POST /api/v1/msme-application/upload/{app_num}/master-conversation with markdown file in body. 202 Accepted Show "Submission Failed" message.

4.4 Module: Report Generation & Delivery​

4.4.1 Overview​

This module encompasses the backend pipeline for generating the suite of MSME analysis reports and the frontend dashboard for the applicant to view and download them. The pipeline is triggered upon the upload of the master-conversation.md file.

4.4.2 Functional Flow (Backend Pipeline)​

This flow is executed asynchronously as described in the project brief.

[master-conversation.md Uploaded to Alfresco] → [Trigger Report Generation Pipeline]
└── [Step 1: Gather Context (all JSONs + conversation)]
└── [Step 2: Call Gemini API for msme_keypoints_analysis.md] → [Save to Alfresco]
└── [Step 3: Call Gemini API for msme_banking_analysis.md (Context + Keypoints)] → [Save to Alfresco]
└── [Step 4: Call Gemini API for msme_financial_analysis.md (Context + Banking)] → [Save to Alfresco]
└── [Step 5: Call Gemini API for msme_loan_analysis.md (...)] → [Save to Alfresco]
└── [Step 6: Call Gemini API for msme_loan_assessment.md (...)] → [Save to Alfresco]
└── [Step 7: Call Gemini API for msme_loan_summary.md (...)] → [Save to Alfresco]
└── [Final Step: Update Application Status to COMPLETED in DB & Send Push Notification]

4.4.3 Screen Specifications​

Screen: Report Dashboard​
  • URL/Route: /application/{application_number}/reports
  • Access: Authenticated MSME Applicant (application status must be COMPLETED)
  • Layout: A list of generated reports. Each item is tappable to view the content. A "Download All as PDF" button is present at the top.

UI Components:

Component Type Behavior Validation
Report List ListView Shows report titles like "Key Points Analysis," "Banking Analysis." N/A
Markdown Viewer View Renders the content of the selected .md file using the flutter_markdown package. N/A
Export PDF Button Button On tap, generates a single PDF containing all reports and prompts the user to save/share it. N/A

Actions & Events:

Action Trigger API Call Response Error Handling
View Report User taps a report title. GET /api/v1/msme-application/report/{app_num}/{report_name}.md 200 OK with markdown content. Display an error message if the report cannot be fetched.

5. Cross-Cutting Concerns​

5.1 Authentication & Authorization​

Feature Specification
Login Method Mobile Number + OTP for MSME Applicants. Email/Password for Admins/Bank Officers.
Session Management Stateless JWT (JSON Web Tokens). Token to be stored securely on the client device and sent in the Authorization header. Token expiry: 24 hours.
Password Policy (For Admin/Banker) Minimum 12 characters, 1 uppercase, 1 lowercase, 1 number, 1 special character.
Role-Based Access MSME Applicant: Can only access their own application data.
Bank Credit Officer: Can access applications assigned to them or their branch pool. Read-only access to PII.
Admin: Full CRUD access on all system data.

5.2 Notification System​

Notification Type Trigger Channel Template
Document Verified A single document's AI processing completes successfully. In-App / Push "Your [Doc Type] has been verified successfully."
All Documents Verified Application status changes to DOC_COMPLETE. In-App / Push "All your documents are verified! Please proceed to the voice interview."
Reports Ready Application status changes to COMPLETED. In-App / Push / SMS "Your Loanmind AI credit analysis reports are now ready to view."
Document Error A document fails processing (e.g., unreadable). In-App / Push "There was an issue processing your [Doc Type]. Please upload a clearer copy."

5.3 Error Handling​

Error Code Description User Message Action
AUTH-401 Invalid or expired JWT token. "Your session has expired. Please log in again." Redirect user to the login screen.
UPLOAD-400 Invalid file type or size. "Upload failed. Please ensure the file is a PDF, JPG, or PNG and is under 10MB." Inform user, do not retry.
APP-404 Application number not found. "We could not find your application. Please try again or contact support." Guide user back to the home screen.
AI-503 AI Service (Gemini) is unavailable or timing out. "Our analysis service is temporarily busy. Please try again in a few moments." Implement exponential backoff for retries on the backend.

5.4 Audit Trail​

Event Logged Fields Retention
User Login User ID, Timestamp, IP Address, User-Agent 1 Year
Application Creation User ID, Application Number, Timestamp 7 Years
Document Upload User ID, Application Number, Document Type, Filename, Alfresco Node ID, Timestamp 7 Years
Report Generated Application Number, Report Name, Timestamp, AI Model Version Used 7 Years
Status Change Application Number, Old Status, New Status, Timestamp 7 Years

6. Data Validation Rules​

Field Type Required Min Max Pattern Custom Rules
mobile_number String Yes 10 10 ^[6-9]\d{9}$ Must be a valid Indian mobile number. Unique across users.
otp String Yes 6 6 ^\d{6}$ N/A
pan_number String Yes 10 10 ^[A-Z]{5}[0-9]{4}[A-Z]{1}$ Must be a valid PAN format.
aadhaar_number String Yes 12 12 ^\d{12}$ Must pass Luhn algorithm check.
loan_amount Float Yes 50000 50000000 N/A Must be a positive number.

7. Integration Specifications​

7.1 External System Integrations​

System Type Direction Data Format Frequency
Google Gemini API API Outbound JSON Real-time
Alfresco Content Services API (CMIS) Outbound JSON / Multipart Real-time
SMS Gateway (e.g., Twilio) API Outbound JSON Real-time

7.2 Integration Flow Diagrams​

1. Document OCR & Extraction Flow: FastAPI Backend → Alfresco (Save File) → FastAPI Worker → Google Gemini API (Process Image/PDF) → FastAPI Worker → Alfresco (Save JSON)

2. Report Generation Flow: FastAPI (Trigger) → Gather Context (PostgreSQL/Alfresco) → Loop (Call Gemini API for each report) → Alfresco (Save .md report)


8. Reporting & Analytics​

(This section refers to internal, operational reports for the System Administrator)

Report Description Data Source Filters Export Format
Application Throughput Tracks the number of applications created, processed, and completed over time. PostgreSQL applications table Date Range, Status CSV, PDF
AI Processing Times Measures the average time taken for OCR and report generation steps. PostgreSQL audit_logs table Date Range, Document Type CSV
User Activity Report Shows daily/monthly active users and engagement metrics. PostgreSQL users & audit_logs tables Date Range CSV

9. State Diagrams​

9.1 MSME Application State Machine​

This diagram outlines the lifecycle of a loan application as tracked in the msme_status.txt file and the primary database.

[INITIATED] --(Create Application)--> [DOC_PROCESSING] --(All Docs Uploaded & Verified)--> [DOC_COMPLETE]

[DOC_COMPLETE] --(User Submits Interview)--> [CONV_UPLOADED] --(Backend starts pipeline)--> [IN_PROGRESS]

[IN_PROGRESS] --(All Reports Generated)--> [COMPLETED]

-- States can also transition to an ERROR state from DOC_PROCESSING or IN_PROGRESS if a fatal, unrecoverable error occurs. --
  • INITIATED: Application case created, but no documents uploaded yet.
  • DOC_PROCESSING: User has started uploading documents; AI processing is ongoing.
  • DOC_COMPLETE: All required documents are successfully processed. Awaiting user interview.
  • CONV_UPLOADED: User has completed and submitted the voice interview.
  • IN_PROGRESS: The backend report generation pipeline is actively running.
  • COMPLETED: All reports have been generated and are available to the user.
  • ERROR: A terminal error occurred (e.g., critical document is unreadable after multiple attempts).

10. Appendix​

A. Wireframe References​

  • Mobile App Onboarding & Document Upload: [Link to Figma/Balsamiq Wireframes - Onboarding_v1.pdf]
  • Mobile App Voice Interview Interface: [Link to Figma/Balsamiq Wireframes - Interview_v1.pdf]
  • Mobile App Report Dashboard: [Link to Figma/Balsamiq Wireframes - Reports_v1.pdf]

B. API Response Examples​

Sample for aadhaar_extracted_data.json:

{
"document_type": "Aadhaar",
"name": "VIKRAM KUMAR",
"dob": "15/03/1988",
"gender": "MALE",
"aadhaar_number": "xxxx xxxx 4321",
"address": "123, MG Road, Koramangala, Bengaluru, Karnataka 560034",
"confidence_scores": {
"name": 0.98,
"dob": 0.99,
"aadhaar_number": 0.99
},
"extraction_timestamp": "2026-06-10T14:30:00Z"
}

C. Revision History​

Version Date Author Changes
1.0 June 09, 2026 DeX AI Generator Initial creation of the Functional Specification Document.

What's Next​

➡️ Plan, Build & Code - See how an approved BRD/SRD/FSD trio like this one flows into sprint planning, Build Access, and the Git-based code workspace.