Skip to content

Latest commit

 

History

History
167 lines (119 loc) · 3.75 KB

README.md

File metadata and controls

167 lines (119 loc) · 3.75 KB

Curation Bot Backend

TypeScript-based backend service for the Curation Bot platform

Table of Contents

Architecture Overview

Tech Stack

The backend is built with modern technologies chosen for their performance, developer experience, and ecosystem:

  • Runtime: Bun

    • Chosen for its exceptional performance and built-in TypeScript support
    • Provides native testing capabilities and package management
    • Offers excellent developer experience with fast startup times
  • Language: TypeScript

    • Ensures type safety and better developer experience
    • Enables better code organization and maintainability
    • Provides excellent IDE support and code navigation

Service Architecture

The backend follows a modular service-based architecture:

src/
├── config/     # Configuration management
├── services/   # Core service implementations
├── types/      # TypeScript type definitions
└── utils/      # Shared utilities

Key Components

Database Service

Located in src/services/db, handles:

  • Data persistence
  • Caching layer
  • Query optimization

Twitter Service

Twitter integration (src/services/twitter) manages:

  • Authentication
  • Tweet interactions
  • Rate limiting
  • User management

Export Services

Located in src/services/exports, manages content distribution to external platforms:

RSS Export

  • Generates RSS feed of approved submissions
  • Configurable feed title and description
  • Customizable maximum items limit
  • Automatic XML escaping and feed updates

Telegram Export

  • Posts approved submissions to Telegram channel
  • Formatted messages with submission details
  • Automatic error handling and retries
  • Real-time channel updates

This is extendible by registering a new export type in exports/types.

Development

Prerequisites

  • Bun runtime installed
  • Node.js 18+ (for some dev tools)
  • Twitter API credentials

Local Setup

  1. Install dependencies:
bun install
  1. Configure environment:
cp .env.example .env

Required environment variables:

# Twitter API Credentials
TWITTER_USERNAME=your_twitter_username
TWITTER_PASSWORD=your_twitter_password
TWITTER_EMAIL=your_twitter_email

# Export Services Configuration
# Telegram
TELEGRAM_ENABLED=false
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHANNEL_ID=your_channel_id

# RSS
RSS_ENABLED=false
RSS_TITLE=Curation Bot
RSS_DESCRIPTION=Latest approved submissions
RSS_FEED_PATH=public/feed.xml
RSS_MAX_ITEMS=100
  1. Start development server:
bun run dev

API Documentation

The backend exposes several endpoints for frontend interaction:

  • POST /submit: Submit new content
  • GET /submissions: Retrieve submission list
  • POST /moderate: Handle moderation actions

See the Frontend README for integration details.