- Published on
hoopics-admin-restful-api
Title: hoopics-admin-restful-api
Author: zTgx
Subject: Admin backend for image sharing platform
Language: Rust (100%)
Source: GitHub Repository
Introduction
This Rust-based admin system evolved from my previous ReactJS+EggJS image sharing platform (hoopics.com), representing my technical exploration of Rust in web development. The system handles core moderation workflows while demonstrating production-ready Rust patterns.
Key Features
- Multi-Database Architecture: Separate connections for admin, statistics, and main data
- Moderation Toolkit: Image review, user management, and content recommendation
- Production-Ready Foundation: JWT auth, structured error handling, and configurable runtime
Tech Stack
- Framework: Actix-Web 4.x
- Database: MariaDB + Diesel ORM
- Auth: JWT middleware
- Config: Dotenv-based environment management
// Example route handler
#[get("/dashboard")]
async fn get_stats(
db: web::Data<AdminDbPool>,
jwt: JwtAuth
) -> Result<Json<DashboardStats>, Error> {
let conn = &mut db.get_conn()?;
let stats = admin_service::get_dashboard_stats(conn)?;
Ok(Json(stats))
}
Architecture
Follows EggJS-inspired layered structure:
- Router: Endpoint definitions
- Controller: Request/response handling
- Service: Business logic
- Model: Database interactions
Environment Configuration
# .env.example
HOOPICS_DATABASE_URL="mysql://user:pwd@host/db"
HOOPICS_ADMIN_DATABASE_URL="mysql://..."
HOOPICS_STATISTICS_DATABASE_URL="mysql://..."
APP_HOST=127.0.0.1
APP_PORT=8080
JWT_SECRET="your_secure_key"
Deployment
# With cargo
DATABASE_URL=mysql://... cargo run --release
# Or via Docker
docker build -t hoopics-admin .
docker run -p 8080:8080 --env-file .env hoopics-admin
THE END