diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7aed4e3..eb228df 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ Please follow the existing code style and conventions used in the project. ## Testing -This repository uses playwright tests, which can be found in [/playwright-tests](./playwright-tests/). Ensure that your changes include appropriate tests and that existing tests pass. +This repository uses tests located in the backend's `src/__tests__` directory. Ensure that your changes include appropriate tests and that existing tests pass. ## Submitting Issues diff --git a/README.md b/README.md index f14f498..19dc7c4 100644 --- a/README.md +++ b/README.md @@ -24,15 +24,9 @@ - [Environment Setup](#environment-setup) - [Running the app](#running-the-app) - [Building for production](#building-for-production) - - [Deploying to Fly.io](#deploying-to-flyio) + - [Deploying](#deploying) - [Running tests](#running-tests) -- [Configuration](#configuration) - - [Twitter Setup](#twitter-setup) - - [Admin Configuration](#admin-configuration) -- [Bot Functionality](#bot-functionality) - - [Submission Process](#submission-process) - - [Moderation System](#moderation-system) - - [Rate Limiting](#rate-limiting) +- [Configuration & Usage](#configuration--usage) - [Contributing](#contributing) @@ -46,9 +40,9 @@ This project uses a monorepo structure managed with [Turborepo](https://turbo.bu ```bash curation-bot/ ├── frontend/ # React frontend application -├── backend/ # Bun-powered backend service -├── package.json # Root package.json for shared dependencies -└── turbo.json # Turborepo configuration +├── backend/ # Bun-powered backend service +├── package.json # Root package.json for shared dependencies +└── turbo.json # Turborepo configuration ``` ### Key Components @@ -62,34 +56,24 @@ curation-bot/ - Bun runtime for high performance - Twitter bot functionality - API endpoints for frontend - - Export services for RSS and Telegram + - Distribution services for RSS and Telegram -### Export Services +### Available Feeds -The platform supports multiple channels for content distribution: +The platform currently supports several curated feeds: -#### RSS Feed - -- Automatically generates an RSS feed of approved submissions -- Configurable feed properties (title, description, max items) -- XML-compliant output with proper escaping -- Ideal for content aggregators and RSS readers - -#### Telegram Channel - -- Posts approved submissions to a configured Telegram channel -- Formatted messages with submission details and source links -- Real-time updates as content is approved -- Requires a Telegram bot token and channel ID - - - -# Futre Features -- Regular posting of information on regular intervals -- Creation of content from these feeds, example blogs, articiles -- Integrating to different channels to post - -The export system is extensible - new export types can be added by implementing the ExportService interface in [backend/src/services/exports/types.ts](./backend/src/services/exports/types.ts). +- **Crypto Grant Wire**: Blockchain grant updates +- **This Week in Ethereum**: Ethereum ecosystem updates +- **NEARWEEK**: NEAR Protocol updates +- **AI x Crypto News**: AI and blockchain intersection +- **AI News**: AI updates +- **Crypto News**: General crypto updates +- **Public Goods FM**: Public goods focus +- **REFI DAO**: Regenerative Finance updates +- **DeSci World**: Decentralized Science updates +- **Network State News**: Network states & intentional communities +- **SOL-WEEK**: Solana ecosystem updates +- **Web3 Fundraising**: Fundraising announcements ## Getting Started @@ -119,18 +103,11 @@ TWITTER_USERNAME=your_twitter_username TWITTER_PASSWORD=your_twitter_password TWITTER_EMAIL=your_twitter_email -# Export Services Configuration +# Distribution Services Configuration + # Telegram (Optional) -TELEGRAM_ENABLED=false # Set to true to enable Telegram export TELEGRAM_BOT_TOKEN= # Your Telegram bot token TELEGRAM_CHANNEL_ID= # Target channel ID for posts - -# RSS Feed (Optional) -RSS_ENABLED=false # Set to true to enable RSS feed -RSS_TITLE= # Title of your RSS feed -RSS_DESCRIPTION= # Description of your RSS feed -RSS_FEED_PATH= # Path where RSS feed will be generated -RSS_MAX_ITEMS=100 # Maximum number of items to keep in feed ``` ### Running the app @@ -154,48 +131,9 @@ Build all packages: bun run build ``` -### Deploying to Fly.io - -The backend service can be deployed to Fly.io with SQLite support. First, install the Fly CLI: - -```bash -# macOS -brew install flyctl - -# Windows -powershell -Command "iwr https://fly.io/install.ps1 -useb | iex" - -# Linux -curl -L https://fly.io/install.sh | sh -``` - -Then sign up and authenticate: - -```bash -fly auth signup -# or -fly auth login -``` - -Deploy the application using the provided npm scripts: - -```bash -# Initialize Fly.io app -bun run deploy:init - -# Create persistent volumes for SQLite and cache -bun run deploy:volumes - -# Deploy the application -bun run deploy -``` - -The deployment configuration includes: +### Deploying -- Persistent storage for SQLite database -- Cache directory support -- Auto-scaling configuration -- HTTPS enabled by default +For deployment instructions, see our [Deployment Guide](./docs/docs/developers/deployment.md). ### Running tests @@ -203,75 +141,15 @@ The deployment configuration includes: bun run test ``` -See the full [testing guide](./playwright-tests/README.md). - -## Configuration - -### Twitter Setup - -The bot requires a Twitter account to function. Configure the following in your `.env` file: - -```env -TWITTER_USERNAME=your_twitter_username -TWITTER_PASSWORD=your_twitter_password -TWITTER_EMAIL=your_twitter_email -``` - -It will use these credentials to login and cache cookies via [agent-twitter-client](https://github.com/ai16z/agent-twitter-client). - -### Configuration - -See the [Configuration Documentation](./docs/docs/developers/configuration.md) for detailed information about: - -- Feed configuration and structure -- Stream and recap behavior -- Plugin system -- Message queue handling - -### Admin Configuration - -Admins are Twitter accounts that have moderation privileges (Twitter handles without @). Configure admin accounts in `backend/src/config/admins.ts`: - -```typescript -export const ADMIN_ACCOUNTS: string[] = [ - "admin_handle_1", - "admin_handle_2" - // Add admin Twitter handles here (without @) -] -``` - -Admin accounts are automatically tagged in submission acknowledgements and can: - -- Approve submissions using the `#approve` hashtag -- Reject submissions using the `#reject` hashtag - -Only the first moderation will be recorded. - -## Bot Functionality - -### Submission Process - -1. **Submit News**: Users can submit news by mentioning the bot with `!submit` in their tweet -2. **Acknowledgment**: The bot responds with a confirmation tweet, tagging the admins for review -3. **Moderation**: Admins will reply to the bot's acknowledgement with either #approve or #reject -4. **Notification**: Users receive a tweet notification about their submission's status - -### Moderation System - -1. **Queue**: All submissions enter a moderation queue -2. **Admin Review**: Admins can review submissions by replying to the bot's acknowledgment tweet -3. **Actions**: - - Approve: Reply with `#approve` hashtag - - Reject: Reply with `#reject` hashtag -4. **Outcome**: Users receive a notification tweet about the moderation decision +Tests are located in the backend's `src/__tests__` directory. Run them using `bun run test`. -### Rate Limiting +## Configuration & Usage -To maintain quality: +For detailed information about configuration, submission process, and usage, please refer to our documentation: -- Users are limited to 10 submissions per day -- Rate limits reset daily -- Exceeding the limit results in a notification tweet +- [Configuration Guide](./docs/docs/developers/configuration.md): Feed setup, plugins, and system configuration +- [User Guide](./docs/docs/user-guides/social_integration.md): How to submit and moderate content +- [Developer Guide](./docs/docs/developers/): Technical documentation for developers ## Contributing diff --git a/backend/README.md b/backend/README.md index 0322f9a..84ef976 100644 --- a/backend/README.md +++ b/backend/README.md @@ -13,148 +13,45 @@ -
- Table of Contents - -- [Architecture Overview](#architecture-overview) - - [Tech Stack](#tech-stack) - - [Service Architecture](#service-architecture) -- [Key Components](#key-components) - - [Database Service](#database-service) - - [Twitter Service](#twitter-service) -- [Development](#development) - - [Prerequisites](#prerequisites) - - [Local Setup](#local-setup) -- [API Documentation](#api-documentation) - -
- -## Architecture Overview - -### Tech Stack - -The backend is built with modern technologies chosen for their performance, developer experience, and ecosystem: - -- **Runtime**: [Bun](https://bun.sh) - - 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](./src/services/exports/types.ts). - ## Development ### Prerequisites -- Bun runtime installed -- Node.js 18+ (for some dev tools) -- Twitter API credentials +- [Bun](https://bun.sh) runtime installed +- Node.js 18+ -### Local Setup +### Setup & Running 1. Install dependencies: - ```bash bun install ``` 2. Configure environment: - ```bash cp .env.example .env ``` -Required environment variables: - -```env -# 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 -``` - 3. Start development server: - ```bash bun run dev ``` -## API Documentation +### Testing -The backend exposes several endpoints for frontend interaction: +Run the test suite: -- `POST /submit`: Submit new content -- `GET /submissions`: Retrieve submission list -- `POST /moderate`: Handle moderation actions +```bash +bun test +``` + +Run tests in watch mode during development: + +```bash +bun test --watch +``` -See the [Frontend README](../frontend/README.md) for integration details. +API documentation is available at `/swagger` when running the development server.
diff --git a/bun.lockb b/bun.lockb index 85a61e2..47e3c3b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/docs/docs/developers/configuration.md b/docs/docs/developers/configuration.md index 331aa61..9894acf 100644 --- a/docs/docs/developers/configuration.md +++ b/docs/docs/developers/configuration.md @@ -13,6 +13,7 @@ The application is configured through a `curate.config.json` file that defines g ```json { "global": { + "botId": "curation_bot", // handle for twitter bot "defaultStatus": "pending", "maxSubmissionsPerUser": 5 } @@ -46,7 +47,7 @@ Each feed represents a distinct content stream with its own configuration: { "feeds": [ { - "id": "example", + "id": "example", // hashtag "name": "Example Feed", "description": "Example feed description", "moderation": { @@ -63,7 +64,7 @@ Each feed represents a distinct content stream with its own configuration: "prompt": "Format this update..." } }, - "distribute": [ // Optional + "distribute": [ // Optional (can be processed later, with /api/feed/{feedId}/process) { "plugin": "@curatedotfun/telegram", "config": { @@ -76,18 +77,18 @@ Each feed represents a distinct content stream with its own configuration: "recap": { "enabled": true, "schedule": "0 0 * * *", - "transform": { // Required for recap + "transform": { // Required to summarize "plugin": "@curatedotfun/gpt-transform", "config": { "prompt": "./prompts/recap.txt" } }, - "distribute": [ + "distribute": [ // Required { "plugin": "@curatedotfun/telegram", "config": { - "botToken": "{TELEGRAM_RECAP_BOT_TOKEN}", - "channelId": "{TELEGRAM_RECAP_CHANNEL_ID}" + "botToken": "{TELEGRAM_BOT_TOKEN}", // gets injected by .env + "channelId": "{TELEGRAM_CHANNEL_ID}" } } ] diff --git a/docs/docs/developers/deployment.md b/docs/docs/developers/deployment.md new file mode 100644 index 0000000..3ae86ce --- /dev/null +++ b/docs/docs/developers/deployment.md @@ -0,0 +1,120 @@ +--- +sidebar_position: 5 +--- + +# Deployment + +This guide covers deploying the application to various environments. + +## Deploying to Fly.io + +The backend service can be deployed to Fly.io with SQLite support. + +### Prerequisites + +Install the Fly CLI: + +```bash +# macOS +brew install flyctl + +# Windows +powershell -Command "iwr https://fly.io/install.ps1 -useb | iex" + +# Linux +curl -L https://fly.io/install.sh | sh +``` + +### Authentication + +Sign up and authenticate with Fly.io: + +```bash +fly auth signup +# or +fly auth login +``` + +### Deployment Steps + +1. Initialize your Fly.io application: + +```bash +cd backend/ +bun run deploy:init +``` + +2. Create persistent volumes for SQLite and cache: + +```bash +bun run deploy:volumes +``` + +3. Deploy the application: + +```bash +bun run deploy +``` + +### Configuration + +The deployment includes: + +- Persistent storage for SQLite database +- Cache directory support +- Auto-scaling configuration +- HTTPS enabled by default + +### Environment Variables + +Make sure to configure your environment variables in Fly.io: + +```bash +fly secrets set TWITTER_USERNAME=your_twitter_username +fly secrets set TWITTER_PASSWORD=your_twitter_password +fly secrets set TWITTER_EMAIL=your_twitter_email +``` + +For distribution services, these will hydrate the curate.config.json: + +```bash +# Telegram +fly secrets set TELEGRAM_BOT_TOKEN=your_bot_token +fly secrets set TELEGRAM_CHANNEL_ID=your_channel_id +``` + +### Monitoring + +Monitor your deployment: + +```bash +# View deployment status +fly status + +# View logs +fly logs + +# Access the Fly.io dashboard +fly dashboard +``` + +### Troubleshooting + +Common issues and solutions: + +1. **Database Connection Issues** + - Verify volume mount paths + - Check SQLite file permissions + - Ensure volumes are properly created + +2. **Memory/CPU Issues** + - Monitor resource usage with `fly status` + - Adjust VM size if needed + - Consider enabling auto-scaling + +3. **Network Issues** + - Check Fly.io region configuration + - Verify firewall settings + - Test network connectivity + +For more help, consult the [Fly.io documentation](https://fly.io/docs/) or join their [community Discord](https://fly.io/discord). diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index b26e2b3..adc5f1d 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -19,7 +19,7 @@ function HomepageHeader() {

{siteConfig.tagline}

- Start CUrating + Start Curating