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

FieldDetails
Project NameLoanmind AI
Version1.0
Created DateJune 09, 2026
Last UpdatedJune 09, 2026
AuthorDeX AI Generator
StatusDraft

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

FeatureDescriptionModulePriority
User Onboarding & Application CreationAllows MSME applicants to register using their mobile number and initiate a new loan application.Application & Document IngestionMust Have
Multi-Document Upload & ProcessingSecurely upload various business documents (PDF, JPG, PNG).Application & Document IngestionMust Have
AI-Powered OCR & ClassificationAutomatically identifies document types and extracts key-value pairs into structured JSON.AI Processing & OrchestrationMust Have
Dynamic Question GenerationAI analyzes uploaded data to generate a contextual Q&A set to fill information gaps.AI Processing & OrchestrationMust Have
Interactive Voice InterviewA voice-driven interface in the mobile app to guide applicants through the generated questions.Interactive InterviewMust Have
Background Report GenerationA pipeline of chained AI calls to generate a suite of 6 MSME business health reports.Report Generation & DeliveryMust Have
Secure Document ManagementAll application-related artifacts are stored in a structured, hierarchical folder system in Alfresco.Core InfrastructureMust Have
Application Status TrackingReal-time status updates are provided to the applicant via the Flutter mobile app.Application & Document IngestionMust Have
Report Dashboard & ExportApplicants can view, download, and share the generated markdown and PDF reports.Report Generation & DeliveryMust Have
CMA Premium WorkflowA separate, paid workflow for generating comprehensive CMA reports, including financial projections.Report Generation & DeliveryShould Have
Bank/Underwriter PortalA web-based interface for credit officers to view and assess completed application packages.Bank & Admin PortalShould Have

3.3 User Classes & Characteristics

User ClassDescriptionAccess LevelTechnical Level
MSME ApplicantA business owner or representative applying for a loan. They primarily interact with the Flutter mobile application.Limited (Own Application Data)Low
Bank Credit OfficerAn 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 AdministratorA Loanmind AI technical staff member responsible for system monitoring, user management, and maintenance.Full System AccessHigh

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 IDAs a...I want to...So that...Priority
US-101New MSME ApplicantRegister and log in using my mobile number and an OTP.I can securely start and manage my loan application.Must Have
US-102MSME ApplicantCreate 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-103MSME ApplicantSee a dynamic checklist of required documents based on my application type.I know exactly what I need to submit.Must Have
US-104MSME ApplicantUpload multiple documents (PDF, JPG, PNG) simultaneously from my phone.I can complete the submission process efficiently.Must Have
US-105MSME ApplicantSee 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:

ComponentTypeBehaviorValidation
Document ListListViewDisplays items like "Aadhaar Card," "PAN Card," "Bank Statement."N/A
Upload ButtonButtonOpens the device's file picker. Allows selection of PDF, JPG, PNG files.File size < 10MB per file.
Status IndicatorIcon/TextInitially "Pending." Changes to a spinner for "Processing," a green check for "Verified," and a red cross for "Error."N/A
"Proceed to Interview" ButtonButtonInitially disabled. Becomes enabled only when all "Must Have" documents are in "Verified" status.N/A

Actions & Events:

ActionTriggerAPI CallResponseError Handling
Upload DocumentUser 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 StatusAutomatic 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 IDDescriptionConditionAction
BR-101Application State ProgressionAll 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-102Document Re-uploadA 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

EndpointMethodRequest BodyResponseStatus Codes
/api/v1/auth/otpPOST{"mobile": "string"}{"message": "OTP sent"}200, 400
/api/v1/auth/verifyPOST{"mobile": "string", "otp": "string"}{"token": "jwt_token"}200, 401
/api/v1/msme-applicationPOST{"loan_amount": float, "purpose": "string"}{"application_number": "uuid"}201
/api/v1/msme-application/upload/{app_num}/{doc_type}POSTmultipart/form-data with file{"job_id": "uuid", "message": "Processing started"}202, 400, 404
/api/v1/msme-application/status/{app_num}GETN/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 IDDescriptionConditionAction
BR-201OCR Confidence ThresholdThe 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-202Data Mismatch DetectionThe 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-203Question Generation TriggerThe 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)

