update the architecture & description #1

Merged
msk_admin merged 1 commits from update_ into main 2026-06-24 03:35:20 +00:00
Contributor

Summary by CodeRabbit

Release Notes

  • New Features

    • Launched web interface for image analysis supporting drag-and-drop file upload, multi-model selection, and segmentation overlay visualization.
    • Enabled PDF report generation with patient data management, save, and export functionality.
  • Documentation

    • Added detailed architecture specifications covering system design and deployment topology.
    • Updated infrastructure component documentation (pgvector embeddings storage, cloud/browser LLM integration).
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Launched web interface for image analysis supporting drag-and-drop file upload, multi-model selection, and segmentation overlay visualization. * Enabled PDF report generation with patient data management, save, and export functionality. * **Documentation** * Added detailed architecture specifications covering system design and deployment topology. * Updated infrastructure component documentation (pgvector embeddings storage, cloud/browser LLM integration). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-06-24 03:35:00 +00:00 (Migrated from github.com)

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 174d111b-6b35-41da-8481-a249cde088e0

📥 Commits

Reviewing files that changed from the base of the PR and between 16a91bd17e and f705113711.

Files ignored due to path filters (7)
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Bold.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Italic.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Regular.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/arial.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/arialbd.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/ariali.ttf is excluded by !**/*.ttf
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/logo.png is excluded by !**/*.png
📒 Files selected for processing (70)
  • README.md
  • proj_level_reading/ARCHITECT/SOFTWARE_ARCHITECTURE_SPEC.md
  • proj_level_reading/ARCHITECT/SOLUTION_ARCHITECTURE_SPEC.md
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/Dockerfile
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/pdf_service.py
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/css/style.css
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/index.html
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/js/script.js
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ML/requirements.txt
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/README.md
  • workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/architecture-review.html
  • workspace/LEGACY/VKIST_ML/docs/Instruction_Manunal_API_Doc_Setup_pilot.md
  • workspace/LEGACY/VKIST_ML/docs/PILOT_TECH_DESC.md
  • workspace/LEGACY/VKIST_ML/docs/VKIST_ULTRASOUND_INTRODUCE_SPEC.md
  • workspace/LEGACY/VKIST_ML/docs/arch_code_analysis.md
  • workspace/sprint_1_2/CODEBASE/backend/spec/backend-spec.md
  • workspace/sprint_1_2/CODEBASE/backend/spec/interface-contract.md
  • workspace/sprint_1_2/CODEBASE/data/spec/data_spec.md
  • workspace/sprint_1_2/CODEBASE/data/spec/interface_contract.md
  • workspace/sprint_1_2/CODEBASE/frontend/spec/frontend_spec.md
  • workspace/sprint_1_2/CODEBASE/frontend/spec/interface_contract.md
  • workspace/sprint_1_2/CODEBASE/frontend/subprojects/offline/spec/interface_contract.md
  • workspace/sprint_1_2/CODEBASE/frontend/subprojects/offline/spec/offline_spec.md
  • workspace/sprint_1_2/CODEBASE/infra/implementation/cicd/jenkin_run.sh
  • workspace/sprint_1_2/CODEBASE/infra/implementation/observability/docker-compose.yaml
  • workspace/sprint_1_2/CODEBASE/infra/implementation/observability/prometheus.yml
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_convnext_tiny/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_densenet/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_efficientnet/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_resnet50/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_swin_v2_s/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/generate_ensemble.py
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/inflammation_model_efficientnet_b0_ultrasound_2_cls/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/msk_vision_pipeline_ensemble/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_deeplabv3/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_deeplabv3_resnet101/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_efficientfeedback/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_unet3plus_att/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_unet_resnet101/config.pbtxt
  • workspace/sprint_1_2/CODEBASE/infra/implementation/s3/upload_ensemble.py
  • workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_file.sh
  • workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_2.sh
  • workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_3.sh
  • workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_4.sh
  • workspace/sprint_1_2/CODEBASE/infra/implementation/triton_run/modal_triton.py
  • workspace/sprint_1_2/CODEBASE/infra/implementation/triton_run/run.sh
  • workspace/sprint_1_2/CODEBASE/infra/spec/infra_spec.md
  • workspace/sprint_1_2/CODEBASE/infra/spec/interface_contract.md
  • workspace/sprint_1_2/CODEBASE/knowledge/spec/interface_contract.md
  • workspace/sprint_1_2/CODEBASE/knowledge/spec/knowledge_spec.md
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/efficientfeedback.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/__init__.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/automatic_mask_generator.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/build_sam.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/__init__.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/common.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/image_encoder.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/mask_decoder.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/prompt_encoder.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/sam.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/transformer.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/predictor.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/__init__.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/amg.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/onnx.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/transforms.py
  • workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/unet3plus_att.py
  • workspace/sprint_1_2/Design_Material/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy
  • workspace/sprint_1_2/SPRINT_1_2_ARCHITECTURE_SPEC.md

