Anthill is a modern multi-tenant inventory management SaaS platform built with Rust (backend microservices) and SvelteKit 2 with Svelte 5 (frontend), optimized for e-commerce businesses.
This project standardizes on SQLx compile-time checked macros plus Offline Mode metadata to get both:
- Schema safety (catch SQL/type mistakes at compile time)
- Stable CI build (no need for a live DB during compilation)
- Prefer
sqlx::query!,sqlx::query_as!,sqlx::query_scalar!for static SQL (string literals). - Avoid
sqlx::query(...)+.bind(...)unless the query is truly dynamic. - Treat
.sqlx/as required workspace metadata:- any change to migrations or query macros must update
.sqlx/ .sqlx/must be committed to git
- any change to migrations or query macros must update
- Start Postgres with the correct schema/migrations applied.
- Set
DATABASE_URLto that database. - Run:
cargo install sqlx-cli --no-default-features --features postgres
cargo sqlx prepare- Commit the resulting changes in
.sqlx/together with your code/migrations.
Verify metadata is in sync:
cargo sqlx prepare --checkπ Just like an anthill works efficiently and organized, Anthill helps you manage inventory intelligently and automatically.
- β Multi-tenant Architecture: Support multiple tenants on the same infrastructure
- β Real-time Inventory Tracking: Update inventory in real-time
- β Marketplace Integration: Connect with Shopee, Lazada, Tiki, WooCommerce, Shopify
- β Order Management: Manage orders from multiple channels
- β Payment Gateway: Integrate with VNPay, Stripe, MoMo, ZaloPay
- β Analytics & Reporting: Analytics dashboard with Cube
- β Zero Downtime Deployment: Continuous deployment without interruption
The project uses Event-Driven Microservices architecture with the following technologies:
- Backend: Rust + Axum + Tokio + SQLx
- Frontend: SvelteKit 2 + Svelte 5 + TypeScript + Tailwind CSS + shadcn-svelte
- Authentication: Kanidm (OAuth2/OIDC Identity Provider)
- Authorization: Casbin-rs (RBAC)
- Database: PostgreSQL
- Cache: Redis
- Message Queue: NATS
- Analytics: Cube
- Deployment: CapRover (Docker Swarm)
- Gateway: NGINX (managed by CapRover)
See architecture details at ARCHITECTURE.md
anthill/
βββ services/ # Rust microservices
β βββ user-service/ # Authentication & tenancy
β βββ inventory-service/ # Inventory management
β βββ order-service/ # Order management
β βββ integration-service/ # Marketplace integration
β βββ payment-service/ # Payment processing
βββ frontend/ # SvelteKit 2 with Svelte 5 application
β βββ src/
β β βββ app.html # Main HTML template
β β βββ app.d.ts # TypeScript declarations
β β βββ lib/ # Shared libraries
β β β βββ components/ # Reusable UI components (shadcn-svelte)
β β β βββ stores/ # Svelte 5 runes state management
β β β βββ utils/ # Utility functions
β β β βββ auth/ # Authentication helpers
β β β βββ api/ # API client functions
β β βββ routes/ # Page routes
β βββ static/ # Static assets
β βββ package.json # Dependencies and scripts
β βββ svelte.config.js # SvelteKit configuration
β βββ vite.config.ts # Vite build configuration
β βββ tsconfig.json # TypeScript configuration
β βββ tailwind.config.js # Tailwind CSS configuration
β βββ playwright.config.ts # E2E testing configuration
βββ shared/ # Shared libraries
β βββ auth/ # Casbin RBAC, Kanidm integration
β βββ config/ # Environment config loader
β βββ db/ # Database utilities
β βββ error/ # Error types and HTTP responses
β βββ jwt/ # JWT encoding/decoding
β βββ kanidm_client/ # Kanidm OAuth2/OIDC client
β βββ openapi/ # OpenAPI spec generation
βββ infra/ # Infrastructure config
β βββ docker_compose/ # Local dev environment
β βββ nginx/ # API Gateway configuration
β βββ monitoring/ # Prometheus, Grafana, Loki setup
βββ migrations/ # Database migrations
βββ scripts/ # Utility scripts
βββ PROJECT_TRACKING/ # Project tracking and tasks
β βββ TASKS_OVERVIEW.md # Task list and progress
βββ docs/ # Documentation
βββ Cargo.toml # Rust workspace
βββ ARCHITECTURE.md # Architecture documentation
βββ STRUCTURE.md # Code structure guide
βββ README.md # This file- Rust (stable + nightly):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Bun:
curl -fsSL https://bun.sh/install | bash(fast JavaScript runtime and package manager for SvelteKit frontend - replaces Node.js) - Docker & Docker Compose: For running local environment
- PostgreSQL Client:
psql(optional, for debugging)
# Install Rust toolchain
rustup default stable
rustup toolchain add nightly
rustup component add clippy rustfmt
# Install cargo tools
cargo install cargo-watch # Auto-reload
cargo install sqlx-cli --features postgres # DB migrations
# Install Bun (if not already installed)
curl -fsSL https://bun.sh/install | bash# Clone repository
git clone <your-repo-url>
cd anthill
# Start PostgreSQL, Redis, NATS
docker-compose up -d
# Return to root directory# Navigate to frontend directory
cd frontend
# Install dependencies
bun install
# Start development server
bun dev
# In another terminal, run backend services...# Return to root directory
cd ..
# Build all services
cargo build --workspace
# Run user-service (default port 3000, configurable via PORT env var)
cargo run --bin user-service
# In another terminal, run inventory-service (port 8001 as per nginx config)
PORT=8001 cargo run --bin inventory-service
# Or run multiple services with different ports (in separate terminals):
# Terminal 1:
PORT=3000 cargo run --bin user-service
# Terminal 2:
PORT=8001 cargo run --bin inventory-service
# Terminal 3:
PORT=8002 cargo run --bin order-service
# And continue with other services...# Run database migrations
sqlx migrate run --database-url postgres://inventory_user:inventory_pass@localhost:5432/inventory_saas
# Verify schema
psql postgres://inventory_user:inventory_pass@localhost:5432/inventory_saas -c "\dt"This project uses pre-commit hooks to automatically check code quality before commits.
# Install pre-commit (one-time setup)
pipx install pre-commit
# Install git hooks (run in project root)
pre-commit install
# Run hooks manually on all files
pre-commit run --all-files
# Skip hooks for a specific commit (use sparingly)
git commit --no-verifyWhat the hooks do:
- β
Format Rust code with
cargo fmt - β
Lint Rust code with
cargo clippy(blocks commits with warnings) - β Check YAML syntax
- β Trim trailing whitespace
- β Fix end-of-file issues
- β Format TOML files
- β Prevent large files from being committed
# Navigate to frontend directory
cd frontend
# Install dependencies
bun install
# Start development server
bun dev
# Build for production
bun run build
# Preview production build
bun run preview
# Run unit tests (Vitest)
bun run test:unit
# Run E2E tests (Playwright)
bun run test:e2e
# Format code
bun run format
# Lint code
bun run lint# Format code
cargo fmt --all
# Lint code
cargo clippy --all -- -D warnings
# Run tests
cargo test --workspace
# Run specific service with auto-reload
cargo watch -x 'run -p user-service'
# Check code without building
cargo check --workspace# Run migrations
sqlx migrate run --database-url postgres://user:password@localhost:5432/inventory_db
# Create new migration
sqlx migrate add <migration_name>
# Revert migration
sqlx migrate revert --database-url postgres://user:password@localhost:5432/inventory_dbSee details in migrations/. Main tables:
tenants: Tenant informationusers: Users within each tenantproducts: Productsinventory_levels: Inventory levelsorders: Ordersintegrations: Marketplace integrationspayments: Payment transactionscasbin_rule: RBAC policies
- Authentication: Kanidm (OAuth2/OIDC Provider)
- User registration, login, password management
- Multi-factor authentication (Passkeys, WebAuthn, TOTP)
- JWT token issuance and validation
- Session management
- Authorization: Casbin-rs with multi-tenant RBAC
- Policy-based access control
- Group-based role mapping from Kanidm
- Tenant Isolation: Automatically filter queries by
tenant_idfrom Kanidm groups
Each service exposes OpenAPI spec at /api/docs endpoint.
Example: http://localhost:3000/api/docs for user-service.
- Install CapRover on your VPS: https://caprover.com/docs/get-started.html
- Deploy stateful services (PostgreSQL, Redis, NATS) via One-Click Apps
- Create
Dockerfilefor each microservice - Create app in CapRover and connect with GitHub
- Push code β CapRover automatically builds & deploys
See details in docs/production-deployment.md
- Unit Tests:
cargo test- Coverage > 70% - Integration Tests: Test API endpoints with test database
- E2E Tests: Playwright for frontend
- Load Tests: K6 for stress testing
- Logging:
tracingcrate + OpenTelemetry - Metrics: Prometheus + Grafana
- Tracing: Distributed tracing with Jaeger (optional)
- Health Checks:
/healthendpoint for each service
See details in docs/monitoring-setup.md
- Fork repository
- Create feature branch:
git checkout -b feature/amazing-feature - Install pre-commit hooks:
pre-commit install - Make your changes (hooks will run automatically on commit)
- Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Create Pull Request
- Rust: Pre-commit hooks will automatically run
cargo fmtandcargo clippy - Follow existing patterns in the codebase
- Write tests for new features
- Update documentation as needed
- Commit messages: Use conventional commits (e.g.,
feat:,fix:,chore:)
- ARCHITECTURE.md - Detailed system architecture
- STRUCTURE.md - Code structure and patterns
- PROJECT_TRACKING/TASKS_OVERVIEW.md - Task list and progress tracking
- docs/production-deployment.md - Production deployment guide
- docs/monitoring-setup.md - Monitoring setup guide
- docs/troubleshooting.md - Troubleshooting guide
- API Docs - OpenAPI spec at each service endpoint
MIT License - See LICENSE file for more details.
- Your Name - Initial work
- Axum - Web framework
- SvelteKit - Frontend framework
- Kanidm - Identity management platform
- CapRover - PaaS platform
- Casbin - Authorization library
- Cube - Analytics platform
Status: π§ In Development - Phase 3 (User Service) & Phase 4 (Inventory Service)
MVP Target: 2-3 months
See PROJECT_TRACKING/TASKS_OVERVIEW.md for detailed progress tracking.