A meticulous daily log of ingestion
Since May 9th 2015, two transatlantic friends have pedantically exchanged information on every evening meal that they have consumed. This is a comprehensive chronicling of that pedantry.
Built in Rust
for Docker,
using PostgreSQL
& Redis
See typescript branch for original typescript version
This is the backend for mealpedant_vue front-end, and is an on-going work in progress.
The backend is a CRUD api application with the following features;
- axum based with tokio async mutlithreading
- Password hashing with argon2
- Weak password resolution & rejection, powered by hibp
- Time based Two-Factor Authentication
- Two-Factor Authentication backup codes
- User sessions using private, encrypted, cookies, with a redis backend
- redis backed login, and/or ip and/or user_id rate limiting
- Automated email templating & sending, using mjml
- User & Admin user accounts
- Restricted User area
- Restricted Admin user area
- strict CORS settings
- Multi-part uploads - for images of meals
- Image conversion, resizing & watermarking
- Customised incoming serde serialization & extraction
- Error tracing
- Redis based cache
- Postgres main data store
- Scheduled automated database backup & encryption
- (attempted complete) test coverage
- Automated github build step
- Fully Dockerized production environment
- Development remote container (using vscode)
- improve backup creation, currently consumes large amount of memory, maybe separate into own container?
See releases
download (x86_64 one liner)
wget https://www.github.com/mrjackwills/mealpedant_api/releases/latest/download/mealpedant_linux_x86_64.tar.gz &&
tar xzvf mealpedant_linux_x86_64.tar.gz mealpedant
Operate docker compose containers via
./run.sh
cargo build --release
cross build --target x86_64-unknown-linux-musl --release
Many of the tests assume a /ramdrive
location is available, ideally this is a tmpfs
mount.
Requires postgres & redis to both be operational and seeded with valid data - init.sql contains database structure, but for food privacy reasons, the full meal data cannot be provided
# Watch
cargo watch -q -c -w src/ -x 'test -- --test-threads=1 --nocapture'
# Run all
cargo test -- --test-threads=1 --nocapture
# Test coverage, requires cargo-llvm-cov to be installed globally
# then: rustup component add llvm-tools-preview --toolchain 1.61.0-x86_64-unknown-linux-gnu
cargo llvm-cov -- --test-threads=1