> For the complete documentation index, see [llms.txt](https://yappr.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yappr.gitbook.io/docs/core-concepts/editor.md).

# How It Works

The tech stack without the tech speak

## How Yappe Actually works?

### The 30-Second Version

We built Yappr on Solana because it's fast, cheap, and doesn't make users wait around. Our backend verifies you're a real human with real followers. Smart contracts handle the money stuff. When tokens hit their goal, they automatically graduate to a real DEX. That's it - no magic, just good engineering.

### System Overview

Yappr is built as a decentralized application (dApp) on Solana, leveraging the blockchain's high speed and low costs for optimal user experience.

```
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│   Frontend      │────▶│   Backend API   │────▶│  Solana RPC     │
│   (React)       │     │   (Node.js)     │     │                 │
└─────────────────┘     └─────────────────┘     └─────────────────┘
         │                       │                        │
         │                       │                        ▼
         │                       │              ┌─────────────────┐
         │                       │              │ Smart Contracts │
         │                       │              │   (Anchor)      │
         │                       │              └─────────────────┘
         │                       │                        │
         ▼                       ▼                        ▼
┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│     Wallet      │     │  Twitter OAuth  │     │   Pyth Oracle   │
│   (Phantom)     │     │  Verification   │     │  (Price Feeds)  │
└─────────────────┘     └─────────────────┘     └─────────────────┘
```

### Core Components

#### 1. Smart Contracts (Programs)

**Yappr Main Program**

* **Program ID**: TBD
* Handles token creation, bonding curve logic, and sales
* Manages KOL allocations and phase transitions
* Integrates with Pyth for live price feeds

**Yappr Migration Program**

* **Program ID**: TBD
* Manages AMM migration when threshold is reached
* Handles Meteora DLMM pool creation
* Burns LP tokens for permanent liquidity

#### 2. Frontend Application

* **Framework**: React with TypeScript
* **Styling**: Tailwind CSS
* **Wallet Integration**: Solana Wallet Adapter
* **State Management**: React Context API
* **Key Features**:
  * Real-time price charts
  * Twitter OAuth integration
  * Responsive design
  * Live transaction updates

#### 3. Backend Services

* **KOL Verification Service**
  * Twitter OAuth handling
  * Follower count verification
  * ED25519 signature generation
  * Bot detection algorithms
* **IPFS Integration**
  * Token metadata storage via Pinata
  * Immutable content addressing
  * Decentralized file storage

#### 4. On-Chain Accounts

**Factory Config (PDA)**

```rust
pub struct FactoryConfig {
    pub authority: Pubkey,
    pub platform_wallet: Pubkey,
    pub backend_authority: Pubkey,
    pub kol_phase_duration: u64,
    pub migration_threshold: u64,
    pub total_tokens_created: u64,
}
```

**Sale Config (PDA)**

```rust
pub struct SaleConfig {
    pub token_mint: Pubkey,
    pub dev_wallet: Pubkey,
    pub phase: Phase,
    pub total_sold: u64,
    pub migrated: bool,
    // ... other fields
}
```

**KOL Data (PDA)**

```rust
pub struct KolData {
    pub wallet: Pubkey,
    pub allocation: u64,
    pub claimed: u64,
    pub verified_at: i64,
}
```

### Data Flow

#### Token Creation Flow

1. **User Input** → Frontend form submission
2. **Metadata Upload** → IPFS via Pinata
3. **Transaction Creation** → Anchor instruction
4. **On-Chain Execution**:
   * Create token mint
   * Initialize sale config
   * Set phase to DevBuy
   * Mint initial supply

#### KOL Purchase Flow

1. **Twitter Verification**:

   ```
   User → Twitter OAuth → Backend API → Signature
   ```
2. **Allocation Assignment**:

   ```
   Follower Count → Allocation Formula → On-Chain Storage
   ```
3. **Token Purchase**:

   ```
   SOL Payment → Bonding Curve → Token Amount → User Wallet
   ```

#### Migration Flow

1. **Threshold Check** (99 SOL raised)
2. **Pause Trading** on bonding curve
3. **Create Meteora Pool** with liquidity
4. **Burn LP Tokens** for security
5. **Enable Trading** on AMM

### Security Architecture

#### Multi-Layer Security

1. **Smart Contract Level**
   * Anchor framework safety checks
   * Overflow protection
   * Access control modifiers
2. **Backend Verification**
   * ED25519 signature validation
   * Twitter OAuth authenticity
   * Rate limiting
3. **Frontend Protection**
   * Wallet connection validation
   * Transaction simulation
   * Error handling

#### Key Security Features

* **No Admin Keys**: Contracts are immutable post-deployment
* **Transparent Pricing**: All calculations on-chain
* **Anti-Rug Mechanisms**:
  * Forced migration at threshold
  * LP token burning
  * No hidden mints

### Performance Optimizations

#### On-Chain Optimizations

* PDA account caching
* Batch operations where possible
* Efficient data structures

#### Frontend Optimizations

* React memo for expensive components
* Debounced RPC calls
* Optimistic UI updates

#### Backend Optimizations

* Redis caching for Twitter data
* Connection pooling
* CDN for static assets

### Integration Points

#### External Services

1. **Pyth Network**
   * Real-time SOL/USD price feeds
   * Devnet: `J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix`
   * Mainnet: `7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE`
2. **Meteora Protocol**
   * DLMM pool creation
   * Liquidity management
   * Fee collection
3. **Twitter API**
   * OAuth 2.0 authentication
   * User profile verification
   * Follower count validation

### Deployment Architecture

### Monitoring & Analytics

* **On-Chain Monitoring**: Helius/QuickNode webhooks
* **Error Tracking**: Sentry integration
* **Analytics**: Google Analytics / Mixpanel
* **Performance**: Datadog APM

### Future Architecture Considerations

1. **Scaling Solutions**
   * Implement caching layers
   * Use Solana's Geyser plugins
   * Consider state compression
2. **Cross-Chain Integration**
   * Bridge to other chains
   * Multi-chain token launches
   * Unified liquidity pools
3. **Advanced Features**
   * Governance mechanisms
   * Staking rewards
   * Revenue sharing

***

For technical implementation details, see our Smart Contracts documentation.
