How luler/reflex_ai_fast works
Project type and purpose
• This is a full-stack web application for “one-click” image generation powered by large language/image models (OpenAI).
• The frontend is a static JS/CSS bundle (exported via Reflex) stored in frontend.zip.
• The backend is a Python service (image_gen_page) exposing API endpoints that proxy requests to the large-model API.
• An Nginx reverse proxy sits in front to serve static assets and route API calls.
File structure
• Top-level Docker and Compose files:
• Dockerfile (build Python backend)
• Dockerfile-nginx (configure Nginx)
• docker-compose.yml (orchestrates nginx + backend)
• config/nginx.conf (routing rules)
• Frontend:
• frontend.zip (Reflex export of the UI)
• assets/ (if unzipped assets are placed here)
• Backend:
• image_gen_page/ (Python package)
– image_gen_page.py (server startup & routes)
– pages/ (handlers for GPT4o, JimEng endpoints)
• requirements.txt (dependencies)
• rxconfig.py (Reflex configuration for export)
• Environment:
• .env (not in repo; user must create with OPENAI_BASE_URL and OPENAI_API_KEY)
• Deployment:
• .dockerignore, .gitignore, .github/workflows/docker-image.yml
Extract README insights
• Two-step install:
1. reflex export --frontend-only to produce frontend.zip.
2. docker-compose up -d to launch nginx + backend.
• The frontend makes API calls to API_URL (127.0.0.1:8080).
• Access via HTTP port 8080.
Main components & interactions
a. Components
• Client (Browser)
• Nginx Reverse Proxy container
• Backend Python container (image_gen_page service)
• External LLM/Image generation API (OpenAI)
b. Data flows
1. User opens http://host:8080/ → Browser GET served by Nginx static root from frontend.zip.
2. In-page JS UI sends HTTP POST to /api/generate (or similar) on same host.
3. Nginx forwards /api/* to the Python backend container.
4. Backend handlers (in image_gen_page/pages) receive request, read prompt, call external model API (OPENAI_BASE_URL + OPENAI_API_KEY).
5. External API returns image or URL → backend returns JSON/image data to client.
6. Browser displays the result.
c. Architectural patterns & principles
• Separation of concerns: static UI vs dynamic API
• Reverse proxy pattern with Nginx (static + API routing)
• Micro-service style (one backend service + one proxy)
• Environment-based configuration (via .env)
d. Key technologies
• Reflex (Python → static frontend export)
• FastAPI/Flask (likely used in image_gen_page)
• Docker & Docker-Compose
• Nginx
• OpenAI API (external service)