# dhananjayrbiraris/text-classification architecture

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

- Interactive diagram: https://gitdiagram.com/dhananjayrbiraris/text-classification
- Repository: https://github.com/dhananjayrbiraris/text-classification

## Overview

##### Project Type and Purpose
- At a high level, this is primarily a **Python-based text-classification CLI application** that implements a Naive Bayes pipeline: data loading, preprocessing, vectorization, training, and evaluation.
- Additionally, there is a **TypeScript/Node “project” subfolder** containing `app.ts` and related config (`package.json`, `tsconfig.json`, type definitions). This looks like a parallel or companion service (e.g., an API server or integration layer), though the README focuses on the Python pipeline.

##### File Structure Analysis
- **Root Level**
- `main.py` – the entry point for the Python pipeline.
- `README.md` – documents the text-classification flow in Python, external dependencies.
- **/project Subfolder**
- `package.json` + `tsconfig.json` – Node/TS config and dependencies.
- `src/app.ts` – TypeScript application entrypoint.
- `src/types/index.ts` – shared type definitions.
- `LICENSE`, `project/README.md` – legal and potentially separate documentation.

a. **Data Sources** (CSV, Excel, JSON, PDF)
b. **Python CLI Application**
– Load Data Module (`load_data`)
– Preprocessing Module (`preprocess_data`)
– Vectorization Module (`vectorize_text`)
– Model Training Module (`train_model`)
– Evaluation Module (`evaluate_model`)
c. **External Libraries**
– pandas, numpy, scikit-learn, pdfplumber
d. **TypeScript/Node Service** (optional companion)
– app.ts service
– Type definitions
– build/transpile step (tsconfig → JavaScript)
e. **Outputs**
– Accuracy score, classification report (printed to console or saved)

##### Relationships & Data Flows
- From **Load Data** → **Preprocess Data** → **Vectorization** → **Training** → **Evaluation**.
- From **Evaluation** → **Console Output / Report File**.
- TS build process: `src/app.ts` → [tsc] → `dist/app.js`.

##### Architectural Patterns & Principles
- **Modular pipeline**: each stage is self-contained and could be replaced or extended (e.g., swap out CountVectorizer for TF-IDF).
- **Separation of concerns**: data I/O, preprocessing, modeling, evaluation.
- **CLI vs. Service**: Python acts as a command-line tool; TS folder hints at a service/packaging layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Sources"
        DS["Data Sources\n(CSV, Excel, JSON, PDF)"]:::datasrc
    end

    subgraph "Python CLI Application"
        LoadData["Load Data Module\n(pandas, pdfplumber)"]:::python
        Preprocess["Preprocessing Module\n(numpy)"]:::python
        Vectorize["Vectorization Module\n(sklearn CountVectorizer)"]:::python
        Train["Model Training Module\n(sklearn Naive Bayes)"]:::python
        Eval["Evaluation Module\n(report generation)"]:::python
        Output["Console Output / Report File"]:::output
        Readme["README.md"]:::doc
    end

    DS --> LoadData --> Preprocess --> Vectorize --> Train --> Eval --> Output
    Readme -.-> LoadData

    subgraph "TS/Node Companion Service"
        Pkg["package.json"]:::service
        TSC["tsconfig.json"]:::service
        Build["TypeScript Build\n(tsc → dist)"]:::service
        App["app.ts"]:::service
        Types["types/index.ts"]:::service
        ReadmeP["README.md"]:::service
        License["LICENSE"]:::service
    end

    Pkg --> App
    TSC --> Build --> App
    Types --> App
    App -.->|"invoke Python CLI"| LoadData

    subgraph Legend
        direction LR
        DS2["Parallelogram: Data Sources"]:::datasrc
        P2["Blue Box: Python Modules"]:::python
        S2["Purple Box: TS Service"]:::service
        O2["Cylinder: Outputs"]:::output
        D2["Yellow Box: Docs"]:::doc
    end

    click LoadData "https://github.com/dhananjayrbiraris/text-classification/blob/main/main.py"
    click Preprocess "https://github.com/dhananjayrbiraris/text-classification/blob/main/main.py"
    click Vectorize "https://github.com/dhananjayrbiraris/text-classification/blob/main/main.py"
    click Train "https://github.com/dhananjayrbiraris/text-classification/blob/main/main.py"
    click Eval "https://github.com/dhananjayrbiraris/text-classification/blob/main/main.py"
    click Readme "https://github.com/dhananjayrbiraris/text-classification/blob/main/README.md"
    click App "https://github.com/dhananjayrbiraris/text-classification/blob/main/project/src/app.ts"
    click Types "https://github.com/dhananjayrbiraris/text-classification/blob/main/project/src/types/index.ts"
    click Pkg "https://github.com/dhananjayrbiraris/text-classification/blob/main/project/package.json"
    click TSC "https://github.com/dhananjayrbiraris/text-classification/blob/main/project/tsconfig.json"
    click ReadmeP "https://github.com/dhananjayrbiraris/text-classification/blob/main/project/README.md"
    click License "https://github.com/dhananjayrbiraris/text-classification/tree/main/project/LICENSE"

    classDef python fill:#add8e6,stroke:#000
    classDef service fill:#dda0dd,stroke:#000
    classDef datasrc fill:#90ee90,stroke:#000
    classDef output fill:#ffa500,stroke:#000
    classDef doc fill:#f0e68c,stroke:#000
```
