### Install Frontend Dependencies Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Navigates to the frontend directory and installs required packages. ```bash cd my-app/frontend && npm install && cd .. ``` -------------------------------- ### Start development servers with romance dev Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Spawns backend and frontend development processes concurrently. Requires cargo-watch to be installed. ```text romance dev ``` ```bash romance dev # Starting development servers... # Backend: http://localhost:3001 # Frontend: http://localhost:5173 ``` -------------------------------- ### Verify CLI Installation Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Confirm the Romance CLI is correctly installed and accessible in your path. ```bash romance --version ``` -------------------------------- ### Install Romance CLI Source: https://github.com/aliexz011/romance/blob/main/README.md Install the CLI tool globally using Cargo. ```bash cargo install romance-cli ``` -------------------------------- ### Install Romance CLI Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Install the CLI tool via crates.io or by building directly from the source repository. ```bash cargo install romance ``` ```bash git clone https://github.com/romance-cli/romance.git cd romance cargo install --path crates/romance-cli ``` -------------------------------- ### Install Observability Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Run this command in the project root to add the observability module. ```bash romance add observability ``` -------------------------------- ### Configure Local Storage Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Example configuration for the local filesystem storage backend. ```toml [storage] backend = "local" upload_dir = "./uploads" max_file_size = "10MB" ``` -------------------------------- ### Install Security Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Run this command to add security middleware to your Romance project. ```bash romance add security ``` -------------------------------- ### Install WebSocket Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add WebSocket support to a Romance project. ```bash romance add websocket ``` -------------------------------- ### Install API Keys Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Installs the API key authentication system for machine-to-machine access. ```bash romance add api-keys ``` -------------------------------- ### Generate Entity Examples Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Various examples of generating entities with different field types, relations, and constraints. ```bash # With inline fields romance generate entity Product title:string price:decimal description:text? # With a foreign key relation romance generate entity Product title:string category_id:uuid->Category # With many-to-many relation romance generate entity Post title:string body:text tags:m2m->Tag # With validation constraints and searchable fields romance generate entity Article title:string[min=3,max=100,searchable] body:text[searchable] published:bool # With file/image fields romance generate entity Document title:string file:file preview:image? # Interactive mode (no fields specified) romance generate entity Product ``` -------------------------------- ### Run Development Servers Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Starts both the backend and frontend processes with hot-reloading enabled. ```bash romance dev ``` -------------------------------- ### Install i18n Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add internationalization support to a Romance project. ```bash romance add i18n ``` -------------------------------- ### Configure S3 Storage Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Example configuration for the S3 storage backend. ```toml [storage] backend = "s3" max_file_size = "50MB" ``` -------------------------------- ### Install Search Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add PostgreSQL full-text search support to a Romance project. ```bash romance add search ``` -------------------------------- ### Install Dashboard Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add the developer dashboard to a Romance project. ```bash romance add dashboard ``` -------------------------------- ### Install Storage Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add file upload and storage support to a Romance project. ```bash romance add storage ``` -------------------------------- ### Generate Auth Syntax and Example Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Syntax and usage for generating JWT authentication components. ```bash romance generate auth ``` ```bash romance generate auth ``` -------------------------------- ### Define Staging Overrides Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Example of a staging override file. ```toml [backend] port = 4000 database_url = "postgres://staging-host:5432/my_app_staging" ``` -------------------------------- ### Generate Admin Panel Example Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Usage for generating an admin panel, which requires authentication to be generated first. ```bash # Generate auth first romance generate auth # Then generate admin romance generate admin ``` -------------------------------- ### Run Database Migrations Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Executes database migrations required after installing addons. ```bash romance db migrate ``` -------------------------------- ### Install Email Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Run this command in your terminal to add the email service to your Romance project. ```bash romance add email ``` -------------------------------- ### Install Audit Log Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Run this command to add the audit logging functionality to the project. ```bash romance add audit-log ``` -------------------------------- ### GET /ready Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Checks that the server can connect to the database. Suitable for Kubernetes readiness probes. ```APIDOC ## GET /ready ### Description Checks that the server can connect to the database. Returns an error if the database is unreachable. ### Method GET ### Endpoint /ready ### Response #### Success Response (200) - **status** (string) - Readiness status - **database** (string) - Database connection status #### Error Response (503) - Returned when the database ping fails. ``` -------------------------------- ### Install Cache Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add the Redis-backed caching layer to a Romance project. ```bash romance add cache ``` -------------------------------- ### Configure project section Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Example of defining project metadata within the [project] section. ```toml [project] name = "my-blog" description = "A blogging platform built with Romance" ``` -------------------------------- ### Install Validation Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add field-level validation capabilities to a Romance project. ```bash romance add validation ``` -------------------------------- ### Verify Dependencies Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Check that the required tools are installed and meet the minimum version requirements. ```bash rustc --version node --version npm --version psql --version ``` -------------------------------- ### Generate OpenAPI Specification Example Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Command to generate an OpenAPI JSON specification. ```bash romance generate openapi ``` -------------------------------- ### Build Frontend Assets Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Installs dependencies and builds the frontend static assets into the dist directory. ```bash cd frontend npm ci npm run build # Static files are in: frontend/dist/ ``` -------------------------------- ### GET /api/products Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md List all products with support for pagination, filtering, and sorting. ```APIDOC ## GET /api/products ### Description List all products (paginated, filterable, sortable). ### Method GET ### Endpoint /api/products ``` -------------------------------- ### Configure project features Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Define installed addons and their status within the [features] section. ```toml [features] validation = true soft_delete = true audit_log = false search = true ``` -------------------------------- ### Install Tasks Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to add the background task queue and scheduler to a Romance project. ```bash romance add tasks ``` -------------------------------- ### Add Project Addons Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Installs optional features such as validation, storage, search, and security modules. ```bash romance add validation # Backend (validator) + frontend (Zod) validation romance add storage # File/image upload with pluggable storage romance add search # Full-text search (PostgreSQL tsvector) romance add security # Rate limiting + security headers romance add observability # Structured logging + request ID tracing romance add soft-delete # Soft-delete with restore/force-delete romance add audit-log # Audit logging (requires auth) romance add oauth google # OAuth social authentication romance add dashboard # Developer dashboard ``` -------------------------------- ### Entity Field Syntax Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Examples of supported field types and syntax for entity generation. ```bash # Required string field title:string # Optional text field (nullable, indicated by ? suffix) description:text? # Decimal field for prices price:decimal # Boolean field in_stock:bool # Foreign key to another entity category_id:uuid->Category # Enum field with defined variants status:enum(draft,published,archived) ``` -------------------------------- ### Initialize and Generate CRUD Entities Source: https://github.com/aliexz011/romance/blob/main/README.md Commands to scaffold a new project, generate a CRUD entity, and start the development server. ```bash romance new my-app cd my-app romance generate entity Post title:string body:text published:bool author_id:uuid->User romance dev ``` -------------------------------- ### GET /api/products/:id Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Retrieve a single product by its unique identifier. ```APIDOC ## GET /api/products/:id ### Description Get a single product by ID. ### Method GET ### Endpoint /api/products/:id ``` -------------------------------- ### Run Migrations in Application Entrypoint Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Use a custom shell script to execute migrations before starting the application process. ```bash # Create a custom entrypoint script #!/bin/sh set -e # Run migrations cd /app && cargo run --release --bin migration -- up # Start the application exec app ``` -------------------------------- ### GET /health Response Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md JSON response for the liveness check endpoint. ```json { "status": "ok", "timestamp": "2025-01-15T10:30:00.000Z" } ``` -------------------------------- ### Install OAuth provider Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Commands to add OAuth2 support for specific providers. Requires the auth module to be generated first. ```bash romance add oauth --provider google romance add oauth --provider github romance add oauth --provider discord ``` -------------------------------- ### Schedule Recurring Jobs Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Initialize and start a scheduler for recurring background tasks. ```rust let mut scheduler = scheduler::Scheduler::new(); scheduler.add_job("cleanup", Duration::from_secs(3600), || { tokio::spawn(async { /* ... */ }) }); scheduler.start(); ``` -------------------------------- ### GET /api/tags/:id/posts Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md List all posts associated with a specific tag. ```APIDOC ## GET /api/tags/:id/posts ### Description List all posts associated with a tag. ### Method GET ### Endpoint /api/tags/:id/posts ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the tag. ``` -------------------------------- ### GET /api/posts/:id/tags Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md List all tags associated with a specific post. ```APIDOC ## GET /api/posts/:id/tags ### Description List all tags associated with a post. ### Method GET ### Endpoint /api/posts/:id/tags ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the post. ``` -------------------------------- ### GET /ready Response Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md JSON response for the readiness check endpoint indicating database connectivity. ```json { "status": "ready", "database": "connected" } ``` -------------------------------- ### Define Production Overrides Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Example of a production override file that merges into the base configuration. ```toml # Production overrides -- values here override romance.toml # Activated by setting ROMANCE_ENV=production or [environment] active = "production" [backend] port = 8080 [security] rate_limit_anon_rpm = 30 rate_limit_auth_rpm = 120 cors_origins = [] [storage] backend = "s3" ``` -------------------------------- ### Generate entity with multiple fields Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Full command example for generating a Product entity with various field types and relations. ```bash romance generate entity Product \ title:string[min=1,max=200] \ price:decimal \ description:text? \ published:bool \ category_id:uuid->Category \ tags:m2m->Tag ``` -------------------------------- ### Generate TypeScript Types Example Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Command to export TypeScript types from Rust structs. ```bash romance generate types ``` -------------------------------- ### Use i18n Translation Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Examples of using translation utilities in both backend and frontend code. ```rust let msg = i18n::t("en", "common.success"); ``` ```rust let locale = request.extensions().get::(); ``` ```tsx import { t } from '@/lib/i18n';

