Swift-Query / documentation /backend_general.md
Darshan Kumar R
Deploy to Hugging Face Spaces (Clean)
ed0b977
|
Raw History Blame Contribute Delete
2.34 kB

SwiftQuery Backend Documentation

Overview

SwiftQuery is a Flask-based web application designed to assist doctors with patient management, clinical note enhancement, and AI-powered insights. It uses MongoDB as its primary database and integrates various AI services (Google Gemini, Groq, CyborgDB).

Architecture

  • Framework: Flask (Python)
  • Database: MongoDB (accessed via Flask-PyMongo)
  • Authentication: Session-based with bcrypt for password hashing.
  • AI Integration: Modular agents in ai_agents/ for RAG and text processing.

Key Directories

  • utils/blueprints/: Contains the route logic for different user roles (Admin, Doctor, Patient, Assistant, Chat).
  • utils/db/: Database configuration (db.py) and schema definitions.
  • ai_agents/: Logic for RAG pipelines and clinical summaries.
  • static/ & templates/: Frontend assets and HTML files.

Setup & Configuration

  1. Environment Variables: Managed via .env (requires MONGO_URI, GOOGLE_AI_API_KEY, GROQ_API_KEY, CYBORGDB_API_KEY, SECRET_KEY).
  2. Dependencies: Listed in requirements.txt. Install via pip install -r requirements.txt.
  3. Run: Execute python main.py to start the server.

Blueprints

1. Auth (auth.py)

  • Handles user login for all roles (Doctor, Admin, Patient, Assistant).
  • Manages session creation and destruction (/logout).

2. Admin (admin.py)

  • Manage Users: Add/Delete Doctors, Assistants, and Patients.
  • Patient ID: Generates structured IDs like SQ-2024-001.

3. Doctor (doctor.py)

  • Dashboard: View assigned patients.
  • Session Management: Start/End sessions to activate AI context.
  • Recording: Upload audio for transcription.

4. Patient (patient.py)

  • Read-Only Access: View medical history, consultations, reports, and bills.
  • Reports: Download test reports.

5. Assistant (assistant.py)

  • Data Entry: Add medical records (History, Consultations, Tests, Treatments) for patients.
  • Account Creation: Helper interface for creating new accounts.

Database Schema

Collections include:

  • patient: Core profile.
  • doctor, admin, administrativeassistant: User roles.
  • medicalhistory, consultation, testreport, treatment: Clinical records.
  • chatsession, chatmessage: AI interaction logs.