A high-performance, type-safe Rust implementation of the Mastodon server backend, aiming for 100% compatibility with the original Mastodon server functionality.
Development Phase: Core API Implementation Complete β
- β Core Infrastructure: Server setup, logging, error handling
- β Authentication System: User registration, login, OAuth support
- β Status Management: Create, read, update status posts
- β Timeline Endpoints: Public and home timeline functionality
- β Social Interactions: Favouriting/unfavouriting statuses
- β API Testing: Comprehensive curl test suite
- π§ Database Integration: Mock responses (PostgreSQL integration in progress)
- π§ ActivityPub Federation: Protocol implementation in progress
- π§ Media Processing: Image and video handling
- π§ Real-time Streaming: WebSocket implementation
- π§ Web Interface: Frontend development
Ready for: API testing, development contributions, feedback
- 100% Mastodon API Compatibility: Full REST API compatibility with original Mastodon
- ActivityPub Federation: Complete ActivityPub protocol implementation
- High Performance: Built with Rust for maximum performance and memory safety
- Type Safety: Strong typing throughout the codebase
- Async/Await: Full async support for concurrent operations
- Modular Architecture: Clean separation of concerns with modular crates
- Database Support: PostgreSQL with SQLx for type-safe database operations
- Real-time Updates: WebSocket streaming for live updates
- Media Processing: Image and video processing capabilities
- Search: Full-text search functionality
- Security: Built-in security features and best practices
- Rust: 1.70 or higher
- PostgreSQL: 13 or higher
- Redis: 6.2 or higher (for caching and job queues)
- Node.js: 20 or higher (for web interface)
Rustodon is organized as a Rust workspace with multiple modular crates:
rustodon/
βββ rustodon-core/ # Core types and traits
βββ rustodon-db/ # Database operations
βββ rustodon-api/ # HTTP API layer
βββ rustodon-auth/ # Authentication & authorization
βββ rustodon-activitypub/ # ActivityPub protocol
βββ rustodon-workers/ # Background job processing
βββ rustodon-search/ # Search functionality
βββ rustodon-mailer/ # Email functionality
βββ rustodon-admin/ # Admin interface
βββ rustodon-config/ # Configuration management
βββ rustodon-logging/ # Logging infrastructure
βββ rustodon-metrics/ # Metrics and monitoring
βββ rustodon-cache/ # Caching layer
βββ rustodon-queue/ # Message queue
βββ rustodon-storage/ # File storage
βββ rustodon-notifications/ # Notification system
βββ rustodon-media/ # Media processing
βββ rustodon-federation/ # Federation logic
βββ rustodon-webhooks/ # Webhook handling
βββ rustodon-scheduler/ # Scheduled tasks
βββ rustodon-migrations/ # Database migrations
βββ rustodon-cli/ # Command line interface
βββ rustodon-server/ # Main server binary
βββ tests/ # Integration tests
git clone https://github.com/arkCyber/Rustodon.git
cd Rustodon
# Copy environment template
cp .env.example .env
# Edit environment variables
nano .env
# Install PostgreSQL and Redis
# (Instructions vary by platform)
# Run database migrations
cargo run -p rustodon-migrations
# Build all crates
cargo build --release
# Run the server
cargo run -p rustodon-server
- Web Interface: http://localhost:3000
- API Documentation: http://localhost:3000/api/v1/docs
Rustodon uses environment variables for configuration. Key settings include:
# Database
DATABASE_URL=postgresql://user:password@localhost/rustodon
# Redis
REDIS_URL=redis://localhost:6379
# Server
RUSTODON_HOST=0.0.0.0
RUSTODON_PORT=3000
# Federation
RUSTODON_DOMAIN=yourdomain.com
RUSTODON_SECRET_KEY_BASE=your-secret-key
# Email
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=your-password
# Run all tests
cargo test
# Run tests with logging
RUST_LOG=debug cargo test
# Run specific crate tests
cargo test -p rustodon-api
# Run integration tests
cargo test --test integration
We provide a comprehensive curl test script to validate API functionality:
# Make the test script executable
chmod +x test_api.sh
# Run API tests (server must be running)
./test_api.sh
The test script validates:
- Health check endpoint
- User registration and login
- OAuth application registration
- Status creation and retrieval
- Timeline endpoints (public and home)
- Status interactions (favouriting/unfavouriting)
# Set offline mode to bypass database connection during compilation
export SQLX_OFFLINE=true
# Start the server
cargo run -p rustodon-server
# Server will be available at http://localhost:3000
# Build Docker image
docker build -t rustodon .
# Run with docker-compose
docker-compose up -d
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests:
cargo test
- Format code:
cargo fmt
- Check linting:
cargo clippy
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.
- Mastodon - The original Mastodon project
- ActivityPub - The ActivityPub protocol specification
- Rust Community - For the amazing Rust ecosystem
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
- Complete ActivityPub implementation
- Web interface development
- Real-time streaming
- Advanced media processing
- Performance optimizations
- Additional federation features
- Mobile app support
- Enterprise features
Made with β€οΈ by the Rustodon Team
- Follow Rust best practices and idioms
- Use async/await for I/O operations
- Implement proper error handling with
Result<T, E>
- Use structured logging with tracing
- Write comprehensive tests for all functionality
- Document all public APIs
Each crate follows a consistent structure:
//! Module description and purpose
//!
//! This module provides [specific functionality] for the Rustodon server.
//!
//! # Author
//!
//! arkSong ([email protected])
use tracing::{info, warn, error, debug, trace};
use serde::{Deserialize, Serialize};
use thiserror::Error;
/// Custom error type for this module
#[derive(Error, Debug)]
pub enum ModuleError {
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
#[error("Validation error: {0}")]
Validation(String),
#[error("Internal error: {0}")]
Internal(String),
}
/// Main struct for this module
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ModuleStruct {
/// Field description
pub field: String,
}
impl ModuleStruct {
/// Creates a new instance
///
/// # Examples
///
/// ```rust
/// use rustodon_module::ModuleStruct;
///
/// let instance = ModuleStruct::new("example");
/// assert_eq!(instance.field, "example");
/// ```
pub fn new(field: impl Into<String>) -> Self {
let field = field.into();
trace!("Creating new ModuleStruct with field: {}", field);
Self { field }
}
}
#[cfg(test)]
mod tests {
use super::*;
use tokio::test;
#[test]
fn test_module_struct_new() {
let instance = ModuleStruct::new("test");
assert_eq!(instance.field, "test");
}
}
- Unit Tests: Test individual functions and methods
- Integration Tests: Test module interactions
- End-to-End Tests: Test complete user flows
- Performance Tests: Benchmark critical operations
- Documentation Tests: Ensure examples compile and run
The project uses structured logging with the tracing
crate:
use tracing::{info, warn, error, debug, trace};
// Log at different levels
trace!("Detailed debugging information");
debug!("General debugging information");
info!("General information about program execution");
warn!("Warning messages");
error!("Error conditions");
All fallible operations return Result<T, E>
with custom error types:
use thiserror::Error;
#[derive(Error, Debug)]
pub enum MyError {
#[error("Database error: {0}")]
Database(#[from] sqlx::Error),
#[error("Validation error: {0}")]
Validation(String),
#[error("Internal error: {0}")]
Internal(String),
}
The server provides RESTful API endpoints:
GET /api/v1/health
- Health check endpointPOST /api/v1/auth/register
- User registrationPOST /api/v1/auth/login
- User login
Configuration is handled through environment variables:
DATABASE_URL
- PostgreSQL connection stringRUST_LOG
- Logging level (debug, info, warn, error)SERVER_HOST
- Server host addressSERVER_PORT
- Server port number
- Fork the repository
- Create a feature branch
- Make your changes following the code standards
- Add tests for new functionality
- Run all tests to ensure they pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
arkSong ([email protected])
- Original Mastodon project for the API specification
- Rust community for excellent tooling and libraries
- SQLx for type-safe database operations
- Axum for the web framework
- Tracing for structured logging