A Rust-based Twitter clone API using Actix-web and ScyllaDB, designed to demonstrate high-performance social media backend capabilities.
- User Management (create users)
- Tweet Operations (create, fetch)
- Timeline Management (user timeline, home feed)
- Three-node ScyllaDB cluster for high availability
- Data seeding capabilities
- Load testing suite
- Grafana + Prometheus Monitoring
- Rust (latest stable version)
- Docker and Docker Compose
- k6 (for load testing)
The project uses a three-node ScyllaDB cluster. Start it using Docker Compose:
docker-compose up -d --build
Wait for all nodes to be ready (usually takes 1-2 minutes). Verify the cluster status:
docker exec -it scylla-node1 nodetool status
Connect to ScyllaDB and create the schema:
docker exec -it scylla-node1 cqlsh
Then paste the CQL commands in db_init.sh
Build and run the application:
cargo build --bin twitter_clone
cargo run --bin twitter_clone
The API will be available at http://localhost:8080
To populate the database with test data:
cargo run --bin seed
This will create:
- 100 random users
- 20 tweets per user
- Appropriate timeline entries
Install k6:
brew install k6
After running
docker-compose up --build
Navigate to http://localhost:3000
POST /api/users
- Create a new usercurl -X POST http://localhost:8080/api/users \ -H "Content-Type: application/json" \ -d '{"username": "testuser", "email": "[email protected]", "password": "password123"}'
-
POST /api/tweets
- Create a new tweetcurl -X POST "http://localhost:8080/api/tweets?user_id=USER_ID" \ -H "Content-Type: application/json" \ -d '{"content": "Hello, World!"}'
-
GET /api/users/{user_id}/tweets
- Get user's tweetscurl "http://localhost:8080/api/users/USER_ID/tweets"
GET /api/feed
- Get user's home feedcurl "http://localhost:8080/api/feed?user_id=USER_ID"
Check ScyllaDB logs:
docker-compose logs -f scylla-node1
Connect to specific node:
docker exec -it scylla-node1 cqlsh
View cluster status:
docker exec -it scylla-node1 nodetool status
docker-compose up --build
cargo run --bin seed
cargo run --bin twitter_clone
brew install k6
k6 run --out json=test_results.json load_test.js