An open API service indexing awesome lists of open source software.

https://github.com/talkstream/typescript-wireframe-platform

Free enterprise grade production-ready wireframe for creating any bots on clouds with Typescript 100% strict. Any AI connectors out of the box. Clean code. Claude Code friendly. Open for partnership.
https://github.com/talkstream/typescript-wireframe-platform

ai api aws claude claude-code-sdk cloud cloudflare cloudflare-workers connectors discord-bot framework github-actions google-cloud platform telegram typescript whatsapp-bot wireframes

Last synced: 3 months ago
JSON representation

Free enterprise grade production-ready wireframe for creating any bots on clouds with Typescript 100% strict. Any AI connectors out of the box. Clean code. Claude Code friendly. Open for partnership.

Awesome Lists containing this project

README

          

# ๐Ÿš€ Universal Bot Platform Wireframe


English | ะ ัƒััะบะธะน


TypeScript
Cloudflare Workers
Telegram
Type Safety: 100%
License: MIT


Production-ready wireframe for creating any bots (Telegram, Discord, Slack) on any cloud platform (Cloudflare Workers, AWS Lambda, Google Cloud) with TypeScript 100% strict mode


Features โ€ข
Quick Start โ€ข
Architecture โ€ข
Deployment โ€ข
Documentation โ€ข
Roadmap

---

## ๐Ÿ†• What's New in v1.3

### ๐Ÿค– Automated Contribution System

- **Interactive CLI tool** - `npm run contribute` for streamlined contributions
- **Auto-detection** - Identifies valuable patterns from your changes
- **Git worktree support** - Perfect for parallel development
- **Test generation** - Automatically creates appropriate tests

### ๐ŸŒ Namespace-based i18n Architecture

- **Organized translations** - Migrated from flat keys to namespaces
- **Platform formatters** - Telegram, Discord, Slack specific formatting
- **Multiple providers** - Static JSON and dynamic KV storage
- **Performance optimized** - Works within Cloudflare free tier limits

### ๐ŸŽฏ Universal Platform Architecture

- **Multi-cloud support** - Deploy on Cloudflare, AWS, GCP, or any cloud
- **Multi-messenger support** - Telegram, Discord, Slack, WhatsApp ready
- **ResourceConstraints** - Platform-agnostic resource management
- **Platform abstraction** - Zero code changes when switching providers
- **Event-driven architecture** with EventBus for decoupled communication
- **Service connectors** for AI, Session, and Payment services
- **Plugin system** for extensible functionality

### Breaking Changes

- No backward compatibility with v1.x
- TelegramAdapter replaced with TelegramConnector
- All services now communicate through EventBus
- Direct Cloudflare dependencies replaced with platform interfaces

## โšก Quick Start with Claude Code


Claude Code Ready
AI Friendly

Start your bot with one command:

```bash
Clone and setup github.com/talkstream/typescript-wireframe-platform
```

Claude Code will guide you through:

- โœ… Installing dependencies
- โœ… Setting up MCP servers if needed
- โœ… Creating your Telegram bot
- โœ… Configuring Cloudflare resources
- โœ… Running tests and starting locally

