# ajayathitya/discern architecture

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

- Interactive diagram: https://gitdiagram.com/ajayathitya/discern
- Repository: https://github.com/ajayathitya/discern

## Overview

##### Project Type and Purpose
- Discern is an offline, single‐module machine‐learning tool: a Convolutional Neural Network (CNN) based handwritten character recognizer implemented in Python (delivered as a Jupyter notebook) that trains on the EMNIST dataset and produces a serialized model (.h5) for inference.

##### High‐Level Components
a. Data Source
- EMNIST dataset (external)
b. Data Preprocessing & Augmentation
- Python routines inside `cnn_final_model.ipynb`
c. Model Architecture & Training Pipeline
- CNN layers defined via Keras/TensorFlow in the notebook
- Training loops, loss functions, metrics
d. Model Artifact
- `emnist_model.h5` (trained weights + topology)
e. Inference Engine
- Notebook cells or standalone Python code that load the .h5 model and accept new image inputs
f. Visualization / UI
- Sample GIF in `Images/Sample.gif` demonstrating inference
g. Support Files
- LICENSE, README.md, and the `Images/` directory

##### Architectural Patterns & Design Principles
- Separation of concerns: training vs. inference
- Modular components: data pipeline, model definition, persistence, and inference
- Reproducibility: versioned notebook + serialized model

##### Key Technologies & Dependencies
- Python 3.x
- Jupyter Notebook (`cnn_final_model.ipynb`)
- TensorFlow / Keras for CNN definition & training
- EMNIST dataset (external download)
- HDF5 serialization for model (`.h5` file)

##### Detail & Clarity
- Use clear, concise labels, and ensure arrowheads point in the exact direction of data movement.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Source
    EMNIST["EMNIST Dataset"]:::data

    %% Notebook Container
    subgraph "Notebook (cnn_final_model.ipynb)"
        Preprocessing["Preprocessing & Augmentation"]:::compute
        Training["CNN Training"]:::compute
        Inference["Inference Engine"]:::compute
    end

    %% Storage & Visualization
    ModelStorage["Model Storage (.h5)"]:::storage
    UI["UI / Visualization"]:::viz

    %% Documentation
    README["README.md"]:::doc
    LICENSE["LICENSE"]:::doc

    %% Data Flows
    EMNIST -->|"Arrow 1: Data Ingestion"| Preprocessing
    Preprocessing -->|"Arrow 2: Training Pipeline"| Training
    Training -->|"Arrow 3: Serialization"| ModelStorage
    ModelStorage -->|"Arrow 4: Load for Inference"| Inference
    Inference -->|"Arrow 5: Visualization Output"| UI

    %% Annotations
    note["Python 3.x\nTensorFlow/Keras\nHDF5 Serialization"]:::annotation
    Preprocessing -.-> note
    Training     -.-> note
    Inference    -.-> note

    %% Click Events
    click Preprocessing "https://github.com/ajayathitya/discern/blob/master/cnn_final_model.ipynb"
    click Training "https://github.com/ajayathitya/discern/blob/master/cnn_final_model.ipynb"
    click Inference "https://github.com/ajayathitya/discern/blob/master/cnn_final_model.ipynb"
    click ModelStorage "https://github.com/ajayathitya/discern/blob/master/emnist_model.h5"
    click UI "https://github.com/ajayathitya/discern/blob/master/Images/Sample.gif"
    click README "https://github.com/ajayathitya/discern/blob/master/README.md"
    click LICENSE "https://github.com/ajayathitya/discern/tree/master/LICENSE"

    %% Styles
    classDef data fill:#AED6F1,stroke:#21618C,color:#1B4F72
    classDef compute fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef storage fill:#F5B041,stroke:#B9770E,color:#7D6608
    classDef viz fill:#D2B4DE,stroke:#6C3483,color:#4A235A
    classDef doc fill:#D5D8DC,stroke:#566573,color:#2C3E50
    classDef annotation fill:#FFFFFF,stroke:#000000,stroke-dasharray: 2,color:#000000
```
