# been231/do_an_tot_nghiep_pawderm-ai architecture

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

- Interactive diagram: https://gitdiagram.com/been231/do_an_tot_nghiep_pawderm-ai
- Repository: https://github.com/been231/do_an_tot_nghiep_pawderm-ai

## Overview

PawDerm AI is a veterinary dermatology decision-support product: pet owners submit lesion images for AI-assisted assessment, receive first-aid and urgency guidance, track cases, and can be connected to clinic services. Doctors review and relabel cases for active learning; administrators manage users and disease knowledge and prepare retraining data. The repository has a React/FastAPI product and a separately launched Streamlit demo. Relationships below follow excerpts, SOURCE INDEX references, or README statements; unsampled feature internals are represented only where documented.

Main entry points: [`frontend/src/App.jsx`](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/App.jsx) (Role-based app), [`backend/main.py`](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/main.py) (REST API), [`streamlit_app/app.py`](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/app.py) (Streamlit entry point), [`frontend/src/services`](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/services) (Frontend API services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["React Web Portals"]
  node_react_app["Role-based app<br/>[App.jsx]"]
  node_auth_page["Authentication<br/>[AuthPage.jsx]"]
  node_auth_forms["Login and registration"]
  node_customer_page["Customer portal<br/>[CustomerPage.jsx]"]
  node_customer_features["Pets, diagnosis, history"]
  node_doctor_page["Doctor portal<br/>[DoctorPage.jsx]"]
  node_doctor_features["Review and relabel"]
  node_admin_page["Admin portal<br/>[AdminPage.jsx]"]
  node_admin_features["Users, disease, retraining"]
  node_api_client["Frontend API services"]
  node_api_config["API configuration<br/>[apiConfig.js]"]
end

subgraph group_api["FastAPI Services"]
  node_api_entry["REST API<br/>[main.py]"]
  node_auth_router["Authentication routes<br/>[auth.py]"]
  node_pet_router["Pet routes<br/>[pets.py]"]
  node_diagnosis_router["Diagnosis and history routes<br/>[diagnosis.py]"]
  node_doctor_router["Doctor review routes<br/>[doctor.py]"]
  node_admin_router["Admin routes<br/>[admin.py]"]
end

subgraph group_core["Clinical AI and Data"]
  node_inference["Image inference<br/>[ai_inference.py]"]
  node_disease_kb["Disease knowledge<br/>[disease_kb.py]"]
  node_data_service["Supabase data access"]
  node_supabase[("Supabase database<br/>[supabase_client.py]")]
end

subgraph group_demo["Streamlit Demo"]
  node_streamlit_app["Streamlit entry point<br/>[app.py]"]
  node_streamlit_auth["Demo authentication<br/>[auth_manager.py]"]
  node_login_manager["Login and sessions<br/>[login_manager.py]"]
  node_demo_diagnosis["Demo diagnosis"]
  node_demo_results["Results and clinic guidance<br/>[result_view.py]"]
  node_demo_history["Pet and case history<br/>[history_service.py]"]
end

node_owner(("Pet owner"))
node_doctor(("Veterinarian"))
node_admin(("Administrator"))

node_owner -->|"uses"| node_react_app
node_doctor -->|"uses"| node_react_app
node_admin -->|"uses"| node_react_app
node_react_app -->|"routes unauthenticated"| node_auth_page
node_react_app -->|"routes customer"| node_customer_page
node_react_app -->|"routes doctor"| node_doctor_page
node_react_app -->|"routes admin"| node_admin_page
node_auth_page -->|"renders"| node_auth_forms
node_customer_page -->|"renders"| node_customer_features
node_doctor_page -->|"renders"| node_doctor_features
node_admin_page -->|"renders"| node_admin_features
node_customer_page -->|"uses services"| node_api_client
node_doctor_page -->|"uses services"| node_api_client
node_admin_page -->|"uses services"| node_api_client
node_api_client -->|"uses configuration"| node_api_config
node_api_client -->|"calls REST API"| node_api_entry
node_api_entry -->|"registers"| node_auth_router
node_api_entry -->|"registers"| node_pet_router
node_api_entry -->|"registers"| node_diagnosis_router
node_api_entry -->|"registers"| node_doctor_router
node_api_entry -->|"registers"| node_admin_router
node_auth_router -->|"calls"| node_data_service
node_pet_router -->|"calls"| node_data_service
node_diagnosis_router -->|"runs inference"| node_inference
node_diagnosis_router -->|"persists cases"| node_data_service
node_doctor_router -->|"calls"| node_data_service
node_admin_router -->|"calls"| node_data_service
node_inference -->|"uses knowledge"| node_disease_kb
node_owner -->|"uses demo"| node_streamlit_app
node_streamlit_app -->|"coordinates authentication"| node_streamlit_auth
node_streamlit_auth -->|"delegates login"| node_login_manager
node_streamlit_app -->|"uses diagnosis"| node_demo_diagnosis
node_streamlit_app -->|"renders results"| node_demo_results
node_streamlit_app -->|"uses history"| node_demo_history
node_demo_diagnosis -->|"uses knowledge"| node_disease_kb
node_demo_history -->|"reads and writes"| node_supabase
node_demo_results -->|"uses history service"| node_demo_history

click node_react_app "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/App.jsx"
click node_auth_page "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/AuthPage.jsx"
click node_auth_forms "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/auth"
click node_customer_page "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/CustomerPage.jsx"
click node_customer_features "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/customer"
click node_doctor_page "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/DoctorPage.jsx"
click node_doctor_features "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/doctor"
click node_admin_page "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/AdminPage.jsx"
click node_admin_features "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/admin"
click node_api_client "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/services"
click node_api_config "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/services/apiConfig.js"
click node_api_entry "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/main.py"
click node_auth_router "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/auth.py"
click node_pet_router "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/pets.py"
click node_diagnosis_router "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/diagnosis.py"
click node_doctor_router "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/doctor.py"
click node_admin_router "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/admin.py"
click node_inference "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/services/ai_inference.py"
click node_disease_kb "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/data/disease_kb.py"
click node_data_service "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/database/supabase_service.py"
click node_supabase "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/database/supabase_client.py"
click node_streamlit_app "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/app.py"
click node_streamlit_auth "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/auth/auth_manager.py"
click node_login_manager "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/auth/login_manager.py"
click node_demo_diagnosis "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/services/diagnosis_service.py"
click node_demo_results "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/components/result_view.py"
click node_demo_history "https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/services/history_service.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_react_app,node_auth_page,node_auth_forms,node_customer_page,node_customer_features,node_doctor_page,node_doctor_features,node_admin_page,node_admin_features,node_api_client,node_api_config toneBlue
class node_api_entry,node_auth_router,node_pet_router,node_diagnosis_router,node_doctor_router,node_admin_router toneAmber
class node_inference,node_disease_kb,node_data_service,node_supabase toneMint
class node_streamlit_app,node_streamlit_auth,node_login_manager,node_demo_diagnosis,node_demo_results,node_demo_history toneRose
class node_owner,node_doctor,node_admin toneIndigo
```

## Components

### React Web Portals

- [Role-based app](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Authentication](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/AuthPage.jsx): `frontend/src/pages/AuthPage.jsx`
- [Login and registration](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/auth): `frontend/src/components/auth`
- [Customer portal](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/CustomerPage.jsx): `frontend/src/pages/CustomerPage.jsx`
- [Pets, diagnosis, history](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/customer): `frontend/src/components/customer`
- [Doctor portal](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/DoctorPage.jsx): `frontend/src/pages/DoctorPage.jsx`
- [Review and relabel](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/doctor): `frontend/src/components/doctor`
- [Admin portal](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/pages/AdminPage.jsx): `frontend/src/pages/AdminPage.jsx`
- [Users, disease, retraining](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/components/admin): `frontend/src/components/admin`
- [Frontend API services](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/tree/main/frontend/src/services): `frontend/src/services`
- [API configuration](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/frontend/src/services/apiConfig.js): `frontend/src/services/apiConfig.js`

### FastAPI Services

- [REST API](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/main.py): `backend/main.py`
- [Authentication routes](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Pet routes](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/pets.py): `backend/app/routers/pets.py`
- [Diagnosis and history routes](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/diagnosis.py): `backend/app/routers/diagnosis.py`
- [Doctor review routes](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/doctor.py): `backend/app/routers/doctor.py`
- [Admin routes](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/routers/admin.py): `backend/app/routers/admin.py`

### Clinical AI and Data

- [Image inference](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/services/ai_inference.py): `backend/app/services/ai_inference.py`
- [Disease knowledge](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/data/disease_kb.py): `backend/app/data/disease_kb.py`
- [Supabase data access](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/database/supabase_service.py): `backend/app/database/supabase_service.py`
- [Supabase database](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/backend/app/database/supabase_client.py): `backend/app/database/supabase_client.py`

### Streamlit Demo

- [Streamlit entry point](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/app.py): `streamlit_app/app.py`
- [Demo authentication](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/auth/auth_manager.py): `streamlit_app/auth/auth_manager.py`
- [Login and sessions](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/auth/login_manager.py): `streamlit_app/auth/login_manager.py`
- [Demo diagnosis](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/services/diagnosis_service.py): `streamlit_app/services/diagnosis_service.py`
- [Results and clinic guidance](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/components/result_view.py): `streamlit_app/components/result_view.py`
- [Pet and case history](https://github.com/been231/do_an_tot_nghiep_pawderm-ai/blob/main/streamlit_app/services/history_service.py): `streamlit_app/services/history_service.py`

### Other components

- **Pet owner**
- **Veterinarian**
- **Administrator**

## Connections

- Pet owner → Role-based app: uses (evidence: `README.md`)
- Veterinarian → Role-based app: uses (evidence: `README.md`)
- Administrator → Role-based app: uses (evidence: `README.md`)
- Role-based app → Authentication: routes unauthenticated (evidence: `frontend/src/App.jsx`)
- Role-based app → Customer portal: routes customer (evidence: `frontend/src/App.jsx`)
- Role-based app → Doctor portal: routes doctor (evidence: `frontend/src/App.jsx`)
- Role-based app → Admin portal: routes admin (evidence: `frontend/src/App.jsx`)
- Authentication → Login and registration: renders (evidence: `frontend/src/pages/AuthPage.jsx`)
- Customer portal → Pets, diagnosis, history: renders (evidence: `frontend/src/pages/CustomerPage.jsx`)
- Doctor portal → Review and relabel: renders (evidence: `frontend/src/pages/DoctorPage.jsx`)
- Admin portal → Users, disease, retraining: renders (evidence: `frontend/src/pages/AdminPage.jsx`)
- Customer portal → Frontend API services: uses services (evidence: `frontend/src/pages/CustomerPage.jsx`)
- Doctor portal → Frontend API services: uses services (evidence: `frontend/src/pages/DoctorPage.jsx`)
- Admin portal → Frontend API services: uses services (evidence: `frontend/src/pages/AdminPage.jsx`)
- Frontend API services → API configuration: uses configuration (evidence: `frontend/src/services/adminService.js`)
- Frontend API services → REST API: calls REST API (evidence: `README.md`)
- REST API → Authentication routes: registers (evidence: `backend/main.py`)
- REST API → Pet routes: registers (evidence: `backend/main.py`)
- REST API → Diagnosis and history routes: registers (evidence: `backend/main.py`)
- REST API → Doctor review routes: registers (evidence: `backend/main.py`)
- REST API → Admin routes: registers (evidence: `backend/main.py`)
- Authentication routes → Supabase data access: calls (evidence: `backend/app/routers/auth.py`)
- Pet routes → Supabase data access: calls (evidence: `backend/app/routers/pets.py`)
- Diagnosis and history routes → Image inference: runs inference (evidence: `backend/app/routers/diagnosis.py`)
- Diagnosis and history routes → Supabase data access: persists cases (evidence: `backend/app/routers/diagnosis.py`)
- Doctor review routes → Supabase data access: calls (evidence: `backend/app/routers/doctor.py`)
- Admin routes → Supabase data access: calls (evidence: `backend/app/routers/admin.py`)
- Image inference → Disease knowledge: uses knowledge (evidence: `backend/app/services/ai_inference.py`)
- Pet owner → Streamlit entry point: uses demo (evidence: `README.md`)
- Streamlit entry point → Demo authentication: coordinates authentication (evidence: `streamlit_app/app.py`)
- Demo authentication → Login and sessions: delegates login (evidence: `streamlit_app/auth/auth_manager.py`)
- Streamlit entry point → Demo diagnosis: uses diagnosis (evidence: `streamlit_app/app.py`)
- Streamlit entry point → Results and clinic guidance: renders results (evidence: `streamlit_app/app.py`)
- Streamlit entry point → Pet and case history: uses history (evidence: `streamlit_app/app.py`)
- Demo diagnosis → Disease knowledge: uses knowledge (evidence: `streamlit_app/services/diagnosis_service.py`)
- Pet and case history → Supabase database: reads and writes (evidence: `streamlit_app/services/history_service.py`)
- Results and clinic guidance → Pet and case history: uses history service (evidence: `streamlit_app/components/result_view.py`)