[Full AI Setup Instructions](./CLAUDE_SETUP.md) | [Manual Setup](#-quick-start-manual-setup)

---

## ๐Ÿ’ซ Support the Project

This wireframe is crafted with passion and care, drawing from decades of experience in IT communities and modern technical ecosystems. It's built by someone who believes that great tools should be both powerful and delightful to use.

Every architectural decision here reflects a deep understanding of what developers need โ€” not just technically, but experientially. This is code that respects your time and intelligence.

If this wireframe resonates with your vision of what development tools should be, consider supporting its continued evolution:

**Cryptocurrency:**

- **TON**: `UQCASJtr_1FfSjcLW_mnx8WuKxT18fXEv5zHrfHhkrwQj2lT`
- **USDT (BEP20)**: `0x16DD8C11BFF0D85D934789C25f77a1def24772F1`
- **USDT (TRC20)**: `TR333FszR3b7crQR4mNufw56vRWxbTTTxS`

_Your support is invested thoughtfully into making this project even better. Thank you for being part of this journey._

---

## ๐ŸŒŸ Features

### Core Technologies

- **โ˜๏ธ Multi-Cloud** - Deploy on Cloudflare, AWS, GCP, Azure, or any cloud
- **๐Ÿ“˜ TypeScript** - Full type safety with strict mode
- **๐Ÿค– grammY** - Modern Telegram Bot framework (extensible to Discord, Slack, etc.)
- **๐Ÿ—„๏ธ SQL Database** - Platform-agnostic database interface (D1, RDS, Cloud SQL)
- **๐Ÿ’พ KV Storage** - Universal key-value storage abstraction
- **๐Ÿง  Multi-Provider AI** - Support for Google Gemini, OpenAI, xAI Grok, DeepSeek, Cloudflare AI
- **๐Ÿ” Sentry** - Error tracking and performance monitoring
- **๐Ÿ”Œ Plugin System** - Extend with custom functionality

### Developer Experience

- **๐Ÿ“ฆ Zero-config setup** - Start developing immediately
- **๐Ÿงช Testing suite** - Unit and integration tests with Vitest
- **๐Ÿ”ง Hot reload** - Instant feedback during development
- **๐Ÿ“ 100% Type safety** - No `any` types, full TypeScript strict mode
- **๐ŸŽฏ ESLint + Prettier** - Consistent code style with ESLint v9
- **๐Ÿš€ CI/CD Pipeline** - GitHub Actions ready
- **โ˜๏ธ Istanbul Coverage** - Compatible with Cloudflare Workers runtime

### Security & Performance

- **๐Ÿ”’ Webhook validation** - Secure token-based authentication
- **โšก Rate limiting** - Distributed rate limiting with KV
- **๐Ÿ›ก๏ธ Security headers** - Best practices implemented
- **๐Ÿ“Š Health checks** - Monitor all dependencies
- **๐Ÿ”„ Session management** - Persistent user sessions
- **๐Ÿ’ฐ Telegram Stars** - Payment integration ready
- **๐ŸŽจ Provider Abstraction** - Switch AI providers without code changes
- **๐Ÿ’ธ Cost Tracking** - Monitor AI usage and costs across providers

### Cloudflare Workers Tier Optimization

- **๐Ÿ†“ Cloudflare Workers Free Plan** - Optimized for 10ms CPU limit
- **๐Ÿ’Ž Cloudflare Workers Paid Plan** - Full features with extended timeouts
- **๐Ÿš€ Auto-scaling** - Tier-aware resource management
- **โšก Request Batching** - Reduce API overhead
- **๐Ÿ”„ Smart Caching** - Multi-layer cache system
- **โฑ๏ธ Timeout Protection** - Configurable API timeouts

## ๐ŸŽฏ Cloudflare Workers Performance Tiers

> **๐Ÿ“Œ Important**: This wireframe is **100% free and open-source**. The tiers below refer to **Cloudflare Workers plans**, not our wireframe. You can use this wireframe for free forever, regardless of which Cloudflare plan you choose.

### Cloudflare Workers Free Plan (10ms CPU limit)

- **Lightweight mode** - Minimal features for fast responses
- **Aggressive caching** - Reduce KV operations (1K writes/day limit)
- **Request batching** - Optimize Telegram API calls
- **Limited AI features** - Disabled by default to save processing time
- **Sequential operations** - Avoid parallel processing overhead

### Cloudflare Workers Paid Plan (30s CPU limit)

- **Full feature set** - All capabilities enabled
- **AI integration** - Multiple LLM providers with smart retries
- **Parallel processing** - Concurrent health checks & operations
- **Advanced caching** - Edge cache + KV + memory layers
- **Extended timeouts** - Configurable per operation type

### Tier Configuration

```bash
# Set your Cloudflare Workers plan in .dev.vars or wrangler.toml
TIER="free" # for Cloudflare Workers Free Plan
TIER="paid" # for Cloudflare Workers Paid Plan
```

The wireframe automatically optimizes based on your Cloudflare Workers plan:

- **Free Plan**: Fast responses, limited features (optimized for 10ms CPU limit)
- **Paid Plan**: Full functionality, better reliability (up to 30s CPU time)

## ๐ŸŒฉ๏ธ Choose Your Cloud Platform

Wireframe v1.2 supports multiple cloud platforms out of the box:

```bash
# Set your preferred cloud platform
CLOUD_PLATFORM=cloudflare # Default: Cloudflare Workers
CLOUD_PLATFORM=aws # AWS Lambda + DynamoDB
CLOUD_PLATFORM=gcp # Google Cloud Functions
```

[Learn more about multi-cloud deployment โ†’](docs/CLOUD_PLATFORMS.md)

## ๐Ÿš€ Quick Start (Manual Setup)

> **๐Ÿ“– Need detailed setup instructions?** Check out our comprehensive [Setup Guide](SETUP.md) for step-by-step configuration with screenshots and troubleshooting.

### One-Command Deploy

```bash
# Clone and deploy a working Telegram bot in 5 minutes
git clone https://github.com/talkstream/typescript-wireframe-platform.git
cd typescript-wireframe-platform
npm install
npm run setup:bot # Interactive setup wizard
```

The setup wizard will:

- โœ… Create your Telegram bot via @BotFather
- โœ… Configure all required secrets
- โœ… Create KV namespaces and D1 database
- โœ… Deploy to Cloudflare Workers
- โœ… Set up webhook automatically

### Prerequisites

- Node.js 20+ and npm 10+
- [Cloudflare account](https://dash.cloudflare.com/sign-up)
- [Telegram Bot Token](https://t.me/botfather)
- AI Provider API Key (optional) - [Google Gemini](https://makersuite.google.com/app/apikey), [OpenAI](https://platform.openai.com/api-keys), [xAI](https://console.x.ai), [DeepSeek](https://platform.deepseek.com), or Cloudflare AI
- [Wrangler CLI](https://developers.cloudflare.com/workers/cli-wrangler/install-update)

### 1. Clone and Install

```bash
git clone https://github.com/talkstream/typescript-wireframe-platform.git
cd typescript-wireframe-platform
npm install

# Verify setup
npm run setup:check
```

### 2. Configure Environment

```bash
# Copy example configuration
cp .dev.vars.example .dev.vars
cp wrangler.toml.example wrangler.toml

# Edit .dev.vars with your values
# TELEGRAM_BOT_TOKEN=your_bot_token_here
# TELEGRAM_WEBHOOK_SECRET=your_secret_here
# AI_PROVIDER=google-ai # Options: google-ai, openai, xai, deepseek, cloudflare-ai
# GEMINI_API_KEY=your_gemini_key_here # For Google Gemini
# See .dev.vars.example for more AI provider options
```

### 3. Create D1 Database

```bash
# Create database
wrangler d1 create your-bot-db

# Update wrangler.toml with the database ID
# Run migrations
npm run db:apply:local
```

### 4. Create KV Namespaces

```bash
wrangler kv:namespace create CACHE
wrangler kv:namespace create RATE_LIMIT
wrangler kv:namespace create SESSIONS
```

### 5. Start Development

```bash
npm run dev
```

Your bot is now running locally! Set the webhook URL to test:

```bash
curl -X POST "https://api.telegram.org/bot/setWebhook" \
-H "Content-Type: application/json" \
-d '{"url": "https://localhost:8787/webhook/"}'
```

## ๐Ÿ—๏ธ Architecture

### Connector-Based Architecture (v1.2)

Wireframe v1.2 introduces a revolutionary connector-based architecture that decouples services from platforms:

```
src/
โ”œโ”€โ”€ connectors/ # Platform & Service Connectors
โ”‚ โ”œโ”€โ”€ messaging/ # Messaging platform connectors
โ”‚ โ”‚ โ””โ”€โ”€ telegram/ # Telegram implementation
โ”‚ โ”œโ”€โ”€ ai/ # AI service connector
โ”‚ โ”œโ”€โ”€ session/ # Session management connector
โ”‚ โ””โ”€โ”€ payment/ # Payment service connector
โ”œโ”€โ”€ core/ # Core framework components
โ”‚ โ”œโ”€โ”€ events/ # Event bus for decoupled communication
โ”‚ โ”œโ”€โ”€ plugins/ # Plugin system
โ”‚ โ””โ”€โ”€ interfaces/ # Core interfaces
โ”œโ”€โ”€ services/ # Business logic services
โ”‚ โ”œโ”€โ”€ ai-service.ts # AI processing logic
โ”‚ โ”œโ”€โ”€ session-service.ts # Session management
โ”‚ โ””โ”€โ”€ payment-service.ts # Payment handling
โ”œโ”€โ”€ plugins/ # Extensible plugins
โ”‚ โ”œโ”€โ”€ start-plugin.ts # Start command handler
โ”‚ โ”œโ”€โ”€ ai-plugin.ts # AI commands plugin
โ”‚ โ””โ”€โ”€ settings-plugin.ts # User settings plugin
โ””โ”€โ”€ index.ts # Application entry point

examples/
โ”œโ”€โ”€ telegram-bot/ # Basic Telegram bot example
โ”‚ โ”œโ”€โ”€ bot.ts # Complete working bot
โ”‚ โ”œโ”€โ”€ wrangler.toml # Deployment configuration
โ”‚ โ””โ”€โ”€ README.md # Quick start guide
โ””โ”€โ”€ telegram-plugin/ # Plugin system example
โ”œโ”€โ”€ reminder-plugin.ts # Example reminder plugin
โ””โ”€โ”€ bot-with-plugins.ts # Bot with plugin integration
```

### Key Design Patterns

- **Connector Pattern** - Platform-agnostic service integration
- **Event-Driven Architecture** - All communication through EventBus
- **Plugin System** - Hot-swappable feature modules
- **Service Abstraction** - Business logic separated from connectors
- **Request/Response Events** - Async service communication
- **Batch Processing** - Optimized API calls
- **Repository Pattern** - Clean data access layer
- **TypeScript Strict Mode** - 100% type safety

## ๐Ÿ“ฆ Examples

### Event-Driven Command

```typescript
// Using the new event-driven architecture
import { Plugin, PluginContext } from './core/plugins/plugin';

export class MyPlugin implements Plugin {
id = 'my-plugin';

async install(context: PluginContext) {
// Register command through plugin system
context.commands.set('hello', {
name: 'hello',
description: 'Greet the user',
handler: async (args, ctx) => {
await ctx.reply('๐Ÿ‘‹ Hello from Wireframe v1.2!');

// Emit custom event
context.eventBus.emit('greeting:sent', {
userId: ctx.sender.id,
timestamp: Date.now(),
});
},
});
}
}
```

### Service Integration Example

```typescript
// Integrate with AI service through events
context.eventBus.emit('ai:complete', {
prompt: 'What is the weather today?',
requestId: 'req_123',
options: { maxTokens: 500 },
});

// Listen for response
context.eventBus.once('ai:complete:success', (event) => {
console.log('AI Response:', event.payload.response.content);
});
```

### Connector Communication

```typescript
// Services communicate through standardized events
// Payment example:
context.eventBus.emit('payment:create_invoice', {
playerId: 123,
invoiceType: 'premium_upgrade',
starsAmount: 100,
});

// Session management:
context.eventBus.emit('session:get', {
userId: 'user123',
requestId: 'req_456',
});
```

## ๐Ÿš€ Deployment

### Deploy to Production

```bash
# Deploy to Cloudflare Workers
npm run deploy

# Or deploy to staging first
npm run deploy:staging
```

### Set Production Webhook

```bash
curl -X POST "https://api.telegram.org/bot/setWebhook" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-bot.workers.dev/webhook/",
"secret_token": ""
}'
```

### Environment Configuration

Configure secrets for production:

```bash
wrangler secret put TELEGRAM_BOT_TOKEN
wrangler secret put TELEGRAM_WEBHOOK_SECRET
wrangler secret put SENTRY_DSN

# AI Provider Secrets (add only what you need)
wrangler secret put GEMINI_API_KEY # Google Gemini
wrangler secret put OPENAI_API_KEY # OpenAI
wrangler secret put XAI_API_KEY # xAI Grok
wrangler secret put DEEPSEEK_API_KEY # DeepSeek
wrangler secret put CLOUDFLARE_AI_ACCOUNT_ID
wrangler secret put CLOUDFLARE_AI_API_TOKEN

# Owner configuration
wrangler secret put BOT_OWNER_IDS
```

## ๐Ÿ“š Best Practices

### 1. **Content Management**

All user-facing text should be managed through the content system:

```typescript
const message = contentManager.format('welcome_message', { name: userName });
```

### 2. **Error Handling**

Comprehensive error handling with proper logging:

```typescript
try {
await riskyOperation();
} catch (error) {
logger.error('Operation failed', { error, context });
await ctx.reply('An error occurred. Please try again.');
}
```

### 3. **Rate Limiting**

Apply appropriate rate limits to prevent abuse:

```typescript
app.post('/webhook/:token', rateLimiter({ maxRequests: 20, windowMs: 60000 }), handler);
```

### 4. **Type Safety**

Leverage TypeScript's strict mode for maximum safety:

```typescript
// Always define types for your data structures
interface UserData {
id: number;
telegramId: number;
username?: string; // Use optional properties appropriately
}
```

### 5. **Testing**

Write tests for critical functionality:

```typescript
describe('StartCommand', () => {
it('should create new user on first interaction', async () => {
// Test implementation
});
});
```

**Important Note for Coverage**: This wireframe uses Istanbul coverage provider instead of V8 due to Cloudflare Workers compatibility. The V8 coverage provider relies on `node:inspector` which is not available in the Workers runtime. Istanbul works by instrumenting code at build time, making it compatible with Workers.

## ๐Ÿ’ก Perfect Use Cases

This wireframe is **ideal** for:

### 1. **๐Ÿ›๏ธ E-commerce Bots**

- Product catalogs with D1 database
- Payment processing with Telegram Stars
- Order tracking with KV sessions
- Global edge deployment for fast responses

### 2. **๐ŸŽฎ Gaming & Entertainment Bots**

- Real-time game state in KV storage
- Leaderboards with D1 queries
- In-game purchases via Telegram Stars
- Low-latency gameplay worldwide

### 3. **๐Ÿ“Š Analytics & Monitoring Bots**

- Data aggregation and reporting
- Scheduled tasks for regular updates
- Webhook integrations
- Rich interactive dashboards

### 4. **๐Ÿค Customer Support Bots**

- AI-powered responses with Gemini
- Ticket management system
- Multi-language support
- Integration with existing CRM systems

### 5. **๐Ÿ“š Educational & Content Bots**

- Course management with structured content
- Progress tracking in database
- Premium content via payments
- Interactive quizzes and assessments

## โŒ When to Use Different Tools

This wireframe might **not** be the best choice for:

### 1. **๐Ÿ“น Heavy Media Processing**

- **Why not**: Cloudflare Workers have CPU time limits (10ms free / 30s paid)
- **Alternative**: Use traditional servers with FFmpeg or cloud functions with longer timeouts

### 2. **๐Ÿ”„ Long-Running Tasks**

- **Why not**: Workers timeout after 30 seconds
- **Alternative**: Use AWS Lambda, Google Cloud Functions, or traditional servers

### 3. **๐Ÿ“ฆ Large File Storage**

- **Why not**: Workers have memory limits and no persistent file system
- **Alternative**: Combine with R2/S3 for file storage or use traditional hosting

### 4. **๐Ÿ”Œ WebSocket Connections**

- **Why not**: Workers don't support persistent WebSocket connections for bots
- **Alternative**: Use Node.js with libraries like node-telegram-bot-api

### 5. **๐Ÿ›๏ธ Legacy System Integration**

- **Why not**: May require specific libraries or protocols not available in Workers
- **Alternative**: Traditional servers with full OS access or containerized solutions

## ๐Ÿ› ๏ธ Development

### Available Scripts

```bash
npm run dev # Start local development
npm run test # Run tests
npm run test:coverage # Run tests with coverage
npm run lint # Lint code
npm run typecheck # Type check
npm run format # Format code
npm run deploy # Deploy to production
npm run tail # View production logs
```

### CI/CD with GitHub Actions

The repository includes GitHub Actions workflows:

- **Test Workflow** - Automatically runs on every push and PR
- **Deploy Workflow** - Optional, requires Cloudflare setup (disabled by default)

To enable automatic deployment:

1. Set up GitHub secrets (see [Setup Guide](SETUP.md))
2. Edit `.github/workflows/deploy.yml` to enable push trigger
3. Ensure all Cloudflare resources are created

### Project Structure

- **Commands** - Add new commands in `src/adapters/telegram/commands/`
- **Callbacks** - Handle button clicks in `src/adapters/telegram/callbacks/`
- **Services** - Business logic in `src/services/`
- **AI Providers** - LLM adapters in `src/lib/ai/adapters/`
- **Database** - Migrations in `migrations/`
- **Tests** - Test files in `src/__tests__/`

### AI Provider System

The wireframe includes a sophisticated multi-provider AI system:

- **๐ŸŽจ Provider Abstraction** - Switch between AI providers without code changes
- **๐Ÿ’ฐ Cost Tracking** - Monitor usage and costs across all providers
- **๐Ÿ”„ Automatic Fallback** - Failover to backup providers on errors
- **๐Ÿ”” Smart Selection** - Automatically choose the best available provider
- **๐Ÿงช Mock Provider** - Test your bot without API costs

Supported providers:

- Google Gemini (default)
- OpenAI (GPT-4o, GPT-3.5)
- xAI Grok
- DeepSeek
- Cloudflare Workers AI

### Access Control System

The wireframe includes a comprehensive role-based access control system:

- **๐Ÿ” Three-tier roles** - Owner, Admin, and User levels
- **๐Ÿ“ Access requests** - Users can request access through the bot
- **โœ… Request management** - Admins can approve/reject requests
- **๐Ÿ› Debug mode** - Owners can enable tiered debug visibility
- **๐ŸŒ Internationalization** - Full i18n support for all messages

#### Role Hierarchy

1. **Owner** (configured via `BOT_OWNER_IDS`)
- Full bot control and configuration
- Can manage administrators
- Access to technical information and debug mode
- Example commands: `/info`, `/admin`, `/debug`

2. **Admin** (granted by owners)
- Can review and process access requests
- See debug messages when enabled (level 2+)
- Example command: `/requests`

3. **User** (default role)
- Basic bot functionality
- Must request access if bot is restricted
- Example commands: `/start`, `/help`, `/ask`

#### Configuration

```bash
# Required in .dev.vars or secrets
BOT_OWNER_IDS=123456789,987654321 # Comma-separated Telegram user IDs
```

#### Access Request Flow

1. New user starts bot with `/start`
2. If access is restricted, user sees "Request Access" button
3. Admin receives notification and reviews with `/requests`
4. User gets notified when request is approved/rejected
5. Approved users gain full bot functionality

#### Debug Mode

Owners can control debug visibility:

- **Level 1**: Only owners see debug messages
- **Level 2**: Owners and admins see debug messages
- **Level 3**: Everyone sees debug messages

```bash
/debug on 2 # Enable debug for owners and admins
/debug off # Disable debug mode
/debug status # Check current debug status
```

## ๐Ÿ”’ Security

### Security Best Practices

This wireframe implements multiple layers of security:

1. **Webhook Validation**
- URL token validation
- X-Telegram-Bot-Api-Secret-Token header validation (required)
- Request payload validation with Zod

2. **Rate Limiting**
- Built-in rate limiting for all endpoints
- Distributed rate limiting using KV storage

3. **Security Headers**
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY
- X-XSS-Protection: 1; mode=block
- Strict Referrer Policy
- Restrictive Permissions Policy

4. **Data Validation**
- All input validated with Zod schemas
- SQL injection prevention with parameterized queries
- Type-safe data handling throughout

5. **Logging Security**
- Sensitive headers automatically redacted
- No PII in logs by default
- Structured logging with request IDs

### Responsible Disclosure

Found a security vulnerability? Please report it responsibly:

1. **DO NOT** create a public GitHub issue
2. Email security details to: `security@your-domain.com`
3. Include: description, steps to reproduce, potential impact
4. Allow reasonable time for a fix before public disclosure

We appreciate your help in keeping this project secure!

## ๐ŸŽฏ Framework Features

### Plugin System

Extend your bot with modular plugins:

- **๐Ÿ”Œ Hot-swappable** - Install/uninstall plugins at runtime
- **๐Ÿ“ฆ Self-contained** - Each plugin manages its own state
- **๐Ÿ”” Event-driven** - Plugins communicate via event bus
- **๐Ÿ’พ Persistent storage** - KV-backed storage per plugin
- **โšก Lifecycle hooks** - Control plugin behavior

### Event Bus

Decoupled communication between components:

- **๐Ÿ“ก Global events** - System-wide notifications
- **๐ŸŽฏ Scoped events** - Plugin-specific namespaces
- **โฑ๏ธ Event history** - Track and replay events
- **๐Ÿ” Filtering** - Subscribe to specific event types
- **โšก Async/sync** - Choose your handling strategy

### Multi-Platform Support

The framework is designed for multiple platforms:

- **Telegram** - Full implementation included
- **Discord** - Connector interface ready
- **Slack** - Connector interface ready
- **WhatsApp** - Connector interface ready
- **Custom** - Easy to add new platforms

## ๐Ÿค Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

### Code Standards

- **No `any` types** - Maintain 100% type safety
- **Test coverage** - Write tests for new features
- **Documentation** - Update docs for API changes
- **Security first** - Consider security implications

## ๐Ÿ”ง Recommended MCP Servers

### Accelerate Development with Model Context Protocol

[MCP (Model Context Protocol)](https://modelcontextprotocol.io/) servers enable AI assistants like Claude to interact with your development tools. Here are the recommended MCP servers for this project:

#### Essential MCP Servers

1. **Cloudflare MCP Servers** - [Official Documentation](https://github.com/cloudflare/mcp-server-cloudflare)
- **Remote servers available at:**
- Observability: `https://observability.mcp.cloudflare.com/sse`
- Workers Bindings: `https://bindings.mcp.cloudflare.com/sse`
- Manage Workers, KV, D1, R2 resources
- Deploy and configure services
- Monitor logs and analytics
- Handle secrets and environment variables

2. **Git MCP Server (GitMCP)** - [GitMCP.io](https://gitmcp.io)
- **Remote server for this project:** `https://gitmcp.io/talkstream/typescript-wireframe-platform`
- Access any GitHub repository content instantly
- No installation required - just use the URL format
- Read-only access to public repositories
- Perfect for exploring codebases and documentation

3. **Sentry MCP Server** - [Official Repository](https://github.com/getsentry/sentry-mcp)
- **Remote server available at:** `https://mcp.sentry.dev`
- Official server maintained by Sentry
- Retrieve and analyze error reports
- Performance monitoring with 16 different tool calls
- OAuth support for secure authentication
- Built on Cloudflare's remote MCP infrastructure

#### How These Servers Help This Project

- **Cloudflare Server**: Essential for managing all Cloudflare resources (Workers, KV, D1) used by this bot
- **Git Server**: Access and explore repository content directly without leaving your development environment
- **Sentry Server**: Quickly diagnose production issues reported by your bot users with official Sentry integration

These MCP servers significantly accelerate development by enabling natural language interactions with your tools, reducing context switching, and automating repetitive tasks.

## โšก Performance & Cloudflare Plans

### Understanding Cloudflare Workers Limits

This wireframe works on both Free and Paid Cloudflare plans. Here's how different plans affect your bot's capabilities:

#### Free Plan Limits

- **CPU Time**: 10ms per request
- **Daily Requests**: 100,000
- **KV Operations**: 100,000 reads, 1,000 writes per day
- **D1 Database**: 5M reads, 100k writes per day

**Works well for:**

- Simple command bots
- Quick responses without heavy processing
- Bots with up to ~3,000 active daily users
- Basic database operations

#### Paid Plan ($5/month) Benefits

- **CPU Time**: 30 seconds per request (3000x more!)
- **Daily Requests**: 10 million included
- **Queues**: Available for async processing
- **Workers Logs**: 10M events/month with filtering
- **Trace Events**: Advanced debugging capabilities

**Enables advanced features:**

- Complex AI text generation
- Image/file processing
- Bulk operations and broadcasts
- Heavy computational tasks
- Async job processing with Queues
- Advanced analytics and debugging

### Choosing the Right Plan

Most bots work perfectly on the **Free plan**. Consider the **Paid plan** when:

- Your bot uses AI for lengthy text generation
- You need to process files or images
- You're broadcasting to thousands of users
- Your commands involve complex calculations
- You need detailed logs and debugging tools

The wireframe automatically adapts to available resources and will work reliably on both plans.

## ๐Ÿ“š Documentation

Comprehensive documentation is available in the `docs/` directory:

- **[Project Overview](docs/PROJECT_OVERVIEW.md)** - Architecture, technology stack, and quick start guide
- **[Development Guide](docs/DEVELOPMENT_GUIDE.md)** - Local setup, testing, and debugging
- **[Architecture Decisions](docs/ARCHITECTURE_DECISIONS.md)** - Key design choices and rationale
- **[API Reference](docs/API_REFERENCE.md)** - Telegram API types and webhook handling
- **[Deployment Guide](docs/DEPLOYMENT.md)** - Production deployment and configuration
- **[Troubleshooting](docs/TROUBLESHOOTING.md)** - Common issues and solutions

### Code Patterns

Reusable patterns for common tasks:

- **[Webhook Validation](docs/patterns/webhook-validation.js)** - Secure webhook handling
- **[Error Handling](docs/patterns/error-handling.js)** - Robust error management
- **[Command Router](docs/patterns/command-router.js)** - Flexible command routing
- **[Access Control](docs/patterns/access-control.js)** - Role-based permissions

## ๐Ÿš€ Roadmap

### Phase 1: Core Enhancements (Days or Hours)

- [ ] Plugin system for modular features
- [ ] Database migrations toolkit
- [ ] Advanced caching strategies
- [ ] WebSocket support for real-time features

### Phase 2: Developer Tools (Days or Hours)

- [ ] CLI tool for scaffolding commands
- [ ] Visual bot flow designer
- [ ] Automated performance profiler
- [ ] Integration test framework

### Phase 3: Ecosystem (Days or Hours)

- [ ] Plugin marketplace
- [ ] Starter templates gallery
- [ ] Community middleware
- [ ] Video tutorials series

### Phase 4: Enterprise Features (Days or Hours)

- [ ] Multi-tenant architecture
- [ ] Advanced analytics dashboard
- [ ] A/B testing framework
- [ ] Compliance tools (GDPR, etc.)

## ๐Ÿ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## ๐Ÿ™ Acknowledgments

- [Cloudflare Workers](https://workers.cloudflare.com/) for the amazing edge platform
- [grammY](https://grammy.dev/) for the excellent Telegram bot framework
- [Telegram Bot API](https://core.telegram.org/bots/api) for the powerful bot platform

---


Made with โค๏ธ for the Telegram bot developer community


Contact Author โ€ข
Get Support