# devashishmaurya/opd architecture

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

- Interactive diagram: https://gitdiagram.com/devashishmaurya/opd
- Repository: https://github.com/devashishmaurya/opd

## Overview

##### Project type and purpose
- This is a lightweight Python-based “tool” whose sole purpose is to generate OPD (out‑patient department) slips and prescriptions by reading data from a Google Sheet, applying a rendering template (render.yaml), and producing PDF outputs (prescription.pdf, slip reports).

##### File structure
- Top‑level scripts and modules:
- app.py  – The main entry point / orchestrator
- report.py – PDF/report‐generation logic
- google_sheet.py – Google Sheets API client wrapper
- sheetUtil.py – Utility functions for parsing & transforming sheet data
- test.py – Unit/integration tests
- get-pip.py – Bootstrap pip installer (one‐off helper)
- Configuration & assets:
- render.yaml – Template definitions (fields, layout, styling)
- requirements.txt – Dependency list
- prescription.pdf – Sample output or static asset
- README.md simply notes “opd slips,” confirming the PDF generation focus.

##### Key external dependency
- Google Sheets API

##### Main components
a. Client/Trigger
- CLI or scheduler that invokes app.py
b. Configuration Loader
- render.yaml reader
c. Google Sheets Service
- google_sheet.py calling Google API
d. Data Processing Layer
- sheetUtil.py transforms raw rows into domain objects
e. Report Generation Layer
- report.py uses domain objects + template to render PDF
f. Output Store
- File system (local folder) or downstream distribution
g. Tests
- test.py (can be shown off to the side)

##### Relationships & data flow
- From app.py → Configuration Loader (reads render.yaml)
- app.py → Google Sheets Service → external Google API
- Raw data → sheetUtil.py → normalized data
- Normalized data + template → report.py → PDF output
- PDF output → local file system (prescription.pdf, slip_NNN.pdf)

##### Architectural patterns & principles
- Single‐process, layered‐architecture script
- Separation of concerns: API client, utilities, report generation, configuration
- Config driven (render.yaml) to support template changes without code edits

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Components
    CLI["CLI / Scheduler"]:::internal
    App["App Orchestrator (app.py)"]:::internal
    Config["Configuration Loader\nrender.yaml"]:::config
    SheetsService["Google Sheets Service\n(google_sheet.py)"]:::internal
    GoogleAPI[(Google Sheets API)]:::externalAPI
    DataTransform["Data Processing\n(sheetUtil.py)"]:::internal
    ReportGen["PDF Generator\n(report.py)"]:::internal
    Output["Output Store\n(prescription.pdf)"]:::output
    Tests["Tests (test.py)"]:::test

    %% Data Flow
    CLI -->|"invoke"| App
    App -->|"read template"| Config
    App -->|"request data"| SheetsService
    SheetsService -->|"call API"| GoogleAPI
    GoogleAPI -->|"raw rows"| SheetsService
    SheetsService -->|"raw rows"| DataTransform
    DataTransform -->|"domain objects"| ReportGen
    ReportGen -->|"PDF bytes"| Output
    Tests -.->|runs against| App

    %% Click Events
    click App "https://github.com/devashishmaurya/opd/blob/main/app.py"
    click Config "https://github.com/devashishmaurya/opd/blob/main/render.yaml"
    click SheetsService "https://github.com/devashishmaurya/opd/blob/main/google_sheet.py"
    click DataTransform "https://github.com/devashishmaurya/opd/blob/main/sheetUtil.py"
    click ReportGen "https://github.com/devashishmaurya/opd/blob/main/report.py"
    click Output "https://github.com/devashishmaurya/opd/blob/main/prescription.pdf"
    click Tests "https://github.com/devashishmaurya/opd/blob/main/test.py"

    %% Styles
    classDef internal fill:#D6EAF8,stroke:#3498DB,color:#1B4F72;
    classDef externalAPI fill:#ABEBC6,stroke:#27AE60,color:#145A32;
    classDef config fill:#FCF3CF,stroke:#F1C40F,color:#7D6608;
    classDef output fill:#D5D8DC,stroke:#566573,color:#1C2833;
    classDef test fill:#FADBD8,stroke:#E74C3C,color:#641E16;
```
