This is a fork from comfyui-api which acts as a wrapper that facilitates using ComfyUI as a stateless API, either by receiving images in the response, or by sending completed images to a webhook. Currently, this project runs locally, so I am not using any webhook features.
This project is a simple in-progress portfolio website that recreates portions of my current website using Typescript, Fastify, React, HTML, CSS. My primary goal was running ComfyUI as a backend, using a custom JSON workflow with locally-run Flux model based on ComfyUI MileHighStyler, with an Image Generator page as a React frontend.
Since I do not include my original handdrawn artwork in this Github repo, I include a video walkthrough of the website, along with a demo of the Image Generator page on YouTube: https://youtu.be/MPYkVqzZrsQ?si=qWhEI2W99cT8E3Sk.
- Node.js 20.18 or higher
- npm or yarn
- ComfyUI installed and configured locally
- If you want to test the sample workflows (under comfyui-api/workflows), have Flux and SD 1.5 models already downloaded
- git clone https://github.com/musemod/Portfolio-comfyui.git
- npm install
- Configure environment variables
- Set up .env (look at env.example)
- Update paths and settings in .env (see src/config.ts for all options)
- Ensure your ComfyUI paths are correctly set
- npm run dev command: This launches both the backend API and React frontend concurrently. See frontend at http://localhost:5173/. You can check backend health and endpoints at http://localhost:3000/docs.
To add your own ComfyUI workflows, you can add them in the comfyui-api/workflows folder. See original comfyui-api for more information on how to correctly add your own JSON ComfyUI workflows.
If I were to deploy this website publicly, several architectural changes would be necessary:
Running ComfyUI locally with Flux models is not viable for a public deployment due to GPU resource constraints and scalability requirements. I would migrate the image generation functionality to use a managed inference provider:
- Hugging Face SDK for Inference (with API) / Serverless Inference - Provides on-demand access to thousands of models including Flux variants, with pay-per-use pricing and automatic scaling
- Replicate - Offers simple API access to community models with built-in queue management
This approach eliminates the need to manage GPU infrastructure while maintaining the ability to use custom workflows through providers that support them.
As a small personal website demonstrating capability, the bare minimum protections against bad actors would include:
- Simple rate limiting with reasonable defaults (e.g., 10 requests per hour per IP)
- Basic authentication using a single shared secret for the image generator page (simple but effective for low-traffic sites)
- Prompt validation to reject obviously malicious inputs (excessive length, suspicious patterns)
- Read-only mode for the rest of the portfolio content with no authentication required
- Environment-based feature flags to quickly disable generation if abuse occurs
- Containerization for consistent deployment across environments
- Model preloading so users don't have to wait for models to load before their first generation
- Monitoring and logging to track usage patterns and detect anomalies
- Database for user data, generation history, and rate limit tracking (optional for small scale)
- CDN for serving static portfolio assets
- Ephemeral image storage with automatic expiration (5-15 minutes). Since users save images directly to their local computers, the server should not persist generated images long-term. This minimizes storage costs, reduces compliance concerns, and aligns with the stateless API philosophy.
These tradeoffs acknowledge that perfect security is impossible and expensive, but reasonable guardrails prevent the most common abuse vectors while maintaining a good user experience.
- SaladTechnologies for the original comfyui-api wrapper
- ComfyUI and its community
- TripleHeadedMonkey for the MileHighStyler custom node