# pathakabhi-04/dermasense architecture

> Architecture diagram of the GitHub repository pathakabhi-04/dermasense, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pathakabhi-04/dermasense
- Repository: https://github.com/pathakabhi-04/dermasense

## Overview

DermaSense is a skin-lesion assessment system with an image-assessment workflow and a separate medical-question answering (RAG) capability. The main workflow accepts an image, applies quality and routing checks, evaluates lesion candidates, and produces diagnosis, risk, and review evidence; temporal assessment compares two visits. Model training and capture/consent persistence are supporting product subsystems. The README is empty, so capability boundaries come from the source tree and indexed source references; links for unsampled RAG ingestion and serving details are omitted where callers are not evidenced.

Main entry points: [`src/inference/orchestrator.py`](https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/orchestrator.py) (Assessment orchestrator), [`src/rag/pipeline.py`](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/pipeline.py) (Answer pipeline), [`src/temporal/pipeline.py`](https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/pipeline.py) (Temporal assessment), [`src/serving/assess_api.py`](https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/assess_api.py) (Assessment API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_assessment["Image assessment"]
  node_orchestrator["Assessment orchestrator<br/>[orchestrator.py]"]
  node_quality["Image quality<br/>[assessment.py]"]
  node_router["Domain routing<br/>[classifier.py]"]
  node_crop["Crop normalization<br/>[crop_normalize.py]"]
  node_detector["Lesion detection<br/>[model.py]"]
  node_segmentation["Lesion segmentation<br/>[inference.py]"]
  node_classifier["Native diagnosis<br/>[native.py]"]
  node_explainability["Visual evidence<br/>[gradcam.py]"]
end

subgraph group_risk_time["Risk and follow-up"]
  node_risk_convergence["Risk convergence<br/>[convergence.py]"]
  node_action_mapping["Action mapping<br/>[action_mapping.py]"]
  node_safety_gate["Safety gate<br/>[safety_gate.py]"]
  node_temporal_pipeline["Temporal assessment<br/>[pipeline.py]"]
  node_calibration["Ruler calibration<br/>[calibration.py]"]
  node_measurement["Lesion measurement<br/>[measurement.py]"]
  node_delta["Change calculation<br/>[delta.py]"]
end

subgraph group_support["Product support"]
  node_assessment_api["Assessment API<br/>[assess_api.py]"]
  node_capture_store[("Capture and consent store<br/>[capture_store.py]")]
  node_linkage["Patient linkage<br/>[linkage.py]"]
end

subgraph group_rag["Medical answers"]
  node_rag_ingestion["Corpus ingestion<br/>[acquisition.py]"]
  node_chunking["Document chunking<br/>[chunker.py]"]
  node_embedder["Text embeddings<br/>[embedder.py]"]
  node_vector_store[("FAISS index<br/>[faiss_store.py]")]
  node_retriever["Medical retrieval<br/>[retriever.py]"]
  node_cv_parser["Assessment context<br/>[parser.py]"]
  node_rag_pipeline["Answer pipeline<br/>[pipeline.py]"]
  node_evidence["Evidence formatting<br/>[evidence.py]"]
  node_prompt["Prompt building<br/>[prompt_builder.py]"]
  node_llm["LLM adapter<br/>[groq_adapter.py]"]
  node_grounding["Grounding check<br/>[grounding_check.py]"]
end

subgraph group_learning["Model learning"]
  node_data["Training data<br/>[dataset.py]"]
  node_transforms["Image transforms<br/>[transforms.py]"]
  node_training_engine["Training engine<br/>[engine.py]"]
end

node_user(("Image submitter"))

node_user -->|"submits image"| node_assessment_api
node_assessment_api -->|"invokes assessment"| node_orchestrator
node_orchestrator -->|"checks quality"| node_quality
node_orchestrator -->|"routes image"| node_router
node_orchestrator -.->|"finds candidates"| node_detector
node_orchestrator -->|"normalizes crops"| node_crop
node_orchestrator -->|"records mask"| node_segmentation
node_orchestrator -->|"classifies candidates"| node_classifier
node_orchestrator -->|"builds evidence"| node_explainability
node_orchestrator -->|"converges evidence"| node_risk_convergence
node_classifier -->|"maps diagnosis"| node_action_mapping
node_classifier -->|"checks prediction"| node_safety_gate
node_assessment_api -->|"persists captures"| node_capture_store
node_assessment_api -->|"uses identifiers"| node_linkage
node_assessment_api -->|"assesses follow-up"| node_temporal_pipeline
node_temporal_pipeline -->|"predicts masks"| node_segmentation
node_temporal_pipeline -->|"calibrates images"| node_calibration
node_temporal_pipeline -->|"measures lesions"| node_measurement
node_temporal_pipeline -->|"computes change"| node_delta
node_risk_convergence -->|"interprets actions"| node_action_mapping
node_rag_ingestion -.->|"prepares corpus"| node_chunking
node_chunking -.->|"embeds chunks"| node_embedder
node_embedder -.->|"indexes vectors"| node_vector_store
node_rag_pipeline -->|"gets evidence"| node_evidence
node_evidence -.->|"retrieves sources"| node_retriever
node_retriever -->|"encodes queries"| node_embedder
node_retriever -->|"searches index"| node_vector_store
node_rag_pipeline -->|"builds prompt"| node_prompt
node_rag_pipeline -->|"generates answer"| node_llm
node_rag_pipeline -->|"checks grounding"| node_grounding
node_rag_pipeline -->|"accepts assessment context"| node_cv_parser
node_data -.->|"prepares images"| node_transforms
node_training_engine -.->|"consumes batches"| node_data

click node_assessment_api "https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/assess_api.py"
click node_orchestrator "https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/orchestrator.py"
click node_quality "https://github.com/pathakabhi-04/dermasense/blob/main/src/quality/assessment.py"
click node_router "https://github.com/pathakabhi-04/dermasense/blob/main/src/routing/classifier.py"
click node_crop "https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/crop_normalize.py"
click node_detector "https://github.com/pathakabhi-04/dermasense/blob/main/src/detection/model.py"
click node_segmentation "https://github.com/pathakabhi-04/dermasense/blob/main/src/segmentation/inference.py"
click node_classifier "https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/native.py"
click node_explainability "https://github.com/pathakabhi-04/dermasense/blob/main/src/explainability/gradcam.py"
click node_risk_convergence "https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/convergence.py"
click node_action_mapping "https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/action_mapping.py"
click node_safety_gate "https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/safety_gate.py"
click node_temporal_pipeline "https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/pipeline.py"
click node_calibration "https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/calibration.py"
click node_measurement "https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/measurement.py"
click node_delta "https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/delta.py"
click node_capture_store "https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/capture_store.py"
click node_linkage "https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/linkage.py"
click node_data "https://github.com/pathakabhi-04/dermasense/blob/main/src/data/dataset.py"
click node_transforms "https://github.com/pathakabhi-04/dermasense/blob/main/src/data/transforms.py"
click node_training_engine "https://github.com/pathakabhi-04/dermasense/blob/main/src/training/engine.py"
click node_rag_ingestion "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/ingestion/acquisition.py"
click node_chunking "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/chunking/chunker.py"
click node_embedder "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/embeddings/embedder.py"
click node_vector_store "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/vectorstore/faiss_store.py"
click node_retriever "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/retrieval/retriever.py"
click node_cv_parser "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/cv_context/parser.py"
click node_rag_pipeline "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/pipeline.py"
click node_evidence "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/retrieval/evidence.py"
click node_prompt "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/prompts/prompt_builder.py"
click node_llm "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/llm/groq_adapter.py"
click node_grounding "https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/safety/grounding_check.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_orchestrator,node_quality,node_router,node_crop,node_detector,node_segmentation,node_classifier,node_explainability toneBlue
class node_risk_convergence,node_action_mapping,node_safety_gate,node_temporal_pipeline,node_calibration,node_measurement,node_delta toneAmber
class node_assessment_api,node_capture_store,node_linkage toneMint
class node_rag_ingestion,node_chunking,node_embedder,node_vector_store,node_retriever,node_cv_parser,node_rag_pipeline,node_evidence,node_prompt,node_llm,node_grounding toneRose
class node_data,node_transforms,node_training_engine,node_user toneIndigo
```

## Components

### Image assessment

- [Assessment orchestrator](https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/orchestrator.py): `src/inference/orchestrator.py`
- [Image quality](https://github.com/pathakabhi-04/dermasense/blob/main/src/quality/assessment.py): `src/quality/assessment.py`
- [Domain routing](https://github.com/pathakabhi-04/dermasense/blob/main/src/routing/classifier.py): `src/routing/classifier.py`
- [Crop normalization](https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/crop_normalize.py): `src/inference/crop_normalize.py`
- [Lesion detection](https://github.com/pathakabhi-04/dermasense/blob/main/src/detection/model.py): `src/detection/model.py`
- [Lesion segmentation](https://github.com/pathakabhi-04/dermasense/blob/main/src/segmentation/inference.py): `src/segmentation/inference.py`
- [Native diagnosis](https://github.com/pathakabhi-04/dermasense/blob/main/src/inference/native.py): `src/inference/native.py`
- [Visual evidence](https://github.com/pathakabhi-04/dermasense/blob/main/src/explainability/gradcam.py): `src/explainability/gradcam.py`

### Risk and follow-up

- [Risk convergence](https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/convergence.py): `src/risk/convergence.py`
- [Action mapping](https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/action_mapping.py): `src/risk/action_mapping.py`
- [Safety gate](https://github.com/pathakabhi-04/dermasense/blob/main/src/risk/safety_gate.py): `src/risk/safety_gate.py`
- [Temporal assessment](https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/pipeline.py): `src/temporal/pipeline.py`
- [Ruler calibration](https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/calibration.py): `src/temporal/calibration.py`
- [Lesion measurement](https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/measurement.py): `src/temporal/measurement.py`
- [Change calculation](https://github.com/pathakabhi-04/dermasense/blob/main/src/temporal/delta.py): `src/temporal/delta.py`

### Product support

- [Assessment API](https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/assess_api.py): `src/serving/assess_api.py`
- [Capture and consent store](https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/capture_store.py): `src/serving/capture_store.py`
- [Patient linkage](https://github.com/pathakabhi-04/dermasense/blob/main/src/serving/linkage.py): `src/serving/linkage.py`

### Medical answers

- [Corpus ingestion](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/ingestion/acquisition.py): `src/rag/ingestion/acquisition.py`
- [Document chunking](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/chunking/chunker.py): `src/rag/chunking/chunker.py`
- [Text embeddings](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/embeddings/embedder.py): `src/rag/embeddings/embedder.py`
- [FAISS index](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/vectorstore/faiss_store.py): `src/rag/vectorstore/faiss_store.py`
- [Medical retrieval](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/retrieval/retriever.py): `src/rag/retrieval/retriever.py`
- [Assessment context](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/cv_context/parser.py): `src/rag/cv_context/parser.py`
- [Answer pipeline](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/pipeline.py): `src/rag/pipeline.py`
- [Evidence formatting](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/retrieval/evidence.py): `src/rag/retrieval/evidence.py`
- [Prompt building](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/prompts/prompt_builder.py): `src/rag/prompts/prompt_builder.py`
- [LLM adapter](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/llm/groq_adapter.py): `src/rag/llm/groq_adapter.py`
- [Grounding check](https://github.com/pathakabhi-04/dermasense/blob/main/src/rag/safety/grounding_check.py): `src/rag/safety/grounding_check.py`

### Model learning

- [Training data](https://github.com/pathakabhi-04/dermasense/blob/main/src/data/dataset.py): `src/data/dataset.py`
- [Image transforms](https://github.com/pathakabhi-04/dermasense/blob/main/src/data/transforms.py): `src/data/transforms.py`
- [Training engine](https://github.com/pathakabhi-04/dermasense/blob/main/src/training/engine.py): `src/training/engine.py`

### Other components

- **Image submitter**

## Connections

- Image submitter → Assessment API: submits image (evidence: `src/serving/assess_api.py`)
- Assessment API → Assessment orchestrator: invokes assessment (evidence: `src/serving/assess_api.py`)
- Assessment orchestrator → Image quality: checks quality (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Domain routing: routes image (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Lesion detection: finds candidates
- Assessment orchestrator → Crop normalization: normalizes crops (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Lesion segmentation: records mask (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Native diagnosis: classifies candidates (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Visual evidence: builds evidence (evidence: `src/inference/orchestrator.py`)
- Assessment orchestrator → Risk convergence: converges evidence (evidence: `src/inference/orchestrator.py`)
- Native diagnosis → Action mapping: maps diagnosis (evidence: `src/inference/native.py`)
- Native diagnosis → Safety gate: checks prediction (evidence: `src/inference/native.py`)
- Assessment API → Capture and consent store: persists captures (evidence: `src/serving/assess_api.py`)
- Assessment API → Patient linkage: uses identifiers (evidence: `src/serving/assess_api.py`)
- Assessment API → Temporal assessment: assesses follow-up (evidence: `src/serving/assess_api.py`)
- Temporal assessment → Lesion segmentation: predicts masks (evidence: `src/temporal/pipeline.py`)
- Temporal assessment → Ruler calibration: calibrates images (evidence: `src/temporal/pipeline.py`)
- Temporal assessment → Lesion measurement: measures lesions (evidence: `src/temporal/pipeline.py`)
- Temporal assessment → Change calculation: computes change (evidence: `src/temporal/pipeline.py`)
- Risk convergence → Action mapping: interprets actions (evidence: `src/risk/convergence.py`)
- Corpus ingestion → Document chunking: prepares corpus
- Document chunking → Text embeddings: embeds chunks
- Text embeddings → FAISS index: indexes vectors
- Answer pipeline → Evidence formatting: gets evidence (evidence: `src/rag/pipeline.py`)
- Evidence formatting → Medical retrieval: retrieves sources
- Medical retrieval → Text embeddings: encodes queries (evidence: `src/rag/retrieval/retriever.py`)
- Medical retrieval → FAISS index: searches index (evidence: `src/rag/retrieval/retriever.py`)
- Answer pipeline → Prompt building: builds prompt (evidence: `src/rag/pipeline.py`)
- Answer pipeline → LLM adapter: generates answer (evidence: `src/rag/pipeline.py`)
- Answer pipeline → Grounding check: checks grounding (evidence: `src/rag/pipeline.py`)
- Answer pipeline → Assessment context: accepts assessment context (evidence: `src/rag/pipeline.py`)
- Training data → Image transforms: prepares images
- Training engine → Training data: consumes batches
