# wkkyu088/smartmirror_adaptive_ui architecture

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

- Interactive diagram: https://gitdiagram.com/wkkyu088/smartmirror_adaptive_ui
- Repository: https://github.com/wkkyu088/smartmirror_adaptive_ui

## Overview

1. This repository is a local desktop application, not a pure web app. The architecture splits into two major runtimes: a TypeScript/React/Electron UI layer and a separate Python computer-vision/ML layer for age detection.

2. The desktop shell is handled by Electron. `public/electron.ts` / `public/electron.js` act as the main-process entry point, while `public/index.html` provides the renderer host. This is the boundary that turns the React app into a standalone smart-mirror application.

3. The renderer UI lives under `src/` and is a React + TypeScript single-page interface. `src/index.tsx` boots the app, `App.tsx` and `MainPage.tsx` organize the main screen, and `index.css` handles the visual presentation.

4. UI state is centralized with Redux. The `src/redux/` folder contains `store.ts`, `reducer.ts`, `actions.ts`, `types.ts`, and `RootState.ts`, which indicates that adaptive display state is shared across components rather than managed locally inside each widget.

5. The adaptive behavior is the core business flow. According to the README, the UI changes size based on estimated age and adjusts position based on eye level, so the Redux state likely carries camera-derived measurements that drive layout, scaling, and placement of the mirror UI.

6. The ML/computer-vision subsystem is isolated in `model/`. `detect_age.py` is the runtime inference script, and `wide_resnet.py` suggests a pretrained Wide ResNet-based age model. The model folder is separate from the UI code, which makes the ML boundary explicit.

7. The model stack depends on OpenCV, dlib, TensorFlow, and Keras, as listed in `model/requirements.txt` and the README. That implies the pipeline is likely: camera frame capture → face/landmark processing → age inference → output used by the UI adaptation logic.

8. Flask appears in the model tooling list, so the Python side is likely exposed as a local service or lightweight API, or at minimum was designed to be callable from the Electron app. The exact transport is not shown in the tree, but the architectural boundary is clearly between the Node/Electron side and the Python inference side.

9. The app also has non-ML informational widgets. `src/components/CalendarWidget.tsx` and `src/components/WeatherWidget.tsx` show that the mirror dashboard combines adaptive health/utility UI with standard ambient information panels.

10. There is no database or server-side persistence in the repository structure. The system appears to be stateless or session-based, focused on live camera input and immediate UI adaptation rather than stored user profiles.

11. Tooling reinforces the split-stack architecture: `package.json` / `package-lock.json` for the Electron-React frontend, `model/requirements.txt` for the Python ML environment, and `tsconfig.json` for TypeScript compilation. This is a two-environment project with a desktop shell and a separate vision inference runtime.

12. For an architecture diagram, the key data flow is: camera capture and face analysis in Python, adaptive state propagation into Redux, and React components rendering the smart-mirror UI inside Electron. Calendar and weather are side widgets that sit alongside the adaptive main display.

Main entry points: [`src/redux/store.ts`](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/store.ts) (Store), [`src/MainPage.tsx`](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/MainPage.tsx) (Main page), [`src/index.tsx`](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/index.tsx) (App boot), [`model/detect_age.py`](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/detect_age.py) (Age detect)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Electron UI runtime"]
  node_electron_main["Electron main<br/>desktop entry<br/>[electron.ts]"]
  node_renderer_host["HTML host<br/>renderer shell<br/>[index.html]"]
  node_app_boot["App boot<br/>react entry<br/>[index.tsx]"]
  node_app_shell["App shell<br/>react shell<br/>[App.tsx]"]
  node_main_page["Main page<br/>screen<br/>[MainPage.tsx]"]
  node_mirror_style["Stylesheet<br/>ui styling<br/>[index.css]"]
  node_redux_store[("Store<br/>[store.ts]")]
  node_redux_logic["Reducer/actions<br/>state logic<br/>[reducer.ts]"]
  node_redux_types["State types<br/>redux types<br/>[types.ts]"]
  node_redux_root["Root state<br/>redux model<br/>[RootState.ts]"]
  node_calendar_widget["Calendar<br/>ambient widget<br/>[CalendarWidget.tsx]"]
  node_weather_widget["Weather<br/>ambient widget<br/>[WeatherWidget.tsx]"]
end

subgraph group_vision["Python vision runtime"]
  node_age_detect["Age detect<br/>inference script<br/>[detect_age.py]"]
  node_wide_resnet["Wide ResNet<br/>ml model<br/>[wide_resnet.py]"]
end

subgraph group_tooling["Project tooling"]
  node_electron_pkg["Package config<br/>node tooling<br/>[package.json]"]
  node_python_reqs["Python deps<br/>python tooling<br/>[requirements.txt]"]
end

node_electron_main -->|"hosts"| node_renderer_host
node_renderer_host -->|"loads"| node_app_boot
node_app_boot -->|"renders"| node_app_shell
node_app_shell -->|"shows"| node_main_page
node_main_page -->|"contains"| node_calendar_widget
node_main_page -->|"contains"| node_weather_widget
node_app_boot -->|"connects"| node_redux_store
node_redux_store -->|"uses"| node_redux_logic
node_redux_logic -->|"typed by"| node_redux_types
node_redux_store -->|"shaped by"| node_redux_root
node_redux_store -->|"drives"| node_main_page
node_redux_store -->|"feeds"| node_calendar_widget
node_redux_store -->|"feeds"| node_weather_widget
node_age_detect -->|"runs"| node_wide_resnet
node_age_detect -->|"publishes"| node_redux_store
node_electron_pkg -->|"builds"| node_electron_main
node_python_reqs -->|"supports"| node_age_detect
node_main_page -->|"styles"| node_mirror_style

click node_electron_main "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/public/electron.ts"
click node_renderer_host "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/public/index.html"
click node_app_boot "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/index.tsx"
click node_app_shell "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/App.tsx"
click node_main_page "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/MainPage.tsx"
click node_mirror_style "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/index.css"
click node_redux_store "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/store.ts"
click node_redux_logic "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/reducer.ts"
click node_redux_types "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/types.ts"
click node_redux_root "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/RootState.ts"
click node_calendar_widget "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/components/CalendarWidget.tsx"
click node_weather_widget "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/components/WeatherWidget.tsx"
click node_age_detect "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/detect_age.py"
click node_wide_resnet "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/wide_resnet.py"
click node_electron_pkg "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/package.json"
click node_python_reqs "https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/requirements.txt"

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_electron_main,node_renderer_host,node_app_boot,node_app_shell,node_main_page,node_mirror_style,node_redux_store,node_redux_logic,node_redux_types,node_redux_root,node_calendar_widget,node_weather_widget toneBlue
class node_age_detect,node_wide_resnet toneAmber
class node_electron_pkg,node_python_reqs toneMint
```

## Components

### Electron UI runtime

TypeScript/React desktop shell and renderer

- [Electron main](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/public/electron.ts): desktop entry · Main-process entry that starts the desktop shell · `public/electron.ts`
- [HTML host](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/public/index.html): renderer shell · Renderer entry document for the React app · `public/index.html`
- [App boot](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/index.tsx): react entry · Bootstraps the renderer application · `src/index.tsx`
- [App shell](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/App.tsx): react shell · Top-level application composition · `src/App.tsx`
- [Main page](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/MainPage.tsx): screen · Primary smart-mirror screen layout · `src/MainPage.tsx`
- [Stylesheet](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/index.css): ui styling · Visual presentation for the renderer · `src/index.css`
- [Store](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/store.ts): redux store · Central state container for adaptive UI · `src/redux/store.ts`
- [Reducer/actions](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/reducer.ts): state logic · State transitions and action definitions · `src/redux/reducer.ts`
- [State types](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/types.ts): redux types · Shared state and action type definitions · `src/redux/types.ts`
- [Root state](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/redux/RootState.ts): redux model · Overall state shape for the UI · `src/redux/RootState.ts`
- [Calendar](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/components/CalendarWidget.tsx): ambient widget · Informational calendar panel · `src/components/CalendarWidget.tsx`
- [Weather](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/src/components/WeatherWidget.tsx): ambient widget · Informational weather panel · `src/components/WeatherWidget.tsx`

### Python vision runtime

Age-detection and computer-vision inference layer

- [Age detect](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/detect_age.py): inference script · Runs age estimation from camera imagery · `model/detect_age.py`
- [Wide ResNet](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/wide_resnet.py): ml model · Pretrained age-estimation network definition · `model/wide_resnet.py`

### Project tooling

Build and runtime dependency definitions

- [Package config](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/package.json): node tooling · Electron and React dependency/runtime configuration · `package.json`
- [Python deps](https://github.com/wkkyu088/smartmirror_adaptive_ui/blob/master/model/requirements.txt): python tooling · Computer-vision and ML runtime dependencies · `model/requirements.txt`

## Connections

- Electron main → HTML host: hosts · Electron opens the renderer window
- HTML host → App boot: loads · HTML host loads the React bundle
- App boot → App shell: renders · Bootstrapped app composes the top-level shell
- App shell → Main page: shows · Main application screen is assembled here
- Main page → Calendar: contains · Ambient dashboard widget
- Main page → Weather: contains · Ambient dashboard widget
- App boot → Store: connects · Renderer uses shared adaptive state
- Store → Reducer/actions: uses · Store is driven by reducers and actions
- Reducer/actions → State types: typed by · Actions and state share Redux types
- Store → Root state: shaped by · Store state follows the root state model
- Store → Main page: drives · Adaptive layout state updates the main UI
- Store → Calendar: feeds · Shared app state can reach widgets
- Store → Weather: feeds · Shared app state can reach widgets
- Age detect → Wide ResNet: runs · Inference script uses the age model
- Age detect → Store: publishes · Estimated age and related measurements update UI state
- Package config → Electron main: builds · Node/Electron tooling supports the desktop shell
- Python deps → Age detect: supports · Python environment enables the vision pipeline
- Main page → Stylesheet: styles · Main screen presentation is defined in CSS