📝 Walkthrough

Walkthrough

The PR adds two project-level architecture specification documents (solution and software architecture) under proj_level_reading/ARCHITECT/, a new sprint 1–2 architecture spec, and minor updates to backend/knowledge component specs replacing Qdrant with pgvector and PhoGPT with GemmaE2B. It also introduces a complete legacy VKIST NON_ML ultrasound FastAPI application including ML inference pipeline, PDF report generation, Vietnamese web UI, Dockerfile, and supporting documentation.

Changes

Architecture & Design Documentation

Layer / File(s) Summary
Project-level solution and software architecture specs
proj_level_reading/ARCHITECT/SOLUTION_ARCHITECTURE_SPEC.md, proj_level_reading/ARCHITECT/SOFTWARE_ARCHITECTURE_SPEC.md
Adds two complete architecture specification documents covering the hybrid edge/on-prem platform: NFR-16/NFR-16a air-gap constraints, inference fallback chain (WebLLM → Triton → Vertex AI → deterministic templates), RAG-Referee safety gates, Decree 13 PII redaction pipelines, Redis/Postgres/Triton gRPC contracts, C4 context/container/component/deployment diagrams, REST/SSE contracts, guardrail worker topology, build-vs-buy matrix, phased task decomposition, and execution timeline.
Sprint 1-2 architecture spec and component spec updates
workspace/sprint_1_2/SPRINT_1_2_ARCHITECTURE_SPEC.md, workspace/sprint_1_2/CODEBASE/backend/spec/backend-spec.md, workspace/sprint_1_2/CODEBASE/knowledge/spec/knowledge_spec.md, README.md
Adds a full sprint-scoped architecture spec with C4 PlantUML diagrams, ML workflow sequence, NFR coverage, compliance obligations, infrastructure decisions, and open questions. Updates backend-spec.md and knowledge_spec.md to replace Qdrant with Postgres pgvector, replace PhoGPT/MedGPT with GemmaE2B/MedGemma, and add mandatory RAG pre-generation retrieval. Updates README directory tree to reflect PROJ_LEVEL_READING/ and Design_Material/ additions.

Legacy VKIST NON_ML Ultrasound Application

