A modern Rust monorepo that combines Axum for API development with a background job processing system using graphile_worker.
This project is organized as a Rust workspace with multiple crates:
app: The main web application using Axum and Inertia.jsworker: A background job processing service using graphile_worker
- Modern Web Framework: Built with Axum, a high-performance web framework for Rust
- Background Job Processing: Utilizes graphile_worker for reliable PostgreSQL-based job queue
- MVC Architecture: Follows the Model-View-Controller pattern for clean code organization
- Database Integration: Uses SQLx for type-safe PostgreSQL interactions
- API Endpoints: RESTful API design with JSON responses
- Docker Development: Fully containerized development environment with live reload
- AI Integration: Built-in Ollama with Gemma model for AI capabilities
- Email Testing: Integrated MailHog for email testing and development
- Rust: 1.87.0 or newer
- Node.js: 22.0.0 or newer (for frontend assets)
- PostgreSQL: 17 or newer
- Docker: Latest version (optional, for containerized deployment)
Create a .env file in the project root with the following variables:
DATABASE_URL=postgres://postgres:postgres@localhost:5432/rustgenie
- Setup the database:
psql -c "CREATE DATABASE rustgenie"- Run the worker:
cargo run --bin worker- Run the web application:
cargo run --bin rustgenieTest the job queue by sending a POST request to the email endpoint:
curl -X POST http://localhost:8000/api/jobs/email \
-H "Content-Type: application/json" \
-d '{"to":"user@example.com","subject":"Test Email","body":"This is a test email."}'This project is fully containerized for both development and production environments.
The recommended way to develop this application is using Docker with live reload:
# Start the development container and database
docker-compose --profile dev up -d
# Access the development container shell
docker-compose exec dev bashOnce inside the container, you can run the app and worker with live reload:
# In one terminal (inside the container)
cd /app && cargo watch -x 'run --bin rustgenie' -w app/src -i app/src/views
# In another terminal (inside the container)
cd /app && cargo watch -x 'run --bin worker' -w worker/src
# For frontend development (in a third terminal inside the container)
cd /app/app && npm run dev- Live Reload: Changes to Rust code automatically trigger recompilation and restart
- Hot Module Replacement: Frontend changes update in real-time without full page reloads
- Shared Volume: Edit code on your host machine, changes reflect immediately in the container
- Unified Environment: Consistent development environment for all team members
- Database Integration: PostgreSQL with TimescaleDB and vectorizer worker included
- Automatic Migrations: Database schema is automatically created and seeded
- AI Integration: Ollama with Gemma 7B model for AI capabilities
- Email Testing: MailHog for capturing and viewing emails during development
To run the application in production mode:
docker-compose --profile prod up -dThis builds and runs the optimized production containers for both the app and worker services.
This project includes Ollama with the Gemma 7B model for AI capabilities. The model is automatically pulled and made available to both the app and worker services.
The Ollama API is available at http://ollama:11434 within the Docker network. You can use it from your application code with the following environment variables:
let ollama_api_url = env::var("OLLAMA_API_URL").unwrap_or_else(|_| "http://ollama:11434".to_string());
let ollama_model = env::var("OLLAMA_MODEL").unwrap_or_else(|_| "gemma:7b".to_string());You can test the AI model directly using curl:
curl -X POST http://localhost:11434/api/generate -d '{"model": "gemma:7b", "prompt": "Hello, how are you?"}'MailHog is included for email testing and development. It captures all outgoing emails and provides a web interface to view them.
The MailHog web interface is available at http://localhost:8025 when the Docker environment is running.
Configure your application to send emails to the MailHog SMTP server:
let smtp_host = env::var("SMTP_HOST").unwrap_or_else(|_| "mailhog".to_string());
let smtp_port = env::var("SMTP_PORT").unwrap_or_else(|_| "1025".to_string()).parse::<u16>().unwrap_or(1025);Detailed documentation for each component can be found in their respective directories:
- Web Application Documentation
- Worker Documentation - Background job processing details
MIT
