Skip to content

applications local web app

Douwe de Vries edited this page Jul 1, 2026 · 2 revisions

Local Web App

Active contributors: Douwe de Vries

The local web app is a single Rust process that serves both the API and the built frontend. /Users/vriesd/projects/csv-align/src/main.rs initializes tracing_subscriber, creates the shared API state, resolves /Users/vriesd/projects/csv-align/frontend/dist, builds the Axum app, and binds the listener to 127.0.0.1:3001.

The frontend must be built before the server starts because cargo run does not run Vite. The expected local flow is:

cd frontend && npm run build
cargo run

After startup, open http://127.0.0.1:3001. API routes are registered before the static file fallback, so /api/* requests go to Axum handlers and all other paths are served from the built frontend directory with directory index fallback.

Route registration

Method Path Handler
GET /api/health health_check
POST /api/sessions create_session
DELETE /api/sessions/{session_id} delete_session
POST /api/sessions/{session_id}/files/{file_letter} load_csv_file
POST /api/sessions/{session_id}/mappings suggest_mappings
POST /api/sessions/{session_id}/compare compare
GET /api/sessions/{session_id}/export export_csv
POST /api/sessions/{session_id}/pair-order/save save_pair_order
POST /api/sessions/{session_id}/pair-order/load load_pair_order
POST /api/sessions/{session_id}/comparison-snapshot/save save_comparison_snapshot
POST /api/sessions/{session_id}/comparison-snapshot/load load_comparison_snapshot

The route constants live in /Users/vriesd/projects/csv-align/src/api/app.rs and are mirrored by /Users/vriesd/projects/csv-align/frontend/src/services/apiRoutes.ts. See HTTP API and transport parity for the full contract.

Body limits

Route Limit behavior Source
CSV upload Axum body limit is MAX_CSV_FILE_BYTES * 2, and the multipart reader rejects file bytes over 25 MiB. /Users/vriesd/projects/csv-align/src/api/app.rs, /Users/vriesd/projects/csv-align/src/api/handlers.rs, /Users/vriesd/projects/csv-align/src/backend/workflow.rs
Comparison snapshot load Axum body limit is MAX_CSV_FILE_BYTES * 4. The request body carries snapshot contents as JSON. /Users/vriesd/projects/csv-align/src/api/app.rs, /Users/vriesd/projects/csv-align/src/backend/requests.rs
Other JSON routes No route-specific custom body limit is set in the app router. /Users/vriesd/projects/csv-align/src/api/app.rs

Static frontend serving

frontend_dist_path() checks for built frontend assets next to the executable first, then under the current working directory. If neither path exists, startup fails with an error that instructs contributors to run cd frontend && npm run build.

The static fallback uses tower_http::services::ServeDir with append_index_html_on_directories(true), so the React app can own browser-side navigation while API paths stay reserved for Axum.

Related pages

Key source files

File Purpose
/Users/vriesd/projects/csv-align/src/main.rs Initializes logging, creates app state, resolves frontend assets, and starts the Axum listener.
/Users/vriesd/projects/csv-align/src/api/app.rs Builds the API router, applies route body limits, and wires static frontend fallback serving.
/Users/vriesd/projects/csv-align/src/api/handlers.rs Implements HTTP handlers and response attachments.
/Users/vriesd/projects/csv-align/src/api/state.rs Wraps the shared session store for Axum state.
/Users/vriesd/projects/csv-align/frontend/src/services/apiRoutes.ts Frontend HTTP route templates and path builders.
/Users/vriesd/projects/csv-align/frontend/src/services/tauri.ts Browser-mode HTTP calls and browser-side file size checks.
/Users/vriesd/projects/csv-align/frontend/package.json Frontend build script used before running the local web app.

Clone this wiki locally