# ashigaevanjelin/beauty_tech_ai architecture

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

- Interactive diagram: https://gitdiagram.com/ashigaevanjelin/beauty_tech_ai
- Repository: https://github.com/ashigaevanjelin/beauty_tech_ai

## Overview

#### Purpose and Runtime
Beauty Tech AI is a Flask-based salon platform combining role-specific workflow management with AI-oriented beauty analysis, recommendations, and hairstyle preview. It runs as a Python web server from `app.py`, targets the runtime specified in `.python-version`/`runtime.txt`, and serves a built frontend bundle from `static/index.html` and `static/assets/`.

#### Application Composition
`app.py` is the backend composition and launch point: it initializes Flask, loads application configuration, database support, and route modules. `config.py` centralizes runtime/database configuration. The primary persistence boundary is SQLite, with the committed local database at `instance/beautypassport.db`.

#### Identity and Role Segmentation
Authentication and role-aware access are handled through `routes/auth.py`. The product has customer, salon-staff, and salon-owner experiences; dashboard selection and role-specific aggregate views are exposed through `routes/dashboards.py`. This is the key authorization boundary before customers access personal beauty data or appointments and staff/owners access operational data.

#### Domain Persistence Model
`models.py` defines the application’s persistent domain layer, expected to represent users, beauty-passport/analysis information, service recommendations, and appointment/business records. Route handlers use this layer rather than treating the frontend bundle as a source of state. SQLite is suitable for the current single-instance deployment model but is a material scaling boundary for concurrent hosted use.

#### Customer Beauty Passport and Analysis
`routes/passport.py` owns the digital Beauty Passport flow: customer beauty-analysis results and generated reports become durable, customer-scoped records. AI/image-oriented processing is supported by `process_realistic_hair.py`; source hairstyle imagery is organized under `assets/hairstyles`. OpenCV and ML-related dependencies are expected through `requirements.txt`, creating a native/image-processing runtime boundary.

#### Recommendations and Hairstyle Experience
`routes/recommendations.py` provides personalized salon-service, home-care, and beauty guidance based on passport/analysis data. `routes/hairstyle.py` serves the virtual hairstyle try-on and face/hairstyle suitability workflow, using bundled/static assets plus the hair-processing pipeline. `fix_assets.py` is an asset-preparation utility associated with this visual-processing boundary.

#### Appointment Operations and Analytics
`routes/appointments.py` manages the booking lifecycle: customer requests, staff assignment/confirmation, completion, and status visibility. Those operational records feed owner/staff dashboard metrics in `routes/dashboards.py`, including bookings, revenue, customer activity, trends, and service popularity. The control flow is customer booking → staff fulfillment/status updates → owner aggregate reporting.

#### Client and Deployment Boundary
The browser client is a prebuilt static application at `static/index.html`, with hashed JavaScript/CSS artifacts in `static/assets/`; Flask supplies its API and static hosting surface. Deployment is compatible with the documented hosted Render instance, but no separate frontend server, external identity provider, payment processor, or cloud AI service is represented in the repository tree.

