This is an example application used to demonstrate how to deploy an application using various different managed cloud services. The application generates 1024x1024 images from text descriptions with FLUX.2 klein 4B model (or a built-in generator when the AI generator is not available) and stores the images in object storage using a database to keep track of available images and their states.
The following instructions will help you get the application up and running locally.
For IaC configuration that deploys the application using UpCloud managed services, see iac/tf/ directory.
docker compose up --buildOpen http://localhost:5173. This starts the database, object storage, backend, and frontend. Images are generated by the backend with the built-in builtin/text-on-shapes generator, which draws the description on top of random shapes.
To generate images with the FLUX.2 klein 4B model, also start the AI generator by enabling the generator profile:
docker compose --profile generator up --buildThe generator runs on CPU in Docker, which is slow. The backend uses the AI generator while it polls for pending images, and falls back to the built-in generator if the AI generator has not polled within the last minute.
To use the Apple Silicon GPU (MPS), run the generator natively and everything else in Docker Compose (requires Python 3.10+):
./scripts/run-local-generator.sh| Variable | Description | Default |
|---|---|---|
GENERATOR_TOKEN |
Shared token between the backend and the generator | local-generator-token |
HF_TOKEN |
Hugging Face token for model downloads | |
IMAGE_DEVICE |
auto, cpu, cuda or mps |
auto |
Backend tests use the Compose database and object storage with a separate images_test table and images-test bucket:
docker compose up -d db storage
cd backend
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/python -m unittestFrontend tests:
cd frontend
npm install
npm testEnd-to-end tests use Playwright to generate, view, list, and delete images in a browser, using the built-in generator. They run in containers with the test profile:
docker compose --profile test run --build --rm testThis starts the database, object storage, backend, and frontend if they are not already running, and runs the tests against the frontend. The services are left running afterwards. The tests create images through the UI and delete them again when they finish. They only delete the images they created and check that these are gone, so existing images are never modified or deleted. The Playwright report and traces of failed tests are written to test/playwright-report and test/test-results.
The tests require the built-in generator, so no AI generator may be running. If one has polled the backend within the last minute, the tests fail before creating anything and say so. Stop the generator and try again after a minute.
To test the AI generator instead, start it and set WAIT_FOR_AI_MODEL to any non-empty value:
docker compose --profile generator up -d --build
WAIT_FOR_AI_MODEL=1 docker compose --profile test run --build --rm testThe tests then wait up to 30 minutes for an AI generator to poll the backend (the model may still be loading) and check that the images were generated with the model it reports. Generating images with an AI model is slow, so the timeouts are longer in this mode.
To explore, run, and debug the tests with Playwright UI mode, run Playwright on your machine against the application. Start the application and install Playwright (requires Node.js):
docker compose up -d --build
cd test
npm install
npx playwright install chromiumThen open the UI:
npm run test:uiThe tests use the application at http://localhost:5173 by default. Set the BASE_URL environment variable to test another instance. Use npm test to run the tests headless from your machine and npx playwright show-report to open the report of the last run.