# siddarammanur656/dermascan-ai- architecture

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

- Interactive diagram: https://gitdiagram.com/siddarammanur656/dermascan-ai-
- Repository: https://github.com/siddarammanur656/dermascan-ai-

## Overview

#### Purpose and Entry Point
DermaScan AI is a single-process Python/Streamlit dermatology-assistance application. It accepts lesion images for local dual-model classification and provides a multilingual skin-care chat assistant backed by Google Gemini, with optional speech input/output. The runtime entry point is `app.py`; launch through `streamlit run app.py`.

Paths: `app.py`, `requirements.txt`, `README.md`

#### Streamlit UI and Session Boundary
`app.py` owns the interactive UI: image upload, side-by-side model results, chat panel, language selection, and voice controls. Streamlit session state preserves chat context only for the active browser session; image handling is in-memory. Styling is loaded from the static CSS asset.

Paths: `app.py`, `assets/style.css`

#### Model Asset Loading and Caching
Two TensorFlow/Keras `.h5` artifacts are application-local inference dependencies. The app loads them with inference-oriented settings and Streamlit resource caching, so model instances are reused rather than reloaded on each interaction. Missing or incompatible assets are a startup/runtime availability boundary.

Paths: `app.py`, `custom_cnn_model.h5`, `vgg16_skin_cancer.h5`

#### Image Inference Pipeline
Uploaded JPEG/PNG input crosses a validation boundary, then is converted to RGB, resized to each model’s configured input size, normalized, and expanded into a batch. The same image is independently evaluated by the custom CNN and VGG16 model. Output handling supports sigmoid-style binary results and multiclass probability vectors, mapping top scores to configured labels and displaying confidence/raw outputs.

Paths: `app.py`, `custom_cnn_model.h5`, `vgg16_skin_cancer.h5`

#### Conversational AI Integration
Skin-care questions and prior session messages are sent to Google Generative AI (Gemini) under a domain-specific prompt. API credentials come from environment configuration, with a UI fallback described for user-provided keys. Gemini model selection includes fallback behavior for quota/API failures; this is the primary external network dependency and the main nondeterministic service boundary.

Paths: `app.py`, `.env`

#### Voice and Multilingual Flow
The UI accepts English, Hindi, and Kannada interaction. Voice capture is transcribed to chat text via speech-recognition dependencies; generated assistant text can be synthesized into audio through gTTS. These capabilities depend on browser microphone permissions and online speech/TTS services, while text chat remains the fallback path.

Paths: `app.py`, `requirements.txt`

#### Runtime and Operational Shape
The system is a Streamlit-hosted Python application using TensorFlow/Keras, NumPy, Pillow, dotenv, Gemini SDK, speech recognition, and gTTS. There is no separate backend, database, queue, or persistent user-data store in the repository. Lightweight operational checks verify dependencies and model file availability.

Paths: `requirements.txt`, `check_models.py`, `test_imports.py`

