# digbenjamins/solanatokensniper architecture

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

- Interactive diagram: https://gitdiagram.com/digbenjamins/solanatokensniper
- Repository: https://github.com/digbenjamins/solanatokensniper

## Overview

##### Project type and purpose
- This is a Node.js (TypeScript) “sniper” and “tracker” bot for the Solana blockchain.
- Purpose: automatically detect and purchase tokens on Solana (PumpSwap/Raydium), perform rug-checks, optionally skip certain tokens, and track trades for stop-loss/take-profit or logging.

##### File structure
- Top-level:
- package.json / tsconfig.json / eslint.config.mjs – Node/TS project config
- README.md / CHANGELOG.md – documentation
- src/
- config.ts – loads .env and parameters
- index.ts – entry point, dispatches “sniper” or “tracker” mode
- test/ – unit tests for individual handlers
- tracker/
– db.ts – persistence of trade events or order history
- utils/
– env-validator.ts – guarantees required env vars
– handlers/ – business‐logic units (rugCheck, signature, sniperoo, token)
– managers/ – websocketManager for live events
– notification.ts – alerts/logging
- types.ts – shared TypeScript types and interfaces

##### Key architecture insights from README
- Two runtime modes: sniper (real-time token purchase) and tracker (persist / monitor trades)
- Integrates four external services/APIs: Solana RPC (Helius), rugcheck.xyz, Sniperoo, JITO
- Pipeline of checks & actions: incoming token event → rug check → signature check → JITO or Sniperoo buy → optionally monitor & auto-sell

##### Final advice
- Two parallel paths: the real-time sniper pipeline and the tracker persistence pipeline.
- Don’t overthink: break the project into components exactly as they appear in the file tree and README, then illustrate how they connect.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Point & Mode Selection"
        Entry["Entry Point / CLI<br/>Mode Selector"]:::core
    end

    subgraph "Configuration & Utilities"
        Config["Config Loader"]:::util
        EnvVal["Environment Validator"]:::util
        Types["Shared Types & Interfaces"]:::util
        Notification["Notification & Logging Module"]:::util
    end

    subgraph "Core Modules"
        WS["WebSocket Manager"]:::core
        RugCheck["RugCheck Handler"]:::core
        SigCheck["Signature Handler"]:::core
        TokenSkip["Token Handler"]:::core
        Sniperoo["Sniperoo Handler"]:::core
    end

    subgraph "External Services"
        SolanaRPC["Solana RPC (Helius)"]:::external
        RugAPI["RugCheck API"]:::external
        SniperooAPI["Sniperoo API"]:::external
        JITO["JITO RPC / Priority Service"]:::external
    end

    subgraph "Persistence"
        DB["Tracker DB Persistence"]:::persistence
    end

    subgraph "Tests"
        Test1["rugCheckHandler.test.ts"]:::test
        Test2["sniperooHandler.test.ts"]:::test
    end

    Entry -->|"loads"| Config
    Entry -->|"validates"| EnvVal
    Entry -->|"uses types"| Types
    Entry -->|"initiates Sniper Mode"| WS
    Entry -->|"initiates Tracker Mode"| DB

    WS -->|"WS event (new token)"| RugCheck
    RugCheck -->|"HTTP REST"| RugAPI
    RugCheck -->|passes| SigCheck
    SigCheck -->|"passes"| TokenSkip
    TokenSkip -->|passes| Sniperoo
    Sniperoo -->|"HTTP REST"| SniperooAPI
    Sniperoo -->|"optionally"| JITO
    Sniperoo -->|"transaction"| SolanaRPC
    Sniperoo -->|"notifies"| Notification

    DB -->|"write events"| DB
    DB -->|"logs"| Notification

    RugCheck --> Test1
    Sniperoo --> Test2

    click Config "https://github.com/digbenjamins/solanatokensniper/blob/main/src/config.ts"
    click EnvVal "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/env-validator.ts"
    click Entry "https://github.com/digbenjamins/solanatokensniper/blob/main/src/index.ts"
    click WS "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/managers/websocketManager.ts"
    click RugCheck "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/handlers/rugCheckHandler.ts"
    click SigCheck "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/handlers/signatureHandler.ts"
    click TokenSkip "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/handlers/tokenHandler.ts"
    click Sniperoo "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/handlers/sniperooHandler.ts"
    click Notification "https://github.com/digbenjamins/solanatokensniper/blob/main/src/utils/notification.ts"
    click DB "https://github.com/digbenjamins/solanatokensniper/blob/main/src/tracker/db.ts"
    click Types "https://github.com/digbenjamins/solanatokensniper/blob/main/src/types.ts"
    click Test1 "https://github.com/digbenjamins/solanatokensniper/blob/main/src/test/rugCheckHandler.test.ts"
    click Test2 "https://github.com/digbenjamins/solanatokensniper/blob/main/src/test/sniperooHandler.test.ts"

    classDef util fill:#9f6,stroke:#333,stroke-width:1px
    classDef core fill:#6cf,stroke:#333,stroke-width:1px
    classDef external fill:#ccc,stroke:#333,stroke-width:1px
    classDef persistence fill:#f96,stroke:#333,stroke-width:1px
    classDef test fill:#eee,stroke:#333,stroke-width:1px
```
