ByteCanvas is a full-stack text-to-image app.
- Frontend: React + Vite + Tailwind + shadcn/ui + Zustand
- Backend: FastAPI + Bytez SDK
- Persistence: Supabase REST API (Storage bucket + images table)
- Generate images from prompts using Bytez.
- Save generated image metadata in Supabase.
- Browse recent creations on Home.
- Full History page with:
- search by prompt
- date range filters
- pagination
- delete image
- Image details page with download and delete.
bytecanvas/
client/ # React app
server/ # FastAPI API
- Node.js 20+
- pnpm
- Python 3.12 recommended
- Python 3.14 may cause dependency/runtime issues with some third-party libs.
Copy server/.env.example to server/.env and fill values.
Required:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEYBYTEZ_API_KEY
Important:
SUPABASE_SERVICE_ROLE_KEYmust be the Supabaseservice_rolesecret key.- Do not use
sb_publishable_*orsb_anon_*for backend server operations.
Optional defaults:
SUPABASE_BUCKET=generated-imagesBYTEZ_MODEL=stabilityai/stable-diffusion-xl-base-1.0
By default, the frontend can use Vite proxy in client/vite.config.js, so API requests to /api/* are forwarded to backend on http://127.0.0.1:8000.
If you want explicit backend URL, create client/.env:
VITE_API_BASE_URL=http://127.0.0.1:8000Create storage bucket:
- Name:
generated-images - Public bucket recommended for direct browser image URLs.
Create table: images
idtext primary key (or uuid stored as text)prompttext not nullimage_urltext not nullstorage_pathtext not nullcreated_attimestamptz not nullmetadatajsonb not null
Quick SQL (Supabase SQL Editor):
CREATE TABLE IF NOT EXISTS public.images (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
prompt TEXT NOT NULL,
image_url TEXT NOT NULL,
storage_path TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
model VARCHAR(255)
);
ALTER TABLE public.images ADD COLUMN metadata JSONB;cd server
python -m venv venv
venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m uvicorn app.main:app --reload --host 127.0.0.1 --port 8000Health check:
cd client
pnpm install
pnpm devOpen:
Base prefix: /api/v1
-
POST /generate- Body:
{ "prompt": "A cat in a wizard hat" } - Returns generated image record.
- Body:
-
GET /history?page=1&page_size=12&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD- Returns paginated image history.
-
GET /history/{image_id}- Returns one image record.
-
DELETE /history/{image_id}- Deletes image metadata + storage object.
-
GET /search?q=cat&page=1&page_size=12&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD- Returns paginated filtered records.
/home/historyhistory view/image/:idimage details
See route setup in client/src/routes/AppRoutes.jsx.
Frontend production build:
cd client
pnpm buildBackend compile sanity check:
cd server
venv\Scripts\python.exe -m compileall app- Verify backend terminal logs.
- Confirm server/.env has valid values.
- Ensure
SUPABASE_SERVICE_ROLE_KEYis service role, not publishable/anon.
- Check whether
image_urlis accessible in browser. - Ensure bucket is public if using
/storage/v1/object/public/...URLs. - Ensure uploaded object exists at stored
storage_path.
- Backend is not running on
127.0.0.1:8000. - Start backend first, then refresh frontend.