Main entry points: [`app.py`](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py) (Image, chat and voice UI), [`custom_cnn_model.h5`](https://github.com/siddarammanur656/dermascan-ai-/blob/master/custom_cnn_model.h5) (Custom CNN model), [`vgg16_skin_cancer.h5`](https://github.com/siddarammanur656/dermascan-ai-/blob/master/vgg16_skin_cancer.h5) (VGG16 skin cancer model), [`.env`](https://github.com/siddarammanur656/dermascan-ai-/blob/master/.env) (API credentials)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Streamlit interface"]
  node_app["Streamlit application<br/>Python entry point<br/>[app.py]"]
  node_ui_controls["Image, chat and voice UI<br/>Streamlit views<br/>[app.py]"]
  node_session[("Browser session state<br/>in-memory context<br/>[app.py]")]
  node_styles["Application styling<br/>CSS asset<br/>[style.css]"]
end

subgraph group_inference["Local image inference"]
  node_upload["Uploaded lesion image<br/>in-memory input<br/>[app.py]"]
  node_image_prep["Validation and preprocessing<br/>image pipeline<br/>[app.py]"]
  node_custom_model{{"Custom CNN model<br/>Keras artifact"}}
  node_vgg_model{{"VGG16 skin cancer model<br/>Keras artifact"}}
  node_results["Classification results<br/>result mapper<br/>[app.py]"]
end

subgraph group_assistant["Conversational assistant"]
  node_chat_prompt["Domain chat prompt<br/>conversation builder<br/>[app.py]"]
  node_gemini{{"Google Gemini<br/>external generative AI"}}
  node_credentials["API credentials<br/>environment configuration<br/>[.env]"]
  node_speech_input{{"Speech transcription<br/>external speech service<br/>[app.py]"}}
  node_speech_output{{"Text-to-speech audio<br/>external TTS service<br/>[app.py]"}}
end

node_app -->|"renders"| node_ui_controls
node_app -->|"loads"| node_styles
node_ui_controls -->|"reads and updates"| node_session
node_ui_controls -->|"accepts"| node_upload
node_upload -->|"validates and transforms"| node_image_prep
node_image_prep -->|"prepared batch"| node_custom_model
node_image_prep -->|"prepared batch"| node_vgg_model
node_custom_model -->|"scores"| node_results
node_vgg_model -->|"scores"| node_results
node_results -->|"displays"| node_ui_controls
node_ui_controls -->|"voice capture"| node_speech_input
node_speech_input -->|"transcribed text"| node_chat_prompt
node_ui_controls -->|"typed question"| node_chat_prompt
node_session -->|"prior messages"| node_chat_prompt
node_credentials -->|"authorizes"| node_gemini
node_chat_prompt -->|"prompt request"| node_gemini
node_gemini -->|"assistant response"| node_session
node_gemini -->|"response text"| node_speech_output
node_speech_output -->|"audio playback"| node_ui_controls

click node_app "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_ui_controls "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_session "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_styles "https://github.com/siddarammanur656/dermascan-ai-/blob/master/assets/style.css"
click node_upload "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_image_prep "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_custom_model "https://github.com/siddarammanur656/dermascan-ai-/blob/master/custom_cnn_model.h5"
click node_vgg_model "https://github.com/siddarammanur656/dermascan-ai-/blob/master/vgg16_skin_cancer.h5"
click node_results "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_chat_prompt "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_credentials "https://github.com/siddarammanur656/dermascan-ai-/blob/master/.env"
click node_speech_input "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py"
click node_speech_output "https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.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_app,node_ui_controls,node_session,node_styles toneBlue
class node_upload,node_image_prep,node_custom_model,node_vgg_model,node_results toneAmber
class node_chat_prompt,node_gemini,node_credentials,node_speech_input,node_speech_output toneMint
```

## Components

### Streamlit interface

- [Streamlit application](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): Python entry point · Single-process runtime and integration boundary. · `app.py`
- [Image, chat and voice UI](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): Streamlit views · `app.py`
- [Browser session state](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): in-memory context · Retains chat context only for the active session. · `app.py`
- [Application styling](https://github.com/siddarammanur656/dermascan-ai-/blob/master/assets/style.css): CSS asset · `assets/style.css`

### Local image inference

- [Uploaded lesion image](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): in-memory input · JPEG/PNG image supplied through the UI. · `app.py`
- [Validation and preprocessing](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): image pipeline · Converts RGB, resizes, normalizes, and batches per model. · `app.py`
- [Custom CNN model](https://github.com/siddarammanur656/dermascan-ai-/blob/master/custom_cnn_model.h5): Keras artifact · Cached local inference model. · `custom_cnn_model.h5`
- [VGG16 skin cancer model](https://github.com/siddarammanur656/dermascan-ai-/blob/master/vgg16_skin_cancer.h5): Keras artifact · Cached local inference model. · `vgg16_skin_cancer.h5`
- [Classification results](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): result mapper · Maps binary or multiclass scores to labels and confidence. · `app.py`

### Conversational assistant

- [Domain chat prompt](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): conversation builder · Combines question, prior messages, language, and skin-care guidance. · `app.py`
- **Google Gemini**: external generative AI · Network service with model and quota fallback behavior.
- [API credentials](https://github.com/siddarammanur656/dermascan-ai-/blob/master/.env): environment configuration · Loads API key from environment with UI key fallback. · `.env`
- [Speech transcription](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): external speech service · Requires microphone permission and online speech recognition. · `app.py`
- [Text-to-speech audio](https://github.com/siddarammanur656/dermascan-ai-/blob/master/app.py): external TTS service · Synthesizes assistant responses through gTTS. · `app.py`

## Connections

- Streamlit application → Image, chat and voice UI: renders
- Streamlit application → Application styling: loads
- Image, chat and voice UI → Browser session state: reads and updates
- Image, chat and voice UI → Uploaded lesion image: accepts
- Uploaded lesion image → Validation and preprocessing: validates and transforms
- Validation and preprocessing → Custom CNN model: prepared batch
- Validation and preprocessing → VGG16 skin cancer model: prepared batch
- Custom CNN model → Classification results: scores
- VGG16 skin cancer model → Classification results: scores
- Classification results → Image, chat and voice UI: displays
- Image, chat and voice UI → Speech transcription: voice capture
- Speech transcription → Domain chat prompt: transcribed text
- Image, chat and voice UI → Domain chat prompt: typed question
- Browser session state → Domain chat prompt: prior messages
- API credentials → Google Gemini: authorizes
- Domain chat prompt → Google Gemini: prompt request
- Google Gemini → Browser session state: assistant response
- Google Gemini → Text-to-speech audio: response text
- Text-to-speech audio → Image, chat and voice UI: audio playback
