# kstickney/quote-system architecture

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

- Interactive diagram: https://gitdiagram.com/kstickney/quote-system
- Repository: https://github.com/kstickney/quote-system

## Overview

##### Project type and purpose
- This is a standalone Python-based desktop quoting system (“Business Quote System”).
- Purpose: let a small business create, store, and export customer quotes (PDFs) using local data and optionally scrape vendor prices from the web.

##### High-level architecture and main components
We will represent the system as a layered, modular desktop application with these primary components:
A. Presentation Layer (Desktop GUI)
– Quote_System.py (main entry point)
– PyQt/Qt styles & resources (styles/, stylesheets/, fonts/, images/)
B. Business Logic Layer
– CustomClasses.py (domain-specific objects: Quote, LineItem, Settings)
– pdf/pdfcreator.py + jinja2 templates (quote-template.html.j2)
– web_scraping/ (optional service to fetch prices)
C. Data Access Layer
– database.py (Access .accdb integration)
– Pickle files under data/ and “Fresh Pickle Files” (settings, database snapshot)
D. External Tools & Services
– wkhtmltopdf.exe & wkhtmltoimage.exe (PDF renderer)
– pyinstaller (for packaging .exe)
– Access Database driver (OLEDB/ODBC)
E. Cross-cutting Concerns
– Logging (app.log)
– Configuration files (pylintrc, Makefile, .github/workflows/ci.yaml)
– Build & packaging (setup.py, requirements.txt)

##### Relationships and data flows
- User → GUI: triggers “New Quote,” “Load Quote,” “Generate PDF,” “Fetch Prices.”
- GUI → Business Logic: passes domain objects to CustomClasses, invokes PDF creator and scraper.
- Business Logic → Data Layer: reads/writes quotes and settings to .accdb and pickles.
- PDF Creator → External Tool: renders HTML via wkhtmltopdf to generate final PDF.
- Web Scraper → External Sites: scrapes industrial automation price data, returns to business logic, and persists to database.
- All modules write to app.log for audit/troubleshooting.

##### Architectural patterns & design principles
- Layered (Presentation → Business → Data → External).
- Separation of concerns: styling in dedicated directories; logic in CustomClasses & pdfcreator; data access abstracted in database.py; external integration encapsulated.
- Resource bundling: Qt resource files (.qrc) map images/fonts into GUI.

##### Final checklist
– All components clearly labeled.
– A note on build process (PyInstaller) and CI (ci.yaml) for completeness.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User interaction
    User["User"]:::external -->|"open GUI / New Quote / Load Quote"| GUI["Quote_System.py"]:::python

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        GUI["Quote_System.py"]:::python
        Styles["styles/"]:::python
        Sheets["stylesheets/"]:::python
        Fonts["fonts/"]:::python
        Images["images/"]:::python
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        Classes["CustomClasses.py"]:::python
        PDFModule["pdf/pdfcreator.py"]:::python
        Template["pdf/quote-template.html.j2"]:::python
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DBModule["database.py"]:::python
        AccessDB["TRW Quote Database.accdb"]:::data
        AccessDBBackup["TRW Quote Database_Backup.accdb"]:::data
        Pickles["data/*.pickle"]:::data
        FreshPickles["Fresh Pickle Files/"]:::data
    end

    %% Web Scraping Optional Module
    subgraph "Web Scraping Module (Optional)" 
        direction TB
        ScraperCore["web_scraping/"]:::optional
    end

    %% External Tools & Services
    subgraph "External Tools & Services"
        direction TB
        WKPDF["pdf/bin/wkhtmltopdf.exe"]:::external
        WKImage["pdf/bin/wkhtmltoimage.exe"]:::external
        Installer["wkhtmltox-0.12.4_msvc2015-win64.exe"]:::external
        PyInstaller["pyinstaller"]:::external
        DBDriver["Access DB driver (OLEDB/ODBC)"]:::external
    end

    %% Cross-cutting Concerns
    subgraph "Cross-cutting Concerns"
        direction TB
        Log["app.log"]:::data
        Config[".pylintrc / Makefile / .github/workflows/ci.yaml"]:::python
        Build["setup.py / requirements.txt / test-requirements.txt"]:::python
    end

    %% Connections
    GUI -->|"createQuote()/loadQuote()"| Classes
    GUI -->|"generatePDF()"| PDFModule
    GUI -->|"fetchPrices()"| ScraperCore
    Classes -->|"saveQuote()/loadQuote()"| DBModule
    DBModule -->|"read/write .accdb & pickle"| AccessDB
    DBModule --> AccessDBBackup
    DBModule --> Pickles
    Classes --> Pickles
    Pickles --> FreshPickles
    PDFModule -->|"render HTML"| Template
    PDFModule -->|"call wkhtmltopdf"| WKPDF
    PDFModule -->|"call wkhtmltoimage"| WKImage
    ScraperCore -->|".scrape() (async)"| DBModule
    ScraperCore -.->|"HTTP requests"| Internet["External Sites"]:::external
    Classes --> Log
    GUI --> Log
    PDFModule --> Log
    ScraperCore --> Log
    DBModule --> Log
    Config --> GUI
    Config --> Classes
    Build --> GUI
    Build --> PDFModule
    Build --> DBModule
    Build --> ScraperCore
    Build --> WKPDF
    Build --> PyInstaller

    %% Click Events
    click GUI "https://github.com/kstickney/quote-system/blob/main/Quote_System.py"
    click Styles "https://github.com/kstickney/quote-system/tree/main/styles/"
    click Sheets "https://github.com/kstickney/quote-system/tree/main/stylesheets/"
    click Fonts "https://github.com/kstickney/quote-system/tree/main/fonts/"
    click Images "https://github.com/kstickney/quote-system/tree/main/images/"
    click Classes "https://github.com/kstickney/quote-system/blob/main/CustomClasses.py"
    click PDFModule "https://github.com/kstickney/quote-system/blob/main/pdf/pdfcreator.py"
    click Template "https://github.com/kstickney/quote-system/blob/main/pdf/quote-template.html.j2"
    click DBModule "https://github.com/kstickney/quote-system/blob/main/database.py"
    click AccessDB "https://github.com/kstickney/quote-system/blob/main/data/TRW Quote Database.accdb"
    click AccessDBBackup "https://github.com/kstickney/quote-system/blob/main/data/TRW Quote Database_Backup.accdb"
    click Pickles "https://github.com/kstickney/quote-system/tree/main/data/"
    click FreshPickles "https://github.com/kstickney/quote-system/tree/main/Fresh Pickle Files/"
    click ScraperCore "https://github.com/kstickney/quote-system/tree/main/web_scraping/"
    click WKPDF "https://github.com/kstickney/quote-system/blob/main/pdf/bin/wkhtmltopdf.exe"
    click WKImage "https://github.com/kstickney/quote-system/blob/main/pdf/bin/wkhtmltoimage.exe"
    click Installer "https://github.com/kstickney/quote-system/blob/main/wkhtmltox-0.12.4_msvc2015-win64.exe"
    click PyInstaller "https://github.com/kstickney/quote-system/tree/main/pyinstaller"
    click DBDriver "https://github.com/kstickney/quote-system/tree/main/Access DB driver (OLEDB/ODBC)"
    click Log "https://github.com/kstickney/quote-system/blob/main/app.log"
    click Config "https://github.com/kstickney/quote-system/blob/main/.github/workflows/ci.yaml"
    click Build "https://github.com/kstickney/quote-system/blob/main/setup.py"

    %% Styles
    classDef python fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef optional fill:#FFD700,stroke-dasharray: 5 5,stroke:#333,stroke-width:1px;
```
