Files
SquidSpirit 815877efba
All checks were successful
Frontend CI / build (push) Successful in 1m33s
BLOG-290 Migrate the frontend JS runtime to bun (#294)
### Description

This change migrates the frontend environment from Node.js/pnpm to Bun to improve build performance and runtime efficiency. The migration includes updating CI/CD workflows, Docker configurations, and the SvelteKit adapter. Additionally, the PR introduces stricter linting rules via eslint-plugin-simple-import-sort and a global restriction on relative imports to enforce the use of path aliases ($lib/...), ensuring a cleaner and more maintainable import structure across the project. Backend environment variables were also renamed for consistency.

### Package Changes

Package | Action | Version
-- | -- | --
svelte-adapter-bun | Added | 1.0.1
eslint-plugin-simple-import-sort | Added | 13.0.0
@types/node | Added | 22.19.17
eslint-plugin-import | Removed | 2.32.0
@sveltejs/adapter-node | Removed | 5.5.4
svelte | Updated | 5.55.1 -> 5.55.5
@sentry/sveltekit | Updated | 10.47.0 -> 10.51.0
@sveltejs/kit | Updated | 2.55.0 -> 2.58.0
tailwindcss | Updated | 4.2.2 -> 4.2.4
typescript-eslint | Updated | 8.58.0 -> 8.59.1

### Screenshots

_No response_

### Reference

Resolves #290.

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #294
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2026-05-14 17:26:39 +08:00
..

Backend

Development

Prerequisites

  • Rust - Latest stable version
  • sqlx-cli - Database migration tool
  • watchexec (Optional) - For hot reloading

Setup

  1. Install sqlx CLI:

    cargo install sqlx-cli
    
  2. Run database migrations:

    sqlx migrate run
    
  3. Prepare SQL schema:

    cargo sqlx prepare --workspace
    
  4. 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 configuration
  • feature/ - Feature modules organized by domain
    • auth/ - Authentication and authorization
    • post/ - Blog post management
    • label/ - Label/tag system
    • image/ - Image handling
    • search/ - Semantic search and RAG support
    • common/ - Shared utilities and types
  • migrations/ - Database migration scripts

Each feature module follows the Clean Architecture pattern:

  • domain/ - Business logic and entities
  • application/ - Use cases and application services
  • adapter/ - Interface adapters (controllers, presenters)
  • framework/ - External frameworks (database, HTTP)

Technology Stack

  • Framework: Actix-web
  • Database: PostgreSQL with SQLx
  • AI / Search: RAG-based semantic search with embeddings and Qdrant
  • Authentication: JWT-based
  • Serialization: Serde
  • Migration: SQLx migrations
  • Logging: env_logger with RUST_LOG

Search Embedding Cache

The search module supports Redis-based query embedding cache.

  • SEARCH_CACHE_KEY_PREFIX - Redis key namespace prefix

Implementation details:

  • Only query embedding is cached.
  • Search result IDs are not cached.
  • Cache uses existing REDIS_URL.
  • Cache is enabled by default.
  • Cache key model revision comes from embedding configuration.
  • index_post does not reset query embedding cache because cache entries only depend on query string.