# zayed-rahat/org-chart-app architecture

> Architecture diagram of the GitHub repository zayed-rahat/org-chart-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zayed-rahat/org-chart-app
- Repository: https://github.com/zayed-rahat/org-chart-app

## Overview

#### Purpose and Entry Points
This is a local Python web application for importing organization data from Excel, managing department/employee records, viewing history, and rendering a printable organization chart. Runtime entry point: `app.py`. Initial/repeat data ingestion entry point: `scripts/import_excel.py`.

#### Web Application Layer
`app.py` hosts the HTTP application on localhost and coordinates page routes, record editing, history views, and chart display. Server-rendered HTML is organized around `templates/base.html`, with functional views under `templates/departments/`, `templates/employees/`, and `templates/chart.html`.

#### Persistence and Domain Model
SQLite is the system of record, auto-created as `data/syslabo.db` at runtime. Database connection, schema/table setup, and persistence operations are centralized in `db.py`; organization entities and their relationships are represented in `models.py`. This boundary isolates the web and chart layers from raw database access.

#### Excel Import Pipeline
`scripts/import_excel.py` ingests source workbooks `source_data/sys_user.xlsx` and `source_data/cmn_department.xlsx` into SQLite. Import behavior is idempotency-oriented: existing rows with the same `sys_id` are skipped rather than overwritten. Excel files are the upstream source; SQLite is the application-serving representation.

#### Department and Employee Management
Department and employee list, edit, and history screens are separate server-rendered flows: `templates/departments/list.html`, `templates/departments/edit.html`, `templates/employees/list.html`, and `templates/employees/edit.html`. History pages (`templates/departments/history.html`, `templates/employees/history.html`, `templates/history.html`) establish an audit/view-history boundary for entity changes or imported state.

#### Organization Chart Rendering
`chart_renderer.py` transforms persisted organizational relationships into chart-ready output consumed by `templates/chart.html`. The chart is browser-rendered and styled independently through `static/chart.css`; users print the resulting page or use the browser’s PDF export, targeting A3 landscape.

#### Presentation and Runtime Dependencies
The UI uses server-side templates plus static CSS: `templates/base.html`, `static/app.css`, and `static/chart.css`. Required Python packages are declared in `requirements.txt`. No remote service, cloud infrastructure, API gateway, or separate frontend build/runtime is indicated; operation depends on Python 3.11+, local filesystem Excel inputs, SQLite, and a browser.

