How kaiofelps/rust-e2e-test-poc works
Project Type and Purpose
• This is a full-stack “todo list” proof-of-concept application, built to demonstrate asynchronous end-to-end tests of HTTP endpoints (views and actions).
• The front end is a React/Inertia/Vite application written in TypeScript; the back end is a Rust web server using SQLx (or SeaORM patterns) for persistence and Inertia for view rendering. Docker Compose orchestrates the Postgres database and any other services.
High-Level Architecture
• The system splits cleanly into four main layers:
a. Client (React/Inertia front end)
b. HTTP/API Layer (Rust controllers & DTOs via Inertia)
c. Domain & Service Layer (Rust domain entities, repositories, services)
d. Infrastructure & Data Layer (SQLx repos, Postgres, session store)
File-Structure Indicators
• Top-level:
• www/ – front-end source (React components, pages, layouts, types)
• src/ – Rust back-end source (common, config, domain, infra, main.rs)
• migrations/ – SQL migrations for Postgres schema
• compose.yaml – Docker Compose specification (Postgres container)
• GitHub workflows – CI pipelines (unit tests, integration/E2E tests)
• Clean Architecture pattern: domain/entities → domain/services → infra/repositories → infra/http/controllers.
Components
A. Front-End Client
• Vite Dev Server (www/app.tsx → pages & components)
• Inertia Client Adapter (JavaScript communicates via X-Inertia headers)
B. Back-End Server
• HTTP Entry Point (src/main.rs)
• Controllers & Presenters (src/infra/http/controllers & presenters)
• DTOs (src/infra/http/dtos)
• Session Middleware (file-based sessions under src/infra/sessions)
C. Domain & Business Logic
• Entities (src/domain/entities)
• Services (create, fetch paginated) under src/domain/services
• Repositories Interfaces (src/domain/repositories)
D. Persistence
• SQLx Repository Implementations (src/infra/sqlx/repositories)
• Migrations and Postgres DB (Docker container)
E. Testing & CI
• Cargo Tests (unit & integration under tests/)
• E2E Tests (GitHub workflow, uses Docker Compose test DB)
Interactions and Data Flow
1. User Action in Browser → HTTP Request (Inertia X-Inertia header)
2. Routing in Rust (actix-web or similar) → Controller
3. Controller extracts DTO, calls Domain Service
4. Domain Service invokes Repository Interface → SQLx adapter → Postgres
5. Query result → Domain Entity → Presenter → Inertia Response (JSON + page props)
6. Front end hydrates React components with returned props
Architectural Patterns & Principles
• Clean Architecture / Hexagonal: separation of concerns (domain vs. infra)
• Dependency inversion: domain defines interfaces, infra provides implementations
• Inertia “single-page” server-driven UI, eliminating a standalone REST layer
• Session management via middleware chain
Technologies & Frameworks
• Front end: React, TypeScript, Vite, Inertia.js
• Back end: Rust (actix-web or Rocket), SQLx, rstest (for fixtures), dotenv, file-based sessions
• Database: Postgres (Docker Compose)
• CI: GitHub Actions (unit + integration + e2e workflows)