A web application for tracking delegation hours for French works council (CSE - Comité Social et Économique) members. Built with Rust, Rocket, and htmx.
- Track persons with multiple role assignments
- Manage roles with delegation hour allocations
- Date-based role assignments (start and end dates)
- Automatic filtering of expired and future roles
- View all persons and roles in clean table interfaces
- RESTful API for person and role management
- Server-side rendering with Tera templates
- Dynamic interactions with htmx
- SQLite database with sqlx for type-safe queries
- Comprehensive test coverage (44 tests)
- Backend: Rust with Rocket web framework
- Database: SQLite with sqlx for async database access
- Frontend: htmx for dynamic interactions
- Templates: Tera template engine
- Testing: Rocket's test client with in-memory SQLite
- Rust (1.70 or later)
- SQLite
- sqlx-cli (for database migrations)
Install sqlx-cli:
cargo install sqlx-cli --no-default-features --features sqlite- Clone the repository:
git clone <repository-url>
cd deleg- Set up the database:
# Create the database
sqlx database create
# Run migrations
sqlx migrate run- Build the project:
cargo buildStart the server:
cargo runThe application will be available at http://localhost:8000
Web Pages:
GET /people- View all persons with their currently active rolesGET /people/<id>- Edit a person's information and role assignmentsGET /roles- View all roles with delegation hours
API Endpoints:
For complete API documentation including request/response formats and examples, see API.md.
Summary of endpoints:
- Persons: GET, POST, PUT, DELETE
/api/personsand/api/persons/<id> - Roles: GET, POST, PUT, DELETE
/api/rolesand/api/roles/<id>
Run all tests:
cargo testRun tests with output:
cargo test -- --nocaptureFormat code:
cargo fmtRun linter:
cargo clippyCreate a new migration:
sqlx migrate add <migration_name>Run migrations:
sqlx migrate runRevert last migration:
sqlx migrate revertdeleg/
├── migrations/ # Database migration files
├── src/
│ ├── main.rs # Application entry point
│ ├── models.rs # Data models (Person, Role, RoleAssignment)
│ ├── db.rs # Database operations (CRUD)
│ └── routes.rs # HTTP routes and handlers
├── templates/ # Tera HTML templates
│ ├── people.html.tera # List all persons
│ ├── edit_person.html.tera # Edit person form
│ └── roles.html.tera # List all roles
├── Cargo.toml # Rust dependencies
├── API.md # REST API documentation
├── CLAUDE.md # Development guidelines
└── README.md # This file
The application requires a DATABASE_URL environment variable. Create a .env file:
DATABASE_URL=sqlite:./deleg.db
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.