Main entry points: [`app.py`](https://github.com/zayed-rahat/org-chart-app/blob/main/app.py) (Local web app), [`db.py`](https://github.com/zayed-rahat/org-chart-app/blob/main/db.py) (Database access), [`scripts/import_excel.py`](https://github.com/zayed-rahat/org-chart-app/blob/main/scripts/import_excel.py) (Excel importer), [`requirements.txt`](https://github.com/zayed-rahat/org-chart-app/blob/main/requirements.txt) (Python dependencies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Excel Import"]
  node_excel_users["User workbook<br/>Excel source<br/>[sys_user.xlsx]"]
  node_excel_departments["Department workbook<br/>Excel source"]
  node_importer["Excel importer<br/>Python script<br/>[import_excel.py]"]
end

subgraph group_web["Web Application"]
  node_app["Local web app<br/>Python HTTP app<br/>[app.py]"]
  node_models["Organization models<br/>domain model<br/>[models.py]"]
  node_database_access["Database access<br/>SQLite persistence<br/>[db.py]"]
  node_sqlite[("Organization database<br/>SQLite system of record")]
  node_chart_renderer["Chart renderer<br/>Python renderer<br/>[chart_renderer.py]"]
end

subgraph group_presentation["Presentation"]
  node_base_template["Base layout<br/>server template<br/>[base.html]"]
  node_department_views["Department views<br/>server templates"]
  node_employee_views["Employee views<br/>server templates"]
  node_history_view["Global history view<br/>server template<br/>[history.html]"]
  node_chart_view["Organization chart view<br/>server template<br/>[chart.html]"]
  node_app_css["Application styles<br/>CSS<br/>[app.css]"]
  node_chart_css["Chart print styles<br/>CSS<br/>[chart.css]"]
end

node_browser(("Local browser<br/>user runtime"))
node_requirements["Python dependencies<br/>package manifest<br/>[requirements.txt]"]

node_excel_users -->|"ingested by"| node_importer
node_excel_departments -->|"ingested by"| node_importer
node_importer -->|"persists imported rows"| node_database_access
node_app -->|"uses"| node_models
node_app -->|"reads and updates records"| node_database_access
node_database_access -->|"creates and accesses"| node_sqlite
node_database_access -->|"maps persisted entities"| node_models
node_app -->|"requests chart data"| node_chart_renderer
node_chart_renderer -->|"loads relationships"| node_database_access
node_app -->|"renders with"| node_base_template
node_app -->|"renders"| node_department_views
node_app -->|"renders"| node_employee_views
node_app -->|"renders"| node_history_view
node_app -->|"renders chart data into"| node_chart_view
node_base_template -->|"loads"| node_app_css
node_chart_view -->|"loads"| node_chart_css
node_browser -->|"HTTP requests"| node_app
node_app -->|"server-rendered pages"| node_browser
node_requirements -.->|"declares runtime packages"| node_app
node_requirements -.->|"declares import packages"| node_importer

click node_excel_users "https://github.com/zayed-rahat/org-chart-app/blob/main/source_data/sys_user.xlsx"
click node_excel_departments "https://github.com/zayed-rahat/org-chart-app/blob/main/source_data/cmn_department.xlsx"
click node_importer "https://github.com/zayed-rahat/org-chart-app/blob/main/scripts/import_excel.py"
click node_app "https://github.com/zayed-rahat/org-chart-app/blob/main/app.py"
click node_models "https://github.com/zayed-rahat/org-chart-app/blob/main/models.py"
click node_database_access "https://github.com/zayed-rahat/org-chart-app/blob/main/db.py"
click node_chart_renderer "https://github.com/zayed-rahat/org-chart-app/blob/main/chart_renderer.py"
click node_base_template "https://github.com/zayed-rahat/org-chart-app/blob/main/templates/base.html"
click node_history_view "https://github.com/zayed-rahat/org-chart-app/blob/main/templates/history.html"
click node_chart_view "https://github.com/zayed-rahat/org-chart-app/blob/main/templates/chart.html"
click node_app_css "https://github.com/zayed-rahat/org-chart-app/blob/main/static/app.css"
click node_chart_css "https://github.com/zayed-rahat/org-chart-app/blob/main/static/chart.css"
click node_requirements "https://github.com/zayed-rahat/org-chart-app/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_excel_users,node_excel_departments,node_importer toneBlue
class node_app,node_models,node_database_access,node_sqlite,node_chart_renderer toneAmber
class node_base_template,node_department_views,node_employee_views,node_history_view,node_chart_view,node_app_css,node_chart_css toneMint
class node_browser,node_requirements toneNeutral
```

## Components

### Excel Import

- [User workbook](https://github.com/zayed-rahat/org-chart-app/blob/main/source_data/sys_user.xlsx): Excel source · `source_data/sys_user.xlsx`
- [Department workbook](https://github.com/zayed-rahat/org-chart-app/blob/main/source_data/cmn_department.xlsx): Excel source · `source_data/cmn_department.xlsx`
- [Excel importer](https://github.com/zayed-rahat/org-chart-app/blob/main/scripts/import_excel.py): Python script · Skips rows whose sys_id already exists. · `scripts/import_excel.py`

### Web Application

- [Local web app](https://github.com/zayed-rahat/org-chart-app/blob/main/app.py): Python HTTP app · Coordinates records, history, and chart routes. · `app.py`
- [Organization models](https://github.com/zayed-rahat/org-chart-app/blob/main/models.py): domain model · Defines department, employee, and relationship entities. · `models.py`
- [Database access](https://github.com/zayed-rahat/org-chart-app/blob/main/db.py): SQLite persistence · Owns connections, schema setup, and persistence operations. · `db.py`
- **Organization database**: SQLite system of record · Created locally at runtime.
- [Chart renderer](https://github.com/zayed-rahat/org-chart-app/blob/main/chart_renderer.py): Python renderer · Builds chart-ready data from persisted relationships. · `chart_renderer.py`

### Presentation

- [Base layout](https://github.com/zayed-rahat/org-chart-app/blob/main/templates/base.html): server template · `templates/base.html`
- **Department views**: server templates · List, edit, and history screens.
- **Employee views**: server templates · List, edit, and history screens.
- [Global history view](https://github.com/zayed-rahat/org-chart-app/blob/main/templates/history.html): server template · `templates/history.html`
- [Organization chart view](https://github.com/zayed-rahat/org-chart-app/blob/main/templates/chart.html): server template · Printable browser-rendered chart. · `templates/chart.html`
- [Application styles](https://github.com/zayed-rahat/org-chart-app/blob/main/static/app.css): CSS · `static/app.css`
- [Chart print styles](https://github.com/zayed-rahat/org-chart-app/blob/main/static/chart.css): CSS · Supports A3 landscape printing or PDF export. · `static/chart.css`

### Other components

- **Local browser**: user runtime · Displays pages and prints or exports charts.
- [Python dependencies](https://github.com/zayed-rahat/org-chart-app/blob/main/requirements.txt): package manifest · `requirements.txt`

## Connections

- User workbook → Excel importer: ingested by
- Department workbook → Excel importer: ingested by
- Excel importer → Database access: persists imported rows
- Local web app → Organization models: uses
- Local web app → Database access: reads and updates records
- Database access → Organization database: creates and accesses
- Database access → Organization models: maps persisted entities
- Local web app → Chart renderer: requests chart data
- Chart renderer → Database access: loads relationships
- Local web app → Base layout: renders with
- Local web app → Department views: renders
- Local web app → Employee views: renders
- Local web app → Global history view: renders
- Local web app → Organization chart view: renders chart data into
- Base layout → Application styles: loads
- Organization chart view → Chart print styles: loads
- Local browser → Local web app: HTTP requests
- Local web app → Local browser: server-rendered pages
- Python dependencies → Local web app: declares runtime packages
- Python dependencies → Excel importer: declares import packages
