Personal photo gallery web app built with Rust, HTMX, Alpine.js and Tailwind CSS. It has admin authentication and a admin panel to add, delete and edit albums with some storage stats. It currently has my name harded on a few pages, but should be easy to change.
Home page shows a list of album cards, and each album page contains a grid of the images. Images can also be viewed in slideshow mode which uses higher quality images.
- Current Limitations
- Setting Up Environment Variables
- Generating a Hashed Password
- Running the Application
- Tailwind CSS Setup
- Auto-Reloading in Development
- Uploading through the admin panel is slow, although the image processing is very fast.
- Uploading too many images at once can cause a timeout (more > 100 images).
- One or two things could be made more mobile friendly.
Create a .env file in the root of the project with the following variables:
# Database URL (SQLite)
DATABASE_URL=sqlite:photo_gallery.db
# JWT Secret (for authentication)
JWT_SECRET=jwt_secret
# Admin credentials (use src/bin/generate_password.rs to create an
# encryped password, otherwise the password check will fail to match the hashes)
ADMIN_USERNAME=admin
ADMIN_PASSWORD=$argon2id$v=19$m=19456,t=2,p=1$salt$hash
# Auto-reload mode for Minijinja (0 = off, 1 = normal, 2 = fast)
AUTO_RELOAD_MODE=2
# Application environment (development or production)
APP_ENV=development
# Host
HOST=127.0.0.1
# Port the app runs on
PORT=8080Notes:
- Replace
jwt_secretwith a secure secret key for JWT encoding - Replace
$argon2id$v=19$m=19456,t=2,p=1$salt$hashwith a hashed password generated using thegenerate_password.rsbinary - Set
APP_ENVtoproductionwhen deploying the application
The generate_password.rs binary is used to generate a hashed password for the admin user:
- Run the Binary:
cargo run --bin generate_password- Enter a Password:
Enter your password: mysecurepassword
- Copy the Output:
Hashed password: $argon2id$v=19$m=19456,t=2,p=1$salt$hash
- Update .env: Replace the
ADMIN_PASSWORDvalue in the.envfile with the generated hash.
- Set
APP_ENV=developmentin the.envfile - Start the application:
cargo run- The application will be available at
http://127.0.0.1:3000
- Set
APP_ENV=productionin the.envfile - Build the application:
cargo build --release- Run the application:
./target/release/photo-galleryTailwind CSS is used for styling. In development, the Tailwind CDN is used for faster iteration. In production, you need to compile Tailwind CSS into a static file.
- Install Tailwind CSS:
npm install tailwindcss postcss autoprefixer- Generate Tailwind Config:
npx tailwindcss init- Create a Tailwind CSS Input File:
Create a
src/tailwind.cssfile with the following content:
@tailwind base;
@tailwind components;
@tailwind utilities;- Compile Tailwind CSS:
npm run build- Serve the Compiled CSS: Ensure the compiled CSS file (
static/css/tailwind.css) is served by the application.
The application uses Minijinja's auto-reloading feature in development mode. This is controlled by the AUTO_RELOAD_MODE environment variable:
0: Auto-reloading is disabled1: Normal auto-reloading2: Fast auto-reloading (watches template files for changes)
Notes:
- Auto-reloading only works in development mode (
APP_ENV=development) - Set
AUTO_RELOAD_MODE=2for the best development experience
- Tailwind CSS Not Working in Production: Ensure you've compiled Tailwind CSS and set
APP_ENV=production - Auto-Reloading Not Working: Ensure
AUTO_RELOAD_MODEis set to2andAPP_ENV=development - turbojpeg Fails to Build: Ensure that you have CMake installed
- Database Errors: Use
sqlx db createandsqlx migrate runto create a database and run the migrations on it

