How zayed-rahat/org-chart-app works
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 Local web app · db.py Database access · import_excel.py Excel importer · requirements.txt Python dependencies
Components 17
Excel Import
- User workbook
source_data/sys_user.xlsx - Department workbook
source_data/cmn_department.xlsx - Excel importer · Skips rows whose sys_id already exists.
scripts/import_excel.py
Web Application
- Local web app · Coordinates records, history, and chart routes.
app.py - Organization models · Defines department, employee, and relationship entities.
models.py - Database access · Owns connections, schema setup, and persistence operations.
db.py - Organization database · Created locally at runtime.
- Chart renderer · Builds chart-ready data from persisted relationships.
chart_renderer.py
Presentation
- Base layout
templates/base.html - Department views · List, edit, and history screens.
- Employee views · List, edit, and history screens.
- Global history view
templates/history.html - Organization chart view · Printable browser-rendered chart.
templates/chart.html - Application styles
static/app.css - Chart print styles · Supports A3 landscape printing or PDF export.
static/chart.css
Other components
- Local browser · Displays pages and prints or exports charts.
- Python dependencies
requirements.txt
Connections 20
- 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