# prameshbasnet/nepali_date_converter architecture

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

- Interactive diagram: https://gitdiagram.com/prameshbasnet/nepali_date_converter
- Repository: https://github.com/prameshbasnet/nepali_date_converter

## Overview

##### Project Type and Purpose
- This is a Flutter/Dart package intended for date conversion between Nepali (BS) and English (AD) calendars.
- Its primary purpose is to offer simple, type-safe, and null-safe methods for converting dates, making the conversion logic encapsulated and reusable.
- The package includes a preloaded dataset (assets/bs_ad_dates.json) which supplies the official calendar data.

##### Analyzing the File Structure
- Top-level files include conventional package files such as LICENSE, README.md, pubspec.yaml (dependency and package configuration), and .gitignore.
- The lib directory contains the main source code (lib/nepali_date_converter.dart) where the conversion functions and possibly the data models (NepaliDate and AdDate) reside.
- The assets directory holds the JSON file (bs_ad_dates.json) with the calendar data.
- The test directory contains tests (e.g., nepali_date_converter_test.dart) ensuring the conversion logic functions as expected.

##### Relevant Components
a. Core Conversion Component:
- This module (inside lib/nepali_date_converter.dart) contains the primary functions for converting between BS and AD dates.
- It encapsulates logic for reading and interpreting the official date data.
b. Data Models:
- NepaliDate and AdDate data models that represent the dates in respective calendars.
c. Dataset Loader:
- A component responsible for parsing and loading the JSON dataset (assets/bs_ad_dates.json) into memory for conversion calculations.
d. Package Configuration & Build:
- The pubspec.yaml file indicates how the package is built, its dependencies, and makes it integrable with other Flutter apps.
e. Testing:
- Test suite housed under the test directory verifies conversion accuracy and reliability.

##### Relationships and Data Flow
- An application (or a widget in another Flutter app) calls the conversion interface provided by the package.
- The conversion interface (methods like convertBsToAd and convertAdToBs) takes a date model (NepaliDate or AdDate) as input.
- Internally, these functions consult the preloaded data (from the assets JSON) via a data loading/parsing component.
- The conversion logic processes this information, performs calculations to translate one date format to the other, and returns a new date model.
- Unit tests simulate these conversion calls checking the correct outcomes.

##### Architectural Patterns or Design Principles
- Separation of Concerns: Distinct segregation between the conversion logic, data models, and data access (JSON loader).
- Modularity: By having the core functionality in the lib folder and tests separated, the design aids in maintainability and reuse.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Application Interface"]:::interface
    B["Conversion Module"]:::conversion
    C["Data Models"]:::model
    D["Dataset Loader/Parser"]:::dataset
    E["Pubspec & Configuration"]:::config
    F["Test Suite"]:::test

    A -->|"calls"| B
    B -->|"uses"| C
    B -->|"loadsData"| D
    B -->|"returnsResult"| A
    F -->|"tests"| B
    E -.->|"buildsPackage"| B

    click B "https://github.com/prameshbasnet/nepali_date_converter/blob/main/lib/nepali_date_converter.dart"
    click C "https://github.com/prameshbasnet/nepali_date_converter/blob/main/lib/nepali_date_converter.dart"
    click D "https://github.com/prameshbasnet/nepali_date_converter/blob/main/assets/bs_ad_dates.json"
    click E "https://github.com/prameshbasnet/nepali_date_converter/blob/main/pubspec.yaml"
    click F "https://github.com/prameshbasnet/nepali_date_converter/blob/main/test/nepali_date_converter_test.dart"

    classDef interface fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef conversion fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef model fill:#B2FF66,stroke:#333,stroke-width:2px;
    classDef dataset fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef config fill:#99CCFF,stroke:#333,stroke-width:2px;
    classDef test fill:#CCCCFF,stroke:#333,stroke-width:2px;
```