Layer / File(s) Summary
FastAPI ML inference pipeline
workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py (lines 1–560)
Adds global config, device selection, label/color constants, model-loading helpers for angle/inflammation/SUP/POST segmentation, preprocessing transforms, inference utilities, mask geometry helpers (get_mask_bounding_box, find_max_continuous_segment), thickness measurement (measure_thickness_new), inflammation severity scoring, and visualization utilities (create_segmentation_overlay, apply_clahe).
FastAPI API endpoints and PDF report service
workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py (lines 562–852), workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/pdf_service.py
Adds POST /api/analyze orchestrating the full ML pipeline, GET /api/health, POST /api/save (timestamped patient folder with info.txt, images, and auto-generated PDF), POST /api/export-pdf returning PDF as attachment, and Uvicorn launcher. Adds pdf_service.py with MedicalReportPDF (FPDF subclass), get_clean_image_stream (base64/path to non-interlaced PNG), and generate_medical_report assembling the full Vietnamese-language patient report.
Vietnamese web UI
workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/index.html, ...templates/css/style.css, ...templates/js/script.js
Adds index.html with model-selection dropdowns, drag-drop upload panel, results cards (angle/inflammation/segmentation/measurement/severity), patient info form, and diagnosis modal. Adds style.css with full layout grid, form/badge/modal/spinner styling and responsive breakpoint. Adds script.js with file handling, uploadAndAnalyze, displayResults, save/export wiring to /api/save and /api/export-pdf, color legend rendering, modal lifecycle, and page-load health check.
Dockerfile, requirements, README, and architecture review
workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/Dockerfile, .../ML/requirements.txt, .../README.md, .../architecture-review.html
Adds a multi-stage Dockerfile (python:3.12 builder + python:3.12-slim runtime). Populates requirements.txt with pinned PyTorch CPU and FastAPI/CV/PDF dependencies. Adds a README.md with setup, model-weight instructions, and LEGACY repo rules. Adds a static architecture-review.html proposing app.py modularization with before/after Mermaid diagrams.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(173, 216, 230, 0.5)
        Note over Browser,FastAPI: Image Upload & Analysis
    end
    participant Browser
    participant FastAPI
    participant AngleModel
    participant SegmentationModel
    participant PDFService
    participant MinIO

    Browser->>FastAPI: POST /api/analyze (image file + model params)
    FastAPI->>FastAPI: apply_clahe → base64 enhanced image
    FastAPI->>AngleModel: predict_angle(image)
    AngleModel-->>FastAPI: angle_class, confidence
    FastAPI->>FastAPI: predict_inflammation(image)
    FastAPI->>SegmentationModel: segment_image(image, angle_type)
    SegmentationModel-->>FastAPI: masks
    FastAPI->>FastAPI: measure_thickness_new(masks) + analyze_inflammation_severity(masks)
    FastAPI->>FastAPI: create_segmentation_overlay(image, masks, measurement)
    FastAPI-->>Browser: JSON (enhanced_img, segmented_img, metadata)

    rect rgba(144, 238, 144, 0.5)
        Note over Browser,MinIO: Save & PDF Export
    end
    Browser->>FastAPI: POST /api/save (patient_info + analysis_result + images)
    FastAPI->>FastAPI: create timestamped patient folder, write info.txt, save images
    FastAPI->>PDFService: generate_medical_report(patient_info, analysis_result, images)
    PDFService-->>FastAPI: PDF bytes
    FastAPI->>MinIO: store report artifact
    FastAPI-->>Browser: { saved_dir }

    Browser->>FastAPI: POST /api/export-pdf (same payload)
    FastAPI->>PDFService: generate_medical_report(...)
    PDFService-->>FastAPI: PDF bytes
    FastAPI-->>Browser: PDF attachment download

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 Hippity-hop, the specs have landed,
C4 diagrams neatly branded!
RAG-Referee guards every token,
Air-gap rules shall not be broken.
Legacy app.py, segmenting knees,
PDF reports typed with ease~
This bunny approves — proceed, if you please! 🦺

Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update_

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/DTJ-Tran/pilot_msk_ultrasound_stack/pull/1?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: failure by coderabbit.ai --> > [!CAUTION] > ## Review failed > > The pull request is closed. <!-- end of auto-generated comment: failure by coderabbit.ai --> <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `174d111b-6b35-41da-8481-a249cde088e0` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 16a91bd17ee7dfbf7922c59ac6e4e57ae664d734 and f70511371126afcc47c62a94cc85d4899214520e. </details> <details> <summary>⛔ Files ignored due to path filters (7)</summary> * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Bold.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Italic.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/Roboto-Regular.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/arial.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/arialbd.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/fonts/ariali.ttf` is excluded by `!**/*.ttf` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/assets/logo.png` is excluded by `!**/*.png` </details> <details> <summary>📒 Files selected for processing (70)</summary> * `README.md` * `proj_level_reading/ARCHITECT/SOFTWARE_ARCHITECTURE_SPEC.md` * `proj_level_reading/ARCHITECT/SOLUTION_ARCHITECTURE_SPEC.md` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/Dockerfile` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/pdf_service.py` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/css/style.css` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/index.html` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/js/script.js` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ML/requirements.txt` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/README.md` * `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/architecture-review.html` * `workspace/LEGACY/VKIST_ML/docs/Instruction_Manunal_API_Doc_Setup_pilot.md` * `workspace/LEGACY/VKIST_ML/docs/PILOT_TECH_DESC.md` * `workspace/LEGACY/VKIST_ML/docs/VKIST_ULTRASOUND_INTRODUCE_SPEC.md` * `workspace/LEGACY/VKIST_ML/docs/arch_code_analysis.md` * `workspace/sprint_1_2/CODEBASE/backend/spec/backend-spec.md` * `workspace/sprint_1_2/CODEBASE/backend/spec/interface-contract.md` * `workspace/sprint_1_2/CODEBASE/data/spec/data_spec.md` * `workspace/sprint_1_2/CODEBASE/data/spec/interface_contract.md` * `workspace/sprint_1_2/CODEBASE/frontend/spec/frontend_spec.md` * `workspace/sprint_1_2/CODEBASE/frontend/spec/interface_contract.md` * `workspace/sprint_1_2/CODEBASE/frontend/subprojects/offline/spec/interface_contract.md` * `workspace/sprint_1_2/CODEBASE/frontend/subprojects/offline/spec/offline_spec.md` * `workspace/sprint_1_2/CODEBASE/infra/implementation/cicd/jenkin_run.sh` * `workspace/sprint_1_2/CODEBASE/infra/implementation/observability/docker-compose.yaml` * `workspace/sprint_1_2/CODEBASE/infra/implementation/observability/prometheus.yml` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_convnext_tiny/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_densenet/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_efficientnet/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_resnet50/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/angle_classify_swin_v2_s/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/generate_ensemble.py` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/inflammation_model_efficientnet_b0_ultrasound_2_cls/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/msk_vision_pipeline_ensemble/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_deeplabv3/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_deeplabv3_resnet101/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_post_efficientfeedback/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_unet3plus_att/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/segmentation_model_unet_resnet101/config.pbtxt` * `workspace/sprint_1_2/CODEBASE/infra/implementation/s3/upload_ensemble.py` * `workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_file.sh` * `workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_2.sh` * `workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_3.sh` * `workspace/sprint_1_2/CODEBASE/infra/implementation/sh_files/mv_sh_4.sh` * `workspace/sprint_1_2/CODEBASE/infra/implementation/triton_run/modal_triton.py` * `workspace/sprint_1_2/CODEBASE/infra/implementation/triton_run/run.sh` * `workspace/sprint_1_2/CODEBASE/infra/spec/infra_spec.md` * `workspace/sprint_1_2/CODEBASE/infra/spec/interface_contract.md` * `workspace/sprint_1_2/CODEBASE/knowledge/spec/interface_contract.md` * `workspace/sprint_1_2/CODEBASE/knowledge/spec/knowledge_spec.md` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/efficientfeedback.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/__init__.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/automatic_mask_generator.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/build_sam.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/__init__.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/common.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/image_encoder.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/mask_decoder.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/prompt_encoder.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/sam.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/modeling/transformer.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/predictor.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/__init__.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/amg.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/onnx.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/segment_anything/utils/transforms.py` * `workspace/sprint_1_2/CODEBASE/ml/implementation/cv/arch/unet3plus_att.py` * `workspace/sprint_1_2/Design_Material/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy` * `workspace/sprint_1_2/SPRINT_1_2_ARCHITECTURE_SPEC.md` </details> </details> --- <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The PR adds two project-level architecture specification documents (solution and software architecture) under `proj_level_reading/ARCHITECT/`, a new sprint 1–2 architecture spec, and minor updates to backend/knowledge component specs replacing Qdrant with pgvector and PhoGPT with GemmaE2B. It also introduces a complete legacy VKIST NON_ML ultrasound FastAPI application including ML inference pipeline, PDF report generation, Vietnamese web UI, Dockerfile, and supporting documentation. ## Changes **Architecture & Design Documentation** |Layer / File(s)|Summary| |---|---| |**Project-level solution and software architecture specs** <br> `proj_level_reading/ARCHITECT/SOLUTION_ARCHITECTURE_SPEC.md`, `proj_level_reading/ARCHITECT/SOFTWARE_ARCHITECTURE_SPEC.md`|Adds two complete architecture specification documents covering the hybrid edge/on-prem platform: NFR-16/NFR-16a air-gap constraints, inference fallback chain (WebLLM → Triton → Vertex AI → deterministic templates), RAG-Referee safety gates, Decree 13 PII redaction pipelines, Redis/Postgres/Triton gRPC contracts, C4 context/container/component/deployment diagrams, REST/SSE contracts, guardrail worker topology, build-vs-buy matrix, phased task decomposition, and execution timeline.| |**Sprint 1-2 architecture spec and component spec updates** <br> `workspace/sprint_1_2/SPRINT_1_2_ARCHITECTURE_SPEC.md`, `workspace/sprint_1_2/CODEBASE/backend/spec/backend-spec.md`, `workspace/sprint_1_2/CODEBASE/knowledge/spec/knowledge_spec.md`, `README.md`|Adds a full sprint-scoped architecture spec with C4 PlantUML diagrams, ML workflow sequence, NFR coverage, compliance obligations, infrastructure decisions, and open questions. Updates backend-spec.md and knowledge_spec.md to replace Qdrant with Postgres pgvector, replace PhoGPT/MedGPT with GemmaE2B/MedGemma, and add mandatory RAG pre-generation retrieval. Updates README directory tree to reflect `PROJ_LEVEL_READING/` and `Design_Material/` additions.| **Legacy VKIST NON_ML Ultrasound Application** |Layer / File(s)|Summary| |---|---| |**FastAPI ML inference pipeline** <br> `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py` (lines 1–560)|Adds global config, device selection, label/color constants, model-loading helpers for angle/inflammation/SUP/POST segmentation, preprocessing transforms, inference utilities, mask geometry helpers (`get_mask_bounding_box`, `find_max_continuous_segment`), thickness measurement (`measure_thickness_new`), inflammation severity scoring, and visualization utilities (`create_segmentation_overlay`, `apply_clahe`).| |**FastAPI API endpoints and PDF report service** <br> `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/app.py` (lines 562–852), `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/pdf_service.py`|Adds `POST /api/analyze` orchestrating the full ML pipeline, `GET /api/health`, `POST /api/save` (timestamped patient folder with info.txt, images, and auto-generated PDF), `POST /api/export-pdf` returning PDF as attachment, and Uvicorn launcher. Adds `pdf_service.py` with `MedicalReportPDF` (FPDF subclass), `get_clean_image_stream` (base64/path to non-interlaced PNG), and `generate_medical_report` assembling the full Vietnamese-language patient report.| |**Vietnamese web UI** <br> `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/templates/index.html`, `...templates/css/style.css`, `...templates/js/script.js`|Adds `index.html` with model-selection dropdowns, drag-drop upload panel, results cards (angle/inflammation/segmentation/measurement/severity), patient info form, and diagnosis modal. Adds `style.css` with full layout grid, form/badge/modal/spinner styling and responsive breakpoint. Adds `script.js` with file handling, `uploadAndAnalyze`, `displayResults`, save/export wiring to `/api/save` and `/api/export-pdf`, color legend rendering, modal lifecycle, and page-load health check.| |**Dockerfile, requirements, README, and architecture review** <br> `workspace/LEGACY/VKIST_ML/codebase-vkist-ultrasound-legacy/ NON_ML/Dockerfile`, `.../ML/requirements.txt`, `.../README.md`, `.../architecture-review.html`|Adds a multi-stage Dockerfile (python:3.12 builder + python:3.12-slim runtime). Populates `requirements.txt` with pinned PyTorch CPU and FastAPI/CV/PDF dependencies. Adds a `README.md` with setup, model-weight instructions, and LEGACY repo rules. Adds a static `architecture-review.html` proposing `app.py` modularization with before/after Mermaid diagrams.| ## Sequence Diagram(s) ```mermaid sequenceDiagram rect rgba(173, 216, 230, 0.5) Note over Browser,FastAPI: Image Upload & Analysis end participant Browser participant FastAPI participant AngleModel participant SegmentationModel participant PDFService participant MinIO Browser->>FastAPI: POST /api/analyze (image file + model params) FastAPI->>FastAPI: apply_clahe → base64 enhanced image FastAPI->>AngleModel: predict_angle(image) AngleModel-->>FastAPI: angle_class, confidence FastAPI->>FastAPI: predict_inflammation(image) FastAPI->>SegmentationModel: segment_image(image, angle_type) SegmentationModel-->>FastAPI: masks FastAPI->>FastAPI: measure_thickness_new(masks) + analyze_inflammation_severity(masks) FastAPI->>FastAPI: create_segmentation_overlay(image, masks, measurement) FastAPI-->>Browser: JSON (enhanced_img, segmented_img, metadata) rect rgba(144, 238, 144, 0.5) Note over Browser,MinIO: Save & PDF Export end Browser->>FastAPI: POST /api/save (patient_info + analysis_result + images) FastAPI->>FastAPI: create timestamped patient folder, write info.txt, save images FastAPI->>PDFService: generate_medical_report(patient_info, analysis_result, images) PDFService-->>FastAPI: PDF bytes FastAPI->>MinIO: store report artifact FastAPI-->>Browser: { saved_dir } Browser->>FastAPI: POST /api/export-pdf (same payload) FastAPI->>PDFService: generate_medical_report(...) PDFService-->>FastAPI: PDF bytes FastAPI-->>Browser: PDF attachment download ``` ## Estimated code review effort 🎯 4 (Complex) | ⏱️ ~60 minutes ## Poem > 🐇 Hippity-hop, the specs have landed, > C4 diagrams neatly branded! > RAG-Referee guards every token, > Air-gap rules shall not be broken. > Legacy app.py, segmenting knees, > PDF reports typed with ease~ > *This bunny approves — proceed, if you please!* 🦺 </details> <!-- walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> <details> <summary>📝 Generate docstrings</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR - [ ] <!-- {"checkboxId": "3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch </details> <details> <summary>🧪 Generate unit tests (beta)</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `update_` </details> </details> <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=DTJ-Tran/pilot_msk_ultrasound_stack&utm_content=1)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Sign in to join this conversation.
No description provided.