Skip to content

rida-118-sam/CDSS

Repository files navigation

CDSS App

Flutter + FastAPI CT Analysis System


📌 Overview

CDSS App is a Flutter-based medical image analysis application that connects to a locally hosted FastAPI backend.

The app:

  • Sends multiple CT scan images to a FastAPI server
  • Receives a structured medical report (text format)
  • Converts the report into an image
  • Displays and stores the result locally

🔄 Complete Workflow

  1. User selects multiple images
  2. App sends images to FastAPI backend (/analyze)
  3. Backend processes images using AI model
  4. Backend returns JSON response containing:
    • success
    • refined_report
  5. App converts the report text into a PNG image
  6. Result is displayed and saved in local database

🏗️ System Architecture

Flutter App
     ↓
POST /analyze (multipart/form-data)
     ↓
FastAPI Server (Laptop)
     ↓
AI Model Processing
     ↓
JSON Response (refined_report)
     ↓
Flutter converts text → Image
     ↓
Display + Store in DB

⚙️ Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • python-multipart
  • Flutter SDK
  • Laptop and phone connected to same WiFi network

🚀 Backend Setup

1️⃣ Install Dependencies

pip install fastapi uvicorn python-multipart

2️⃣ Run Server

uvicorn app:app --host 0.0.0.0 --port 8000

0.0.0.0 is required to allow phone access.


3️⃣ Get Laptop IPv4 Address

Open Command Prompt:

ipconfig

Find:

IPv4 Address : 10.115.206.17

Your API base URL becomes:

http://10.115.206.17:8000

🌐 API Endpoint Used in App

POST /analyze

POST http://<YOUR_IP>:8000/analyze

Request Type

  • Method: POST
  • Content-Type: multipart/form-data
  • Field name: files
  • Multiple images allowed

📥 Expected Backend Response Format

The backend must return JSON in this format:

{
  "success": true,
  "refined_report": "Detailed CT analysis report text here..."
}

If "success" is not true, the app throws an error.


📱 Flutter Implementation (submit_page.dart)

The app sends images using:

final uri = Uri.parse("http://10.115.206.17:8000/analyze");
final request = http.MultipartRequest("POST", uri);

for (final img in widget.images) {
  request.files.add(
    await http.MultipartFile.fromPath("files", img.path),
  );
}

After receiving response:

  • JSON is decoded
  • refined_report is extracted
  • Text is converted into PNG image
  • Image is stored in local database
  • Output page is shown

🖼️ Text to Image Conversion

The app dynamically converts the medical report into a PNG file using Flutter Canvas API.

This ensures:

  • Structured medical report view
  • Saveable image output
  • Easy storage in DB

🧪 Testing Backend

Open in browser:

http://<YOUR_IP>:8000/docs

Use Swagger UI to test /analyze endpoint.


🌐 Network Requirements

  • Laptop and phone must be on same WiFi
  • Firewall must allow port 8000
  • Backend must be running
  • IPv4 address must match the one in submit_page.dart

❗ Common Errors

Phone cannot connect

  • Check same WiFi
  • Verify IPv4 address
  • Ensure --host 0.0.0.0
  • Check firewall settings

JSON decode error

  • Ensure backend returns proper JSON
  • Ensure success field exists

📂 Project Structure

cdss_app/
│
├── lib/
│   ├── submit_page.dart
│   ├── data/
│   └── ml/
│
├── backend/
│   └── app.py
│
└── README.md

📌 Notes

  • IP address may change when WiFi reconnects.
  • For production deployment:
    • Use cloud hosting
    • Use HTTPS
    • Do not hardcode IP address

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors