Backend
Development
Prerequisites
- Rust - Latest stable version
- sqlx-cli - Database migration tool
- watchexec (Optional) - For hot reloading
Setup
-
Install sqlx CLI:
cargo install sqlx-cli
-
Run database migrations:
sqlx migrate run
-
Prepare SQL schema:
cargo sqlx prepare --workspace
-
Run the server:
RUST_LOG=debug cargo run
Development Commands
- Run server:
RUST_LOG=debug cargo run
- Hot reload (optional):
RUST_LOG=debug watchexec -e rs -r 'cargo run'
- Database migration:
sqlx migrate run
- Schema preparation:
cargo sqlx prepare --workspace
- Build:
cargo build
- Test:
cargo test
Project Structure
The backend follows Clean Architecture principles with a modular structure:
server/
- Main server application and configurationfeature/
- Feature modules organized by domainauth/
- Authentication and authorizationpost/
- Blog post managementlabel/
- Label/tag systemimage/
- Image handlingcommon/
- Shared utilities and types
migrations/
- Database migration scripts
Each feature module follows the Clean Architecture pattern:
domain/
- Business logic and entitiesapplication/
- Use cases and application servicesadapter/
- Interface adapters (controllers, presenters)framework/
- External frameworks (database, HTTP)
Technology Stack
- Framework: Actix-web
- Database: PostgreSQL with SQLx
- Authentication: JWT-based
- Serialization: Serde
- Migration: SQLx migrations
- Logging: env_logger with RUST_LOG