{t("common.welcome")}

``` -------------------------------- ### Install Soft Delete Addon Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Adds soft-delete support to entity generation, replacing permanent deletion with a deleted_at timestamp. ```bash romance add soft-delete ``` -------------------------------- ### Enqueue and Process Tasks Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enqueue tasks and start a worker pool for background processing. ```rust // Enqueue a task TaskQueue::new(db).enqueue("send_email", payload).await?; // Start a worker pool (4 concurrent workers) TaskQueue::new(db).start_worker(4, handler).await; ``` -------------------------------- ### Docker Compose Management Commands Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Common commands for building, starting, and managing the lifecycle of the application containers. ```bash # Build all services docker compose build # Build and start all services docker compose up --build # Start in detached mode docker compose up -d # View logs docker compose logs -f backend docker compose logs -f frontend # Stop all services docker compose down # Stop and remove volumes (destroys database data) docker compose down -v ``` -------------------------------- ### Extend Workflow with Deployment Step Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Example of adding a deployment job that depends on the successful completion of backend and frontend CI jobs. ```yaml deploy: needs: [backend, frontend] runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - uses: actions/checkout@v4 - name: Build and push Docker images run: | docker build -t my-registry/my-app-backend:${{ github.sha }} -f Dockerfile . docker build -t my-registry/my-app-frontend:${{ github.sha }} -f Dockerfile.frontend . docker push my-registry/my-app-backend:${{ github.sha }} docker push my-registry/my-app-frontend:${{ github.sha }} - name: Deploy run: | # Your deployment steps here (e.g., kubectl apply, docker compose pull, etc.) ``` -------------------------------- ### Initialize a new project Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Scaffolds a full-stack project structure including backend, frontend, and configuration files. ```bash romance new ``` ```bash romance new my-blog # Output: # Creating new Romance project: my-blog # create backend/Cargo.toml # create backend/src/main.rs # ... # create .github/workflows/ci.yml # Installing frontend dependencies... # Project created successfully! ``` -------------------------------- ### Create a New Project Source: https://github.com/aliexz011/romance/blob/main/README.md Initialize a new project directory structure. ```bash romance new my-app cd my-app ``` -------------------------------- ### Combine Visibility and Validation Rules Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Example of generating an entity with multiple fields using combined visibility and validation rules. ```bash romance generate entity Employee \ name:string[min=2,max=50] \ salary:decimal[admin_only,min=0] \ ssn:string[roles=hr;admin,unique] ``` -------------------------------- ### Configure Migration Service in Docker Compose Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Define a dedicated migration service that runs before the backend container starts. ```yaml services: migrate: build: context: . dockerfile: Dockerfile command: ["sh", "-c", "cd /app && cargo run --bin migration -- up"] environment: DATABASE_URL: postgres://postgres:postgres@db:5432/my_app depends_on: db: condition: service_healthy backend: # ... depends_on: migrate: condition: service_completed_successfully ``` -------------------------------- ### Use WebSocket Hook Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Example of using the generated React hook to manage WebSocket connections in a component. ```tsx import { useWebSocket } from '@/lib/useWebSocket'; function MyComponent() { const { messages, sendMessage, isConnected } = useWebSocket('ws://localhost:3000/ws'); // ... } ``` -------------------------------- ### Docker Compose Health Check Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Example configuration for adding a health check to the backend service in docker-compose.yml. ```yaml services: backend: # ... healthcheck: test: ["CMD", "curl", "-f", "http://localhost:3001/health"] interval: 30s timeout: 5s retries: 3 start_period: 10s ``` -------------------------------- ### Generate New Project Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Initialize a new full-stack project structure using the CLI. ```bash romance new my-app ``` -------------------------------- ### Use Cache Service Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Perform basic cache operations including setting, getting, and deleting values with TTL support. ```rust let cache = CacheService::new()?; cache.set("key", &value, 300).await?; // TTL in seconds let val: Option = cache.get("key").await?; cache.del("key").await?; ``` -------------------------------- ### GET /health Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Returns the server's status and current timestamp. This endpoint is suitable for load balancer liveness probes. ```APIDOC ## GET /health ### Description Returns the server's status and current timestamp. Does not check external dependencies. ### Method GET ### Endpoint /health ### Response #### Success Response (200) - **status** (string) - Server status - **timestamp** (string) - Current server timestamp #### Response Example { "status": "ok", "timestamp": "2025-01-15T10:30:00.000Z" } ``` -------------------------------- ### Run Backend Binary Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Executes the production binary with necessary environment variables for database connection, security, and network configuration. ```bash DATABASE_URL="postgres://user:pass@host:5432/dbname" \ JWT_SECRET="your-secret" \ PORT=8080 \ RUST_LOG=info \ CORS_ORIGIN="https://your-domain.com" \ ./target/release/my_app-backend ``` -------------------------------- ### Define the ROMANCE:CUSTOM marker Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Place this comment marker in your entity file to designate the start of the preserved code section. ```rust // === ROMANCE:CUSTOM === ``` ```typescript // === ROMANCE:CUSTOM === ``` -------------------------------- ### Add Project Addons Source: https://github.com/aliexz011/romance/blob/main/README.md Commands to extend project functionality with production-ready features. ```bash romance add validation ``` ```bash romance add soft-delete ``` ```bash romance add audit-log ``` ```bash romance add storage ``` ```bash romance add search ``` ```bash romance add oauth google ``` ```bash romance add security ``` ```bash romance add observability ``` ```bash romance add dashboard ``` ```bash romance add email ``` ```bash romance add i18n ``` ```bash romance add cache ``` ```bash romance add tasks ``` ```bash romance add websocket ``` ```bash romance add api-keys ``` -------------------------------- ### Create PostgreSQL Database Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Initializes a new PostgreSQL database for the application. ```bash createdb my_app ``` -------------------------------- ### Build Backend Binary Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Compiles the backend project in release mode to generate the production binary. ```bash cd backend cargo build --release # The binary is at: # backend/target/release/{project_name_snake}-backend ``` -------------------------------- ### Run database migrations Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Executes pending migrations via the SeaORM migration binary. ```bash romance db migrate # Running migrations... # Migrations applied successfully! ``` -------------------------------- ### Demonstrate Deep Merge Behavior Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Illustration of how base configuration values are preserved during a merge with an override file. ```toml # Base romance.toml [backend] port = 3001 database_url = "postgres://localhost/my_app" [features] validation = true # romance.staging.toml [backend] port = 4000 # Result after merge: # backend.port = 4000 (overridden) # backend.database_url = "..." (preserved from base) # features.validation = true (preserved from base) ``` -------------------------------- ### Generate Authentication and Admin Panels Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Scaffolds authentication logic or an admin dashboard into the project. ```bash romance generate auth ``` ```bash romance generate admin ``` -------------------------------- ### POST /api/products Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Create a new product entry. ```APIDOC ## POST /api/products ### Description Create a new product. ### Method POST ### Endpoint /api/products ``` -------------------------------- ### Configure Backend Settings Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Defines the server port, database connection string, and API route prefix. ```toml [backend] port = 3001 database_url = "postgres://localhost/my_blog" api_prefix = "/api/v1" ``` -------------------------------- ### Configure backend/.env Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Contains environment-specific secrets and connection strings for production deployment. ```env DATABASE_URL=postgres://prod-user:prod-pass@db.example.com:5432/my_ecommerce PORT=8080 JWT_SECRET=a-long-random-secret-generated-with-openssl-rand-base64-64 RUST_LOG=info CORS_ORIGIN=https://my-ecommerce.example.com S3_BUCKET=my-ecommerce-uploads S3_REGION=us-east-1 S3_ACCESS_KEY=AKIA... S3_SECRET_KEY=... ``` -------------------------------- ### Manage Database Migrations Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Commands for applying, checking, rolling back, and seeding database migrations. ```bash romance db migrate ``` ```bash # Check which migrations have been applied romance db status # Rollback the last migration romance db rollback # Run seed data (if configured) romance db seed ``` -------------------------------- ### Configure Database URL Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Sets the connection string in the environment configuration file. ```env DATABASE_URL=postgres://localhost/my_app ``` -------------------------------- ### Activate Production Environment Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Set the environment variable to enable production mode for the Romance CLI. ```bash export ROMANCE_ENV=production ``` -------------------------------- ### Frontend Dockerfile Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Uses a multi-stage build with Node.js for the Vite build process and Nginx for serving the static assets. ```dockerfile FROM node:20-alpine AS builder WORKDIR /app COPY frontend/package*.json ./ RUN npm ci COPY frontend/ . RUN npm run build FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 ``` -------------------------------- ### Run project verification with romance check Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Executes backend compilation, backend tests, and frontend type checking sequentially. Exits immediately on any failure. ```text romance check ``` ```bash romance check # Running checks... # cargo check... OK # cargo test... OK # tsc --noEmit... OK # All checks passed! ``` -------------------------------- ### Configure Frontend Settings Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Sets the Vite development server port and the base URL for the backend API. ```toml [frontend] port = 5173 api_base_url = "http://localhost:3001" ``` -------------------------------- ### Initialize Email Service Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Instantiate the email service within your Rust code to begin sending emails. ```rust let email_service = EmailService::new(); // Password reset handler available at /api/auth/password-reset ``` -------------------------------- ### Backend Dockerfile Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Uses a multi-stage build to compile the Rust backend and create a minimal Debian-based runtime image. ```dockerfile # Build stage FROM rust:1.83 AS builder WORKDIR /app COPY backend/ . RUN cargo build --release # Runtime stage FROM debian:bookworm-slim RUN apt-get update && apt-get install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/* COPY --from=builder /app/target/release/my_app-backend /usr/local/bin/app EXPOSE 3001 CMD ["app"] ``` -------------------------------- ### Production Image Building and Pushing Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Commands for tagging specific production images and pushing them to a container registry. ```bash # Build with specific tags docker build -t my-app-backend:v1.0.0 -f Dockerfile . docker build -t my-app-frontend:v1.0.0 -f Dockerfile.frontend . # Push to a container registry docker tag my-app-backend:v1.0.0 registry.example.com/my-app-backend:v1.0.0 docker push registry.example.com/my-app-backend:v1.0.0 ``` -------------------------------- ### Generate entities and relations via CLI Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Use these commands to scaffold entities, authentication, and complex relations including foreign keys and many-to-many associations. ```bash # Step 1: Create Category (standalone entity) romance generate entity Category name:string description:text? # Step 2: Create Tag (standalone entity) romance generate entity Tag name:string[unique] color:string? # Step 3: Create User with auth romance generate auth # Step 4: Create Post with multiple relations romance generate entity Post \ title:string[min=3,max=200,searchable] \ body:text[searchable] \ published:bool \ author_id:uuid->User \ category_id:uuid->Category? \ tags:m2m->Tag ``` -------------------------------- ### Configure Security Settings Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Define rate limits and CORS origins in the romance.toml configuration file. ```toml # romance.toml [security] rate_limit_anon_rpm = 30 rate_limit_auth_rpm = 120 cors_origins = ["http://localhost:5173"] ``` -------------------------------- ### Override configuration for production environments Source: https://github.com/aliexz011/romance/blob/main/README.md Create environment-specific files like romance.production.toml to deep-merge settings over the base configuration. ```toml # romance.production.toml [backend] port = 8080 ``` -------------------------------- ### Configure WebSocket Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the WebSocket feature in the project configuration file. ```toml # romance.toml [features] websocket = true ``` -------------------------------- ### Activate Environment Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Methods to activate a specific environment via shell or configuration file. ```bash # Via environment variable ROMANCE_ENV=staging romance dev # Or in romance.toml [environment] active = "staging" ``` -------------------------------- ### Configure romance.production.toml Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Provides production-specific overrides for backend, security, and storage settings. ```toml [backend] port = 8080 [security] rate_limit_anon_rpm = 30 rate_limit_auth_rpm = 120 cors_origins = ["https://my-ecommerce.example.com"] [storage] backend = "s3" max_file_size = "50MB" ``` -------------------------------- ### Run Tests and Update Scaffold Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Executes tests using a temporary database or updates project files against the latest templates. ```bash romance test ``` ```bash romance update ``` -------------------------------- ### Kubernetes Liveness and Readiness Probes Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Configuration for Kubernetes liveness and readiness probes targeting the backend service. ```yaml livenessProbe: httpGet: path: /health port: 3001 initialDelaySeconds: 5 periodSeconds: 15 readinessProbe: httpGet: path: /ready port: 3001 initialDelaySeconds: 10 periodSeconds: 10 ``` -------------------------------- ### Add Storage and Generate Entity with File Fields Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Configures the storage addon and generates an entity containing file and image fields for upload handling. ```bash romance add storage romance generate entity Document title:string file:file preview:image? ``` -------------------------------- ### Configure Email Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the email feature in your romance.toml configuration file. ```toml # romance.toml [features] email = true ``` -------------------------------- ### Generate Entity Syntax Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md The basic syntax for generating a full CRUD entity. ```bash romance generate entity [field:type...] ``` -------------------------------- ### Production Configuration Overrides Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Default production settings for the Romance CLI, typically defined in romance.production.toml. ```toml [backend] port = 8080 [security] rate_limit_anon_rpm = 30 rate_limit_auth_rpm = 120 cors_origins = [] [storage] backend = "s3" ``` -------------------------------- ### Execute test suite with romance test Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Runs tests in an isolated temporary database environment. Must be executed from the project root directory. ```text romance test ``` ```bash romance test ``` -------------------------------- ### Generate Entity Command Syntax Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Basic command structure for generating entities via the CLI. ```bash romance generate entity [field:type...] ``` -------------------------------- ### POST /api/products/bulk Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Create multiple product records in a single request. ```APIDOC ## POST /api/products/bulk ### Description Create multiple products. ### Method POST ### Endpoint /api/products/bulk ``` -------------------------------- ### Configure Tasks Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the background_tasks feature in the romance.toml configuration file. ```toml # romance.toml [features] background_tasks = true ``` -------------------------------- ### Execute management command with romance run Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Runs a custom management command registered in the backend application. Requires the command to be defined in backend/src/commands.rs. ```bash romance run cleanup --older-than 30d # Running management command: cleanup # Command 'cleanup' completed. ``` -------------------------------- ### Configure Search Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the search feature in the romance.toml configuration file. ```toml # romance.toml [features] search = true ``` -------------------------------- ### Run Project Checks Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Executes sequential checks for backend compilation, unit tests, and frontend type safety. ```bash romance check ``` -------------------------------- ### Run Migrations Manually Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Execute migrations from the project root or directly via cargo. ```bash # From the project root romance db migrate # Or directly with cargo cd backend && cargo run --bin migration -- up ``` -------------------------------- ### Mark Fields as Searchable Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Configuring fields for full-text search indexing using the searchable annotation. ```bash romance generate entity Article title:string[searchable] body:text[searchable] author:string ``` ```bash title:string[min=3,max=100,searchable] ``` -------------------------------- ### Configure i18n Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the i18n feature in the project configuration file. ```toml # romance.toml [features] i18n = true ``` -------------------------------- ### Default .env Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md The standard environment variable template generated by the romance new command. ```env DATABASE_URL=postgres://localhost/my_app PORT=3001 JWT_SECRET=romance-dev-secret-change-in-production RUST_LOG=info CORS_ORIGIN=http://localhost:5173 ``` -------------------------------- ### Update project scaffold files Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Updates project files to the latest template version, handling conflicts interactively. ```bash # First-time setup for an existing project romance update --init # Manifest created at .romance/manifest.json # Regular update romance update # Checking for template updates... # 2 file(s) can be auto-updated # 1 file(s) have conflicts # 0 file(s) are new in this version ``` -------------------------------- ### Configure Cache Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the cache feature in the romance.toml configuration file. ```toml # romance.toml [features] cache = true ``` -------------------------------- ### Configure Audit Log Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enable the audit log feature in the project configuration file. ```toml # romance.toml [features] audit_log = true ``` -------------------------------- ### Generate Entities in Recommended Order Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Generate the target entity first to allow Romance to automatically inject the HasMany relationship. ```bash # 1. Generate User first romance generate entity User name:string email:string # 2. Generate Post with FK to User romance generate entity Post title:string author_id:uuid->User ``` -------------------------------- ### Configure romance.toml Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Defines the base configuration for project settings, backend, frontend, codegen, features, security, storage, and environment. ```toml [project] name = "my-ecommerce" description = "An e-commerce platform" [backend] port = 3001 database_url = "postgres://localhost/my_ecommerce" api_prefix = "/api/v1" [frontend] port = 5173 api_base_url = "http://localhost:3001" [codegen] generate_openapi = true generate_ts_types = true [features] validation = true soft_delete = true audit_log = true search = true [security] rate_limit_rpm = 100 cors_origins = ["http://localhost:5173"] csrf = false [storage] backend = "local" upload_dir = "./uploads" max_file_size = "25MB" [environment] active = "development" ``` -------------------------------- ### Default romance.toml configuration Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md The initial configuration file generated by the romance new command. ```toml [project] name = "my-app" [backend] port = 3001 database_url = "postgres://localhost/my_app" [frontend] port = 5173 api_base_url = "http://localhost:3001" [codegen] generate_openapi = true generate_ts_types = true [features] # Enable with: romance add # validation = true # soft_delete = true # audit_log = true # search = true ``` -------------------------------- ### Define Field Visibility Syntax Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md The basic syntax for applying visibility annotations to entity fields. ```bash name:type[visibility_annotation] ``` -------------------------------- ### Set Active Environment Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Basic configuration for defining the active environment in the main config file. ```toml [environment] active = "development" ``` -------------------------------- ### Add OAuth authentication Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Configures OAuth social authentication for specified providers. ```bash romance add oauth ``` ```bash romance add oauth google romance add oauth github romance add oauth discord ``` -------------------------------- ### Generate Entity with File Fields Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Use image and file types during entity generation to enable storage support. ```bash romance generate entity Profile name:string avatar:image document:file ``` -------------------------------- ### Configure security middleware Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Set rate limits, allowed CORS origins, and CSRF protection in the [security] section. ```toml [security] rate_limit_rpm = 100 cors_origins = ["http://localhost:5173", "https://my-app.example.com"] csrf = true ``` -------------------------------- ### Basic Nginx SPA and API Proxy Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Standard configuration for serving static files and routing API requests to a backend service. ```nginx server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } location /api { proxy_pass http://backend:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } ``` -------------------------------- ### Check Migration Status Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Verify the current state of applied migrations. ```bash romance db status # Or directly cd backend && cargo run --bin migration -- status ``` -------------------------------- ### Override security settings for production Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Use a production-specific configuration file to adjust rate limits and restrict CORS origins. ```toml [security] rate_limit_anon_rpm = 30 rate_limit_auth_rpm = 120 cors_origins = [] ``` -------------------------------- ### Generate Types and OpenAPI Specs Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Creates TypeScript definitions from Rust structs or generates an OpenAPI specification. ```bash romance generate types ``` ```bash romance generate openapi ``` -------------------------------- ### Check database migration status Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Displays the current state of all migrations, indicating which are applied or pending. ```bash romance db status # Migration status: # [Applied] m20250101000000_create_users_table # [Applied] m20250101000001_create_products_table # [Pending] m20250102000000_create_orders_table ``` -------------------------------- ### Run database seed data Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Executes seed data operations, generating a seed file if one is missing. ```bash romance db seed # Running seed data... # Seed data applied successfully! ``` -------------------------------- ### Add Relations Source: https://github.com/aliexz011/romance/blob/main/README.md Define entities with foreign keys and many-to-many relationships to automatically generate junction tables and route logic. ```bash romance generate entity Category name:string romance generate entity Product title:string category_id:uuid->Category tags:m2m->Tag romance generate entity Tag name:string ``` -------------------------------- ### Configure Soft Delete Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Enables the soft-delete feature in the project configuration file. ```toml # romance.toml [features] soft_delete = true ``` -------------------------------- ### Generate Entity with Validation Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Command to generate an entity with specific validation rules applied to fields. ```bash romance generate entity Product name:string[min=3,max=100] price:decimal ``` -------------------------------- ### Run project health checks Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Executes a series of diagnostic checks to verify the project structure, configuration files, and required toolchains. ```text romance doctor ``` ```bash romance doctor # Romance Doctor # V romance.toml found and valid # V Backend structure OK # V Frontend structure OK # V Markers intact (entities, handlers, routes) # V Cargo installed (1.83.0) # V Node.js installed (v20.11.0) # V DATABASE_URL configured # V .romance/manifest.json valid # # 8/8 checks passed ``` -------------------------------- ### Docker Compose Service Definition Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Defines the multi-service architecture including PostgreSQL, Redis, the backend API, and the frontend SPA. ```yaml version: '3.8' services: db: image: postgres:16 environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: my_app ports: - "5432:5432" volumes: - pgdata:/var/lib/postgresql/data redis: image: redis:7-alpine ports: - "6379:6379" backend: build: context: . dockerfile: Dockerfile ports: - "3001:3001" environment: DATABASE_URL: postgres://postgres:postgres@db:5432/my_app REDIS_URL: redis://redis:6379 JWT_SECRET: change-me-in-production RUST_LOG: info depends_on: - db - redis frontend: build: context: ./frontend dockerfile: Dockerfile.frontend ports: - "5173:80" depends_on: - backend volumes: pgdata: ``` -------------------------------- ### Generate BelongsTo Relation Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Use the CLI to create a foreign key relation between entities. ```bash romance generate entity :-> ``` ```bash romance generate entity Post title:string body:text author_id:uuid->User ``` -------------------------------- ### Define basic entity field Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Standard syntax for defining a field with a specific type. ```text name:type ``` -------------------------------- ### PUT /api/products/:id Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Update an existing product by its ID. ```APIDOC ## PUT /api/products/:id ### Description Update an existing product. ### Method PUT ### Endpoint /api/products/:id ``` -------------------------------- ### Generate shell completions Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Outputs shell completion scripts for supported shells to enable command auto-completion. ```text romance completions ``` ```bash # Bash romance completions bash > ~/.local/share/bash-completion/completions/romance # Zsh romance completions zsh > ~/.zfunc/_romance # Fish romance completions fish > ~/.config/fish/completions/romance.fish ``` -------------------------------- ### Hardened Nginx Production Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Extended configuration adding security headers, Gzip compression, asset caching, and proxy timeout settings. ```nginx server { listen 80; root /usr/share/nginx/html; index index.html; # Security headers add_header X-Frame-Options "DENY" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript; # Cache static assets location /assets { expires 1y; add_header Cache-Control "public, immutable"; } location / { try_files $uri $uri/ /index.html; } location /api { proxy_pass http://backend:3001; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # Timeouts proxy_connect_timeout 30s; proxy_read_timeout 60s; proxy_send_timeout 60s; } } ``` -------------------------------- ### Destroy an entity using CLI Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Executes the removal of all files and configuration references associated with the specified entity. ```bash romance destroy entity Product ``` -------------------------------- ### GitHub Actions CI Workflow Configuration Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md The default CI workflow file located at .github/workflows/ci.yml, which manages backend testing and frontend build processes. ```yaml name: CI on: push: branches: [main] pull_request: branches: [main] env: CARGO_TERM_COLOR: always jobs: backend: runs-on: ubuntu-latest services: postgres: image: postgres:16 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: my_app_test ports: - 5432:5432 options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: workdir: backend - name: Check working-directory: backend run: cargo check - name: Test working-directory: backend env: DATABASE_URL: postgres://postgres:postgres@localhost:5432/my_app_test JWT_SECRET: test-secret run: cargo test - name: Clippy working-directory: backend run: cargo clippy -- -D warnings frontend: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 cache: npm cache-dependency-path: frontend/package-lock.json - name: Install working-directory: frontend run: npm ci - name: Type check working-directory: frontend run: npx tsc --noEmit - name: Build working-directory: frontend run: npm run build ``` -------------------------------- ### BelongsTo Backend Implementation Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Generated Rust code for a BelongsTo relation in the model, handler, and route files. ```rust // In the Model struct pub author_id: Uuid, // In the Relation enum #[sea_orm( belongs_to = "super::user::Entity", from = "Column::AuthorId", to = "super::user::Column::Id" )] User, // Related impl impl Related for Entity { fn to() -> RelationDef { Relation::User.def() } } ``` ```rust pub async fn list_posts( State(state): State, Path(id): Path, Query(params): Query, ) -> crate::errors::AppResult>> { // Paginated query filtering posts by author_id = id } ``` ```rust .route("/api/users/:id/posts", get(user::list_posts)) ``` -------------------------------- ### Generate CRUD Entity Source: https://github.com/aliexz011/romance/blob/main/docs/getting-started.md Generates full-stack boilerplate for a new entity including backend models, handlers, routes, and frontend components. ```bash romance generate entity Product title:string price:decimal description:text? in_stock:bool ``` -------------------------------- ### Handle Pending ManyToMany Relations Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md CLI commands for handling relations where the target entity is not yet defined. ```bash # Tag doesn't exist yet romance generate entity Post title:string tags:m2m->Tag # Output: Target entity 'Tag' not found -- storing pending M2M relation # Later, when Tag is generated: romance generate entity Tag name:string # Output: Applied pending M2M: Post <-> Tag # Junction table post_tag is now generated, and both entities get their M2M code ``` -------------------------------- ### Define field modifiers in CLI Source: https://github.com/aliexz011/romance/blob/main/README.md Use this syntax in the CLI to define optional fields, foreign keys, validation rules, and searchability. ```bash # Optional (nullable) field -- append ? description:text? # Foreign key -- append ->EntityName category_id:uuid->Category # Validation rules -- use brackets title:string[min=3,max=100] email:string[email] slug:string[unique] website:string[url] code:string[regex=^[A-Z]{3}$] # Searchable field (for full-text search addon) title:string[searchable] body:text[searchable] # Combine modifiers author_id:uuid[required]->User title:string[min=3,max=200,searchable] ``` -------------------------------- ### Configure Validation Feature Source: https://github.com/aliexz011/romance/blob/main/docs/addons.md Manual configuration entry for the validation feature in the project manifest. ```toml # romance.toml [features] validation = true ``` -------------------------------- ### DELETE /api/products/bulk Source: https://github.com/aliexz011/romance/blob/main/docs/entities.md Delete multiple products by their IDs. ```APIDOC ## DELETE /api/products/bulk ### Description Delete multiple products by ID. ### Method DELETE ### Endpoint /api/products/bulk ``` -------------------------------- ### Configure Code Generation Source: https://github.com/aliexz011/romance/blob/main/docs/configuration.md Controls the generation of OpenAPI annotations and TypeScript type definitions. ```toml [codegen] generate_openapi = true generate_ts_types = true ``` ```toml # Section present, fields omitted -> both default to true [codegen] # Section absent entirely -> both default to false # (no [codegen] section) # Explicit values override defaults [codegen] generate_openapi = true generate_ts_types = false ``` -------------------------------- ### Pending Relations JSON Structure Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md The format of the pending relations configuration file. ```json [ { "source_entity": "Post", "target_entity": "Tag", "relation_type": "ManyToMany" } ] ``` -------------------------------- ### ManyToMany API Routes Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Generated API routes for managing M2M associations. ```rust .route("/api/posts/:id/tags", get(post::list_tags)) .route("/api/posts/:id/tags/:tag_id", post(post::add_tag)) .route("/api/posts/:id/tags/:tag_id", delete(post::remove_tag)) ``` ```rust .route("/api/tags/:id/posts", get(tag::list_posts)) .route("/api/tags/:id/posts/:post_id", post(tag::add_post)) .route("/api/tags/:id/posts/:post_id", delete(tag::remove_post)) ``` -------------------------------- ### Define optional entity field Source: https://github.com/aliexz011/romance/blob/main/docs/cli-reference.md Appends a question mark to allow null values in the database. ```text name:type? ``` -------------------------------- ### Nested Serialization Query Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Use the include parameter to embed related objects in API responses. ```http GET /api/posts/123?include=user ``` ```http GET /api/posts/123?include=user,category ``` -------------------------------- ### Generate Entity with Explicit HasMany Source: https://github.com/aliexz011/romance/blob/main/docs/relations.md Use this command to define a HasMany relationship when the child entity does not yet exist. ```bash romance generate entity User name:string email:string posts:has_many->Post ``` -------------------------------- ### Docker Compose Stop Grace Period Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Configuration to increase the grace period for Docker to wait before sending SIGKILL. ```yaml services: backend: # ... stop_grace_period: 30s ``` -------------------------------- ### Rollback Database Migrations Source: https://github.com/aliexz011/romance/blob/main/docs/deployment.md Revert the last applied migration using the CLI or cargo directly. ```bash romance db rollback # Or directly cd backend && cargo run --bin migration -- down ```