# gopikrishnan20/skinchapters architecture

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

- Interactive diagram: https://gitdiagram.com/gopikrishnan20/skinchapters
- Repository: https://github.com/gopikrishnan20/skinchapters

## Overview

#### Purpose and System Shape
SkinChapters is a skincare-analysis platform: users scan skin, backend ML classifies skin type and conditions, and the system produces personalized AM/PM routines and product-oriented “chapters.” It is split into a Vite/React frontend and a Python backend with bundled trained model artifacts.

#### Frontend Entry and Application Shell
The client boots from `frontend/src/main.tsx` into the application root at `frontend/src/App.tsx`. It presents a multi-page user journey spanning marketing, authentication, scan/upload, analysis results, dashboard, profile, and curated chapters.
- `frontend/src/main.tsx`
- `frontend/src/App.tsx`
- `frontend/src/pages/ScanPage.tsx`

#### User Journey and Presentation Pages
The primary control flow is: landing/onboarding → sign-in/up → protected user experiences → scan → analysis/results → dashboard and recommendations. Scan and analysis-specific screens are distinct from general product discovery and account pages.
- `frontend/src/pages/Index.tsx`
- `frontend/src/pages/SkinAnalysisPage.tsx`
- `frontend/src/pages/ResultsDashboardPage.tsx`
- `frontend/src/pages/ChaptersPage.tsx`

#### Client Service Boundary
Frontend analysis requests are centralized in a service layer rather than embedded in page components, forming the browser-to-backend boundary. Authentication state and route access are handled separately through an auth context and protected-route wrapper.
- `frontend/src/services/skinAnalysisService.ts`
- `frontend/src/services/AuthContext.js`
- `frontend/src/services/ProtectedRoute.tsx`

#### Authentication Infrastructure
The frontend includes Firebase configuration, indicating Firebase is the material identity/authentication dependency. Backend analysis services appear logically separate from Firebase-managed client identity; the available tree does not establish server-side Firebase verification.
- `frontend/src/lib/firebaseConfig.ts`
- `frontend/src/services/AuthContext.js`
- `frontend/src/pages/SignInPage.tsx`

#### Backend API and Analysis Orchestration
The Python backend’s API entry point is `backend/app/main.py`. It likely receives scan input, invokes classification and utility processing, then delegates personalized routine construction. This is the core inference/request boundary between browser data and local ML assets.
- `backend/app/main.py`
- `backend/app/utils.py`
- `backend/app/routine_generator.py`

#### ML Inference Assets and Recommendation Output
Two persisted `.h5` models separate skin-type prediction from skin-condition prediction. Their outputs are the inputs to routine generation, which should convert classifications into morning/night recommendations. Label CSVs provide class mapping for at least the condition model.
- `backend/models/skin_type_model.h5`
- `backend/models/skin_condition_model.h5`
- `backend/data/skin_condition/skin_condition_labels.csv`
- `backend/app/routine_generator.py`

#### Model Lifecycle and Data Boundary
Training is kept outside runtime application code. Separate training scripts consume local skin-type and skin-condition datasets and produce/update model artifacts used by the API. No hosted database, queue, or external model-serving infrastructure is evident in the repository tree.
- `backend/training/train_skin_type.py`
- `backend/training/train_skin_condition.py`
- `backend/data/skin_type`
- `backend/data/skin_condition`

