A complete Twitter data crawling system with MongoDB storage, Python FastAPI backend, and Next.js frontend - all running in Docker containers.
- MongoDB: External database for storing Twitter accounts and tweets
- Backend: Python FastAPI server for Twitter API integration
- Frontend: Next.js UI for managing Twitter accounts
- Docker
- Docker Compose
- Local MongoDB running on
mongodb://localhost:27017 - Twitter API Bearer Token (get it from Twitter Developer Portal)
Create a .env file in the root directory:
cp .env.example .envEdit .env and add your Twitter Bearer Token:
TWITTER_BEARER_TOKEN=your_actual_bearer_token_hereHow to get Twitter API Bearer Token:
- Go to Twitter Developer Portal
- Create a new App (or use existing)
- Navigate to "Keys and tokens"
- Generate/Copy your "Bearer Token"
docker-compose up -dThis will start:
- Backend API on
localhost:8000 - Frontend UI on
localhost:3000
- Frontend UI: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
docker-compose downdocker-compose down -v# All services
docker-compose logs -f
# Specific service
docker-compose logs -f backend
docker-compose logs -f frontend
docker-compose logs -f mongodbdocker-compose up -d --buildmongosh eNewsGET /api/accounts- List all Twitter accountsPOST /api/accounts- Add new Twitter accountGET /api/accounts/{id}- Get specific accountDELETE /api/accounts/{id}- Delete accountGET /api/accounts/{id}/tweets- Fetch tweets from accountPOST /api/crawl/all- Crawl all active accounts
x_account- Twitter account informationsource-twitter- Stored tweets from crawling
See .env.example for configuration options.
docker-compose logs backenddocker-compose logs frontenddocker-compose logs mongodb