Backend

This directory contains the server-side code for the Tweet Metrics Tracker application.

Structure

  • index.ts - Main entry point for the HTTP API
  • cron.ts - Cron job for periodically fetching and updating tweets
  • database/ - Database schema and queries
  • routes/ - API routes and static file serving
  • services/ - External API integrations (Twitter API)

API Endpoints

  • GET /api/tweets - Get tweets with pagination
  • GET /api/tweets/:id - Get a single tweet by ID
  • GET /api/tweets/:id/metrics - Get metrics history for a tweet
  • GET /api/top-tweets - Get top tweets by engagement
  • GET /api/fetch/:username - Fetch tweets for a specific user
  • GET /api/search?q=query - Search tweets by keyword

Environment Variables

  • TWITTER_API_KEY - Twitter API key
  • TWITTER_API_SECRET - Twitter API secret
  • TWITTER_BEARER_TOKEN - Twitter bearer token