EndpointMethodRequest BodyResponseStatus Codes
/api/v1/msme-application/interview-questions/{app_num}GETN/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 IDAs a...I want to...So that...Priority
US-301MSME ApplicantBe 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-302MSME ApplicantHear the question read out loud and see it on the screen.I can understand the question clearly.Must Have
US-303MSME ApplicantRecord my spoken answer for each question.My detailed operational context is captured.Must Have
US-304MSME ApplicantReview the transcribed text of my answer and edit it before confirming.I can ensure the system captured my response accurately.Should Have
US-305MSME ApplicantSubmit 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:

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

Actions & Events:

ActionTriggerAPI CallResponseError Handling
Start InterviewUser 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 TranscriptUser taps "Submit Interview".POST /api/v1/msme-application/upload/{app_num}/master-conversation with markdown file in body.202 AcceptedShow "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:

ComponentTypeBehaviorValidation
Report ListListViewShows report titles like "Key Points Analysis," "Banking Analysis."N/A
Markdown ViewerViewRenders the content of the selected .md file using the flutter_markdown package.N/A
Export PDF ButtonButtonOn tap, generates a single PDF containing all reports and prompts the user to save/share it.N/A

Actions & Events:

ActionTriggerAPI CallResponseError Handling
View ReportUser taps a report title.GET /api/v1/msme-application/report/{app_num}/{report_name}.md200 OK with markdown content.Display an error message if the report cannot be fetched.

5. Cross-Cutting Concerns

5.1 Authentication & Authorization

FeatureSpecification
Login MethodMobile Number + OTP for MSME Applicants. Email/Password for Admins/Bank Officers.
Session ManagementStateless 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 AccessMSME 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 TypeTriggerChannelTemplate
Document VerifiedA single document's AI processing completes successfully.In-App / Push"Your [Doc Type] has been verified successfully."
All Documents VerifiedApplication status changes to DOC_COMPLETE.In-App / Push"All your documents are verified! Please proceed to the voice interview."
Reports ReadyApplication status changes to COMPLETED.In-App / Push / SMS"Your Loanmind AI credit analysis reports are now ready to view."
Document ErrorA 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 CodeDescriptionUser MessageAction
AUTH-401Invalid or expired JWT token."Your session has expired. Please log in again."Redirect user to the login screen.
UPLOAD-400Invalid 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-404Application number not found."We could not find your application. Please try again or contact support."Guide user back to the home screen.
AI-503AI 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

EventLogged FieldsRetention
User LoginUser ID, Timestamp, IP Address, User-Agent1 Year
Application CreationUser ID, Application Number, Timestamp7 Years
Document UploadUser ID, Application Number, Document Type, Filename, Alfresco Node ID, Timestamp7 Years
Report GeneratedApplication Number, Report Name, Timestamp, AI Model Version Used7 Years
Status ChangeApplication Number, Old Status, New Status, Timestamp7 Years

6. Data Validation Rules

FieldTypeRequiredMinMaxPatternCustom Rules
mobile_numberStringYes1010^[6-9]\d{9}$Must be a valid Indian mobile number. Unique across users.
otpStringYes66^\d{6}$N/A
pan_numberStringYes1010^[A-Z]{5}[0-9]{4}[A-Z]{1}$Must be a valid PAN format.
aadhaar_numberStringYes1212^\d{12}$Must pass Luhn algorithm check.
loan_amountFloatYes5000050000000N/AMust be a positive number.

7. Integration Specifications

7.1 External System Integrations

SystemTypeDirectionData FormatFrequency
Google Gemini APIAPIOutboundJSONReal-time
Alfresco Content ServicesAPI (CMIS)OutboundJSON / MultipartReal-time
SMS Gateway (e.g., Twilio)APIOutboundJSONReal-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)

ReportDescriptionData SourceFiltersExport Format
Application ThroughputTracks the number of applications created, processed, and completed over time.PostgreSQL applications tableDate Range, StatusCSV, PDF
AI Processing TimesMeasures the average time taken for OCR and report generation steps.PostgreSQL audit_logs tableDate Range, Document TypeCSV
User Activity ReportShows daily/monthly active users and engagement metrics.PostgreSQL users & audit_logs tablesDate RangeCSV

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

VersionDateAuthorChanges
1.0June 09, 2026DeX AI GeneratorInitial 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.