Main entry points: [`app.py`](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/app.py) (Flask application), [`models.py`](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/models.py) (Domain persistence model), [`routes/dashboards.py`](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/dashboards.py) (Role dashboards), [`routes/appointments.py`](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/appointments.py) (Appointment operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backend["Flask backend"]
  node_app["Flask application<br/>composition root<br/>[app.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_models["Domain persistence model<br/>ORM models<br/>[models.py]"]
end

subgraph group_routes["Route modules"]
  node_auth["Authentication &amp; roles<br/>route module<br/>[auth.py]"]
  node_dashboards["Role dashboards<br/>route module<br/>[dashboards.py]"]
  node_passport["Beauty Passport<br/>route module<br/>[passport.py]"]
  node_recommendations["Recommendations<br/>route module<br/>[recommendations.py]"]
  node_hairstyle["Virtual hairstyle try-on<br/>route module<br/>[hairstyle.py]"]
  node_appointments["Appointment operations<br/>route module<br/>[appointments.py]"]
end

subgraph group_visual["Visual AI pipeline"]
  node_hair_processor["Hair image processor<br/>image-processing pipeline"]
  node_hairstyle_assets["Hairstyle source images<br/>image assets"]
  node_asset_preparation["Asset preparation<br/>[fix_assets.py]"]
  node_native_dependencies["Native ML dependencies<br/>Python dependencies<br/>[requirements.txt]"]
end

node_browser["Browser client<br/>static SPA<br/>[index.html]"]
node_static_assets["Frontend assets<br/>bundled JS/CSS"]
node_database[("SQLite database<br/>persistence store<br/>[beautypassport.db]")]

node_browser -->|"API requests"| node_app
node_browser -->|"loads bundle"| node_static_assets
node_app -->|"hosts"| node_static_assets
node_app -->|"loads"| node_config
node_app -->|"registers"| node_auth
node_app -->|"registers"| node_dashboards
node_app -->|"registers"| node_passport
node_app -->|"registers"| node_recommendations
node_app -->|"registers"| node_hairstyle
node_app -->|"registers"| node_appointments
node_auth -->|"authorizes roles"| node_dashboards
node_passport -->|"stores analysis"| node_models
node_recommendations -->|"uses passport data"| node_models
node_hairstyle -->|"runs preview processing"| node_hair_processor
node_hair_processor -->|"uses source imagery"| node_hairstyle_assets
node_asset_preparation -->|"prepares"| node_hairstyle_assets
node_hair_processor -->|"requires"| node_native_dependencies
node_appointments -->|"updates booking lifecycle"| node_models
node_appointments -->|"feeds operational metrics"| node_dashboards
node_dashboards -->|"aggregates records"| node_models
node_models -->|"persists"| node_database

click node_browser "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/static/index.html"
click node_app "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/app.py"
click node_config "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/config.py"
click node_auth "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/auth.py"
click node_dashboards "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/dashboards.py"
click node_passport "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/passport.py"
click node_recommendations "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/recommendations.py"
click node_hairstyle "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/hairstyle.py"
click node_appointments "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/appointments.py"
click node_models "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/models.py"
click node_database "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/instance/beautypassport.db"
click node_hair_processor "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/process_realistic_hair.py"
click node_hairstyle_assets "https://github.com/ashigaevanjelin/beauty_tech_ai/tree/main/assets/hairstyles"
click node_asset_preparation "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/fix_assets.py"
click node_native_dependencies "https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/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_app,node_config,node_models toneBlue
class node_auth,node_dashboards,node_passport,node_recommendations,node_hairstyle,node_appointments toneAmber
class node_hair_processor,node_hairstyle_assets,node_asset_preparation,node_native_dependencies toneMint
class node_browser,node_static_assets,node_database toneNeutral
```

## Components

### Flask backend

- [Flask application](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/app.py): composition root · Initializes configuration, persistence, routes, API, and static hosting. · `app.py`
- [Runtime configuration](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/config.py): configuration · `config.py`
- [Domain persistence model](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/models.py): ORM models · Defines users, passports, recommendations, appointments, and business records. · `models.py`

### Route modules

- [Authentication & roles](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/auth.py): route module · Authorization boundary for customers, staff, and owners. · `routes/auth.py`
- [Role dashboards](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/dashboards.py): route module · Provides role-specific operational and aggregate views. · `routes/dashboards.py`
- [Beauty Passport](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/passport.py): route module · Persists customer-scoped analysis results and reports. · `routes/passport.py`
- [Recommendations](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/recommendations.py): route module · Generates personalized services, home-care, and beauty guidance. · `routes/recommendations.py`
- [Virtual hairstyle try-on](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/hairstyle.py): route module · Serves hairstyle suitability and preview workflows. · `routes/hairstyle.py`
- [Appointment operations](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/routes/appointments.py): route module · Manages booking, assignment, fulfillment, and status. · `routes/appointments.py`

### Visual AI pipeline

- [Hair image processor](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/process_realistic_hair.py): image-processing pipeline · OpenCV/ML-oriented realistic hair processing. · `process_realistic_hair.py`
- [Hairstyle source images](https://github.com/ashigaevanjelin/beauty_tech_ai/tree/main/assets/hairstyles): image assets · `assets/hairstyles`
- [Asset preparation](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/fix_assets.py): utility · Prepares visual assets for hairstyle processing. · `fix_assets.py`
- [Native ML dependencies](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/requirements.txt): Python dependencies · Provides the native and image-processing runtime boundary. · `requirements.txt`

### Other components

- [Browser client](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/static/index.html): static SPA · Prebuilt client for customer and salon workflows. · `static/index.html`
- **Frontend assets**: bundled JS/CSS
- [SQLite database](https://github.com/ashigaevanjelin/beauty_tech_ai/blob/main/instance/beautypassport.db): persistence store · Single-instance persistence and concurrent-hosting scaling boundary. · `instance/beautypassport.db`

## Connections

- Browser client → Flask application: API requests
- Browser client → Frontend assets: loads bundle
- Flask application → Frontend assets: hosts
- Flask application → Runtime configuration: loads
- Flask application → Authentication & roles: registers
- Flask application → Role dashboards: registers
- Flask application → Beauty Passport: registers
- Flask application → Recommendations: registers
- Flask application → Virtual hairstyle try-on: registers
- Flask application → Appointment operations: registers
- Authentication & roles → Role dashboards: authorizes roles
- Beauty Passport → Domain persistence model: stores analysis
- Recommendations → Domain persistence model: uses passport data
- Virtual hairstyle try-on → Hair image processor: runs preview processing
- Hair image processor → Hairstyle source images: uses source imagery
- Asset preparation → Hairstyle source images: prepares
- Hair image processor → Native ML dependencies: requires
- Appointment operations → Domain persistence model: updates booking lifecycle
- Appointment operations → Role dashboards: feeds operational metrics
- Role dashboards → Domain persistence model: aggregates records
- Domain persistence model → SQLite database: persists