Main entry points: [`backend/app/main.py`](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/main.py) (Analysis API), [`frontend/src/App.tsx`](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/App.tsx) (Application shell), [`backend/models/skin_condition_model.h5`](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/models/skin_condition_model.h5) (Skin condition model), [`frontend/src/services/AuthContext.js`](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/services/AuthContext.js) (Auth state and route guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React client"]
  node_client_boot["Client bootstrap<br/>Vite entry<br/>[main.tsx]"]
  node_app_shell["Application shell<br/>React root<br/>[App.tsx]"]
  node_journey_pages["Onboarding and discovery<br/>page flow<br/>[Index.tsx]"]
  node_scan_page["Skin scan upload<br/>scan page<br/>[ScanPage.tsx]"]
  node_results_page["Results dashboard<br/>results page"]
  node_analysis_service["Analysis API client<br/>service boundary"]
  node_auth_guard["Auth state and route guard<br/>access control<br/>[AuthContext.js]"]
  node_firebase{{"Firebase authentication<br/>identity provider<br/>[firebaseConfig.ts]"}}
end

subgraph group_backend["Python analysis API"]
  node_api["Analysis API<br/>Python API entry<br/>[main.py]"]
  node_processing["Image and analysis utilities<br/>processing layer<br/>[utils.py]"]
  node_routine_generator["Routine generator<br/>recommendation engine"]
end

subgraph group_ml["ML lifecycle"]
  node_skin_type_model["Skin type model<br/>trained H5 model<br/>[skin_type_model.h5]"]
  node_condition_model["Skin condition model<br/>trained H5 model"]
  node_condition_labels["Condition labels<br/>class mapping"]
  node_skin_type_training["Skin type training<br/>training pipeline<br/>[train_skin_type.py]"]
  node_condition_training["Condition training<br/>training pipeline"]
  node_skin_type_data[("Skin type dataset<br/>local training data")]
  node_condition_data[("Skin condition dataset<br/>local training data")]
end

node_client_boot -->|"mounts"| node_app_shell
node_app_shell -->|"routes"| node_journey_pages
node_app_shell -->|"routes"| node_scan_page
node_app_shell -->|"routes"| node_results_page
node_auth_guard -->|"protects user routes"| node_journey_pages
node_auth_guard -->|"uses identity"| node_firebase
node_scan_page -->|"submits scan"| node_analysis_service
node_analysis_service -->|"analysis request"| node_api
node_api -->|"processes input"| node_processing
node_api -->|"runs inference"| node_skin_type_model
node_api -->|"runs inference"| node_condition_model
node_api -->|"passes classifications"| node_routine_generator
node_condition_model -->|"maps classes"| node_condition_labels
node_routine_generator -->|"recommendations response"| node_results_page
node_skin_type_data -->|"training input"| node_skin_type_training
node_skin_type_training -->|"produces"| node_skin_type_model
node_condition_data -->|"training input"| node_condition_training
node_condition_training -->|"produces"| node_condition_model
node_condition_data -->|"defines classes"| node_condition_labels

click node_client_boot "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/main.tsx"
click node_app_shell "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/App.tsx"
click node_journey_pages "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/Index.tsx"
click node_scan_page "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/ScanPage.tsx"
click node_results_page "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/ResultsDashboardPage.tsx"
click node_analysis_service "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/services/skinAnalysisService.ts"
click node_auth_guard "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/services/AuthContext.js"
click node_firebase "https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/lib/firebaseConfig.ts"
click node_api "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/main.py"
click node_processing "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/utils.py"
click node_routine_generator "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/routine_generator.py"
click node_skin_type_model "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/models/skin_type_model.h5"
click node_condition_model "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/models/skin_condition_model.h5"
click node_condition_labels "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/data/skin_condition/skin_condition_labels.csv"
click node_skin_type_training "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/training/train_skin_type.py"
click node_condition_training "https://github.com/gopikrishnan20/skinchapters/blob/master/backend/training/train_skin_condition.py"
click node_skin_type_data "https://github.com/gopikrishnan20/skinchapters/tree/master/backend/data/skin_type"
click node_condition_data "https://github.com/gopikrishnan20/skinchapters/tree/master/backend/data/skin_condition"

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_client_boot,node_app_shell,node_journey_pages,node_scan_page,node_results_page,node_analysis_service,node_auth_guard,node_firebase toneBlue
class node_api,node_processing,node_routine_generator toneAmber
class node_skin_type_model,node_condition_model,node_condition_labels,node_skin_type_training,node_condition_training,node_skin_type_data,node_condition_data toneMint
```

## Components

### React client

- [Client bootstrap](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/main.tsx): Vite entry · `frontend/src/main.tsx`
- [Application shell](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/App.tsx): React root · `frontend/src/App.tsx`
- [Onboarding and discovery](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/Index.tsx): page flow · Landing, analysis, dashboard, and chapters experiences. · `frontend/src/pages/Index.tsx`
- [Skin scan upload](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/ScanPage.tsx): scan page · `frontend/src/pages/ScanPage.tsx`
- [Results dashboard](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/pages/ResultsDashboardPage.tsx): results page · `frontend/src/pages/ResultsDashboardPage.tsx`
- [Analysis API client](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/services/skinAnalysisService.ts): service boundary · `frontend/src/services/skinAnalysisService.ts`
- [Auth state and route guard](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/services/AuthContext.js): access control · `frontend/src/services/AuthContext.js`
- [Firebase authentication](https://github.com/gopikrishnan20/skinchapters/blob/master/frontend/src/lib/firebaseConfig.ts): identity provider · `frontend/src/lib/firebaseConfig.ts`

### Python analysis API

- [Analysis API](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/main.py): Python API entry · Receives scans and orchestrates inference and recommendations. · `backend/app/main.py`
- [Image and analysis utilities](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/utils.py): processing layer · `backend/app/utils.py`
- [Routine generator](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/app/routine_generator.py): recommendation engine · Builds AM/PM routines from predicted skin attributes. · `backend/app/routine_generator.py`

### ML lifecycle

- [Skin type model](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/models/skin_type_model.h5): trained H5 model · `backend/models/skin_type_model.h5`
- [Skin condition model](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/models/skin_condition_model.h5): trained H5 model · `backend/models/skin_condition_model.h5`
- [Condition labels](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/data/skin_condition/skin_condition_labels.csv): class mapping · `backend/data/skin_condition/skin_condition_labels.csv`
- [Skin type training](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/training/train_skin_type.py): training pipeline · Trains the skin-type artifact from local data. · `backend/training/train_skin_type.py`
- [Condition training](https://github.com/gopikrishnan20/skinchapters/blob/master/backend/training/train_skin_condition.py): training pipeline · Trains the condition artifact from local data. · `backend/training/train_skin_condition.py`
- [Skin type dataset](https://github.com/gopikrishnan20/skinchapters/tree/master/backend/data/skin_type): local training data · `backend/data/skin_type`
- [Skin condition dataset](https://github.com/gopikrishnan20/skinchapters/tree/master/backend/data/skin_condition): local training data · `backend/data/skin_condition`

## Connections

- Client bootstrap → Application shell: mounts
- Application shell → Onboarding and discovery: routes
- Application shell → Skin scan upload: routes
- Application shell → Results dashboard: routes
- Auth state and route guard → Onboarding and discovery: protects user routes
- Auth state and route guard → Firebase authentication: uses identity
- Skin scan upload → Analysis API client: submits scan
- Analysis API client → Analysis API: analysis request
- Analysis API → Image and analysis utilities: processes input
- Analysis API → Skin type model: runs inference
- Analysis API → Skin condition model: runs inference
- Analysis API → Routine generator: passes classifications
- Skin condition model → Condition labels: maps classes
- Routine generator → Results dashboard: recommendations response
- Skin type dataset → Skin type training: training input
- Skin type training → Skin type model: produces
- Skin condition dataset → Condition training: training input
- Condition training → Skin condition model: produces
- Skin condition dataset → Condition labels: defines classes
