# sumithemmadi/truecallerjs architecture

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

- Interactive diagram: https://gitdiagram.com/sumithemmadi/truecallerjs
- Repository: https://github.com/sumithemmadi/truecallerjs

## Overview

##### Main Components
- Core Library Functions: The source files under the "src" directory (e.g., src/index.ts, src/search.ts, src/login.ts, src/verifyOtp.ts) represent the core business logic, handling API communication, data processing, and formatting.
- Data Module: The "src/data" folder, which contains static JSON files (such as continents.json, countries.json, languages.json, phones.json) and TypeScript files, represents auxiliary data used by the library.
- Command Line Interface (CLI): The CLI entry point found in src/cli.ts allows the library to be executed from the command line. This component takes user input, processes command options (like login, search, and bulk search), and then calls the appropriate library functions.
- Testing & Distribution: The "test" directory contains test scripts ensuring the functions (login, verifyOtp, search, bulkSearch) work as expected. The "dist" directory shows the compiled output, including both CommonJS and potential module formats, which represents the packaged production version of the library.
- Configuration & Build Tools: Various configuration files (.babelrc.json, .eslintrc.json, tsconfig.json, jest.config.ts, etc.) indicate the use of TypeScript, ESLint, Prettier, and Jest. These parts are essential for development, testing, and ensuring code quality.

##### Relationships and Interactions
- The CLI acts as an entry point for end-users, parsing command-line inputs and dispatching commands via the core library functions.
- The core functions (search, login, bulkSearch, verifyOtp) interface with the external Truecaller service (not shown as internal code but implied by the API integration described in the README).
- The data files and static JSON assets are used within the core functionality to provide supporting data (like phone number formatting or country details).
- The build pipeline takes source files (src) and generates a distributable version (in dist) that is consumable as a library through an npm package.
- Testing ensures that inputs through both the CLI and the library methods produce the correct outputs.

##### Architectural Patterns and Technologies
- Modularity: The separation between the CLI (src/cli.ts) and the core library functions (src/index.ts, src/search.ts, etc.) shows a clear modular design.
- API Abstraction: The library abstracts the Truecaller API details, exposing simple functions (e.g., search and bulk search) to the user.
- Compatibility: Support for Node.js, JavaScript, and TypeScript as indicated by multiple type definitions (.d.ts files) and configurations.
- Build and Test Integration: The use of tools like Babel, ESLint, Prettier, and Jest is integral to the development process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interface Layer"
        CLI["CLI Interface (src/cli.ts)"]:::userFacing
    end

    subgraph "Core Library Layer"
        LIB["Core Library Module (src/index.ts, src/search.ts, src/login.ts, src/verifyOtp.ts)"]:::internal
        DATA["Data Module (src/data)"]:::internalData
    end

    subgraph "External & Deployment"
        API["Truecaller API"]:::external
        BUILD["Build Pipeline (dist)"]:::build
        TEST["Test Suite (test)"]:::test
        CONFIG["Configuration & Build Tools (root config files)"]:::config
    end

    CLI -->|"command-delegation"| LIB
    LIB -->|"API-requests"| API
    LIB -->|"data-lookup"| DATA
    LIB -->|"bundled-by"| BUILD
    TEST -->|"validates"| LIB
    CONFIG -->|"configures"| LIB
    CONFIG -->|"configures"| BUILD
    CONFIG -->|"configures"| TEST

    click CLI "https://github.com/sumithemmadi/truecallerjs/blob/main/src/cli.ts"
    click LIB "https://github.com/sumithemmadi/truecallerjs/blob/main/src/index.ts"
    click DATA "https://github.com/sumithemmadi/truecallerjs/tree/main/src/data"
    click TEST "https://github.com/sumithemmadi/truecallerjs/tree/main/test"
    click BUILD "https://github.com/sumithemmadi/truecallerjs/tree/main/dist"
    click CONFIG "https://github.com/sumithemmadi/truecallerjs/blob/main/.eslintrc.json"

    classDef userFacing fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef internal fill:#90be6d,stroke:#000,stroke-width:2px;
    classDef internalData fill:#90be6d,stroke:#000,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#f9844a,stroke:#000,stroke-width:2px;
    classDef build fill:#577590,stroke:#000,stroke-width:2px;
    classDef test fill:#277da1,stroke:#000,stroke-width:2px;
    classDef config fill:#e07a5f,stroke:#000,stroke-width:2px;
```
