# dracor22/handi-cat_wallet-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/dracor22/handi-cat_wallet-tracker
- Repository: https://github.com/dracor22/handi-cat_wallet-tracker

## Overview

##### Main Components

a) Client Layer:
- Telegram Bot Interface
- Bot Commands Module
- Message Handlers Module

b) Application Core:
- Transaction Processing Engine
- Wallet Tracking System
- Rate Limiting Service

c) External Services:
- Solana RPC Node
- Telegram API
- Token Price APIs

d) Data Layer:
- Supabase Database
- Prisma ORM
- Prisma Pulse (Real-time Updates)

**[Telegram Users] → [Telegram Bot Interface]**
- ↓
**[Bot Layer (Commands & Handlers)] → [Application Core]**
- ↓
- ┌─────────────┬──────┴───────┐
- ↓             ↓              ↓
- [External APIs] [Database Layer] [Blockchain]

##### Component Details

a) Bot Layer (src/bot/):
- Message processing flow
- Rate limiting mechanism

b) Core Services (src/lib/):
- Wallet tracking system
- Transaction parsing pipeline
- Token price aggregation

c) Data Flow:
- Real-time updates via Prisma Pulse
- Transaction monitoring flow
- User subscription handling

##### Specific Implementation Details

Key architectural elements:
- Prisma repositories pattern (src/repositories/)
- Transaction parsing pipeline (src/parsers/)
- Provider services (src/providers/)
- Type system (src/types/)

##### Important Relationships to Highlight

- Real-time transaction monitoring flow
- Database update notifications
- User subscription management
- Token price aggregation pipeline

##### Additional Elements

- Configuration management
- Cron jobs for maintenance tasks
- Backup processes
- Promotion handling system

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef database fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black
    classDef monitoring fill:#607D8B,stroke:#455A64,color:white

    %% Legend
    subgraph Legend
        F[Frontend Component]:::frontend
        B[Backend Component]:::backend
        D[(Database Component)]:::database
        E[External Service]:::external
        M[Monitoring Component]:::monitoring
    end

    %% Main Components
    subgraph TelegramInterface["Telegram Bot Interface"]
        BotCommands["Commands Handler"]:::frontend
        BotHandlers["Event Handlers"]:::frontend
        BotMessages["Message Processor"]:::frontend
    end

    subgraph MonitoringSystem["Transaction Monitoring System"]
        WatchTx["Transaction Watcher"]:::monitoring
        TrackWallets["Wallet Tracker"]:::monitoring
        TxParser["Transaction Parser"]:::monitoring
        HeliusParser["Helius Parser"]:::monitoring
        TokenParser["Token Parser"]:::monitoring
    end

    subgraph DatabaseLayer["Database Layer"]
        PrismaDB[(Prisma Database)]:::database
        GroupRepo["Group Repository"]:::database
        SubRepo["Subscription Repository"]:::database
        UserRepo["User Repository"]:::database
        WalletRepo["Wallet Repository"]:::database
    end

    subgraph ExternalServices["External Services"]
        SolanaRPC["Solana RPC"]:::external
        PriceAPI["Price API"]:::external
        PaymentSystem["Payment System"]:::external
        TelegramAPI["Telegram API"]:::external
    end

    subgraph BusinessLogic["Business Logic Layer"]
        UserBalances["Balance Manager"]:::backend
        UserPlan["Plan Manager"]:::backend
        ValidTx["Transaction Validator"]:::backend
        WalletDetails["Wallet Manager"]:::backend
    end

    %% Connections
    TelegramAPI --> BotCommands
    BotCommands --> BusinessLogic
    BotHandlers --> BusinessLogic
    BusinessLogic --> MonitoringSystem
    MonitoringSystem --> ExternalServices
    BusinessLogic --> DatabaseLayer
    DatabaseLayer --> BusinessLogic
    MonitoringSystem --> BusinessLogic

    %% Click Events
    click BotCommands "https://github.com/DracoR22/handi-cat_wallet-tracker/tree/main/src/bot/commands/"
    click BotHandlers "https://github.com/DracoR22/handi-cat_wallet-tracker/tree/main/src/bot/handlers/"
    click BotMessages "https://github.com/DracoR22/handi-cat_wallet-tracker/tree/main/src/bot/messages/"
    
    click WatchTx "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/watch-transactions.ts"
    click TrackWallets "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/track-wallets.ts"
    click TxParser "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/parsers/transaction-parser.ts"
    click HeliusParser "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/parsers/helius-transaction-parser.ts"
    click TokenParser "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/parsers/token-parser.ts"
    
    click GroupRepo "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/repositories/prisma/group.ts"
    click SubRepo "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/repositories/prisma/subscription.ts"
    click UserRepo "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/repositories/prisma/user.ts"
    click WalletRepo "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/repositories/prisma/wallet.ts"
    click PrismaDB "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/prisma/schema.prisma"
    
    click PriceAPI "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/token-prices-api.ts"
    click PaymentSystem "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/payments.ts"
    click SolanaRPC "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/providers/solana.ts"
    click TelegramAPI "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/providers/telegram.ts"
    
    click UserBalances "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/user-balances.ts"
    click UserPlan "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/user-plan.ts"
    click ValidTx "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/valid-transactions.ts"
    click WalletDetails "https://github.com/DracoR22/handi-cat_wallet-tracker/blob/main/src/lib/wallet-details.ts"
```
