# webresh/drik-panchanga architecture

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

- Interactive diagram: https://gitdiagram.com/webresh/drik-panchanga
- Repository: https://github.com/webresh/drik-panchanga

## Overview

##### Project Type and Purpose
- This project is a standalone desktop application written in Python. Its purpose is to compute the essential elements of the Indian lunisolar calendar (panchanga) such as Tithi, Nakshatra, Yoga, Karana, and Vaara using astronomical data from the Swiss Ephemeris.
- The application supports both a command-line interface (via the core library logic in panchanga.py) and a graphical user interface (via gui.py) built on wxPython. It also provides location lookup functionality based on provided CSV/JSON data files.

##### File Structure
- Top-Level Files:
- panchanga.py: Contains the core computational logic for the calendar, interfacing with the Swiss Ephemeris.
- gui.py: Implements the graphical user interface that gathers user input, triggers computations, and displays the results.
- geonames.py: Likely handles location-related functions such as searching for cities or geographical coordinates.
- Gui.wxg: A design file for wxGlade which is used to modify or regenerate the GUI layout.
- cities.csv & cities.json: Data files that likely support location lookup. They provide data for recognized places.
- sanskrit_names.json: Might store Sanskrit names or additional nomenclature needed for display or internal mapping.
- README.md & .gitignore: Standard files for project documentation and version control.

##### README for Additional Insights
- The README provides a large amount of detail regarding features, dependencies, and usage. It clearly states that the application is built using Python and depends on the Swiss Ephemeris (through the pyswisseph package) for astronomical calculations.
- The instructions and installation notes (involving python-tz, wxPython for the GUI, and python-wxglade for GUI design modifications) give insights into both runtime and development aspects.
- The README highlights two modes for inputting location (search versus manual coordinate entry) which hints at the presence of a location lookup module.

A. Identify the Main Components:
- User Interface Layer:
- GUI (gui.py) and the associated design file (Gui.wxg) that govern user input and display.
- Core Business Logic / Computational Module:
- Panchanga Module (panchanga.py) that performs panchanga calculations.
- Location/Geographical Data Module:
- Geonames Module (geonames.py) in combination with cities.csv, cities.json, and sanskrit_names.json to manage and lookup geographic locations.
- External Dependency:
- Swiss Ephemeris (accessed via pyswisseph) serving as the astronomical data engine.

B. Determine Relationships and Data Flow:
- User Actions:
- Users interact with the GUI to input date, location, and optionally modify configuration (coordinates/time zone).
- Data Flow:
- The GUI collects the input and passes the relevant data (date, location info) to the core computational module (panchanga.py).
- If the location is provided as a city name, the GUI likely calls routines in geonames.py which accesses cities.csv/cities.json to resolve coordinates.
- The panchanga.py module then uses Swiss Ephemeris’s functionality to compute calendar values and timings.
- Results are sent back up to the GUI for display.
- Optional UI Design:
- The GUI layout is designed and can be modified using wxGlade via the Gui.wxg file.

C. Highlight Important Architectural Patterns:
- Separation of Concerns:
- The user interface, business logic, and data lookup functions are distinctly separated.
- Modular Design:
- The core panchanga computations are isolated in one module, which makes the library importable and reusable.
- Integration with External Libraries:
- The design neatly separates internal logic from externally provided services like the Swiss Ephemeris (pyswisseph) and wxWidgets (via wxPython).

D. Include Relevant Technologies:
- Python as the programming language.
- wxPython for graphical user interface.
- Swiss Ephemeris (via pyswisseph) for astronomical computations.
- Additional packages such as python-tz for time zone handling and python-wxglade for UI design.

- Clear labels for each component:
- “Graphical User Interface (gui.py & Gui.wxg)”
- “Panchanga Calculation Module (panchanga.py)”
- “Location Lookup Module (geonames.py + cities.csv/cities.json)”
- “Swiss Ephemeris (pyswisseph) – External Dependency”
- From the “User Input” in the GUI to the “Location Lookup Module” (if a city name is provided).
- From the GUI to the “Panchanga Calculation Module” to show how date and location inputs are passed.
- From the “Panchanga Calculation Module” to the “Swiss Ephemeris” indicating dependency on external astronomical computations.
- Distinct visual elements:

## Diagram (Mermaid)

```mermaid
graph TD
    UI["User Input"]:::input
    GUI["Graphical User Interface (gui.py & Gui.wxg)"]:::gui
    PAN["Panchanga Calculation Module (panchanga.py)"]:::business
    GEO["Location Lookup Module (geonames.py + cities.csv, cities.json, sanskrit_names.json)"]:::data
    SW["Swiss Ephemeris (pyswisseph) - External Dependency"]:::external

    UI -->|"triggers"| GUI
    GUI -->|"if_city_provided"| GEO
    GUI -->|"provides_date_location"| PAN
    GEO -->|"provides_coordinates"| PAN
    PAN -->|"calls_calculation"| SW
    PAN -->|"returns_results"| GUI

    click GUI "https://github.com/webresh/drik-panchanga/blob/master/gui.py"
    click GUI "https://github.com/webresh/drik-panchanga/blob/master/Gui.wxg"
    click PAN "https://github.com/webresh/drik-panchanga/blob/master/panchanga.py"
    click GEO "https://github.com/webresh/drik-panchanga/blob/master/geonames.py"
    click GEO "https://github.com/webresh/drik-panchanga/blob/master/cities.csv"
    click GEO "https://github.com/webresh/drik-panchanga/blob/master/cities.json"
    click GEO "https://github.com/webresh/drik-panchanga/blob/master/sanskrit_names.json"

    classDef gui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef input fill:#e2d9f3,stroke:#6f42c1,stroke-width:2px;
```
