Fibo Scene Generator is a full‑stack web application that converts natural-language prompts into scene parameters and generates images. It ships with a React + Vite frontend and an Express backend. The project includes a demo mode (no API keys required) and local persistence for generation history.
This README will help you get the project running locally, explain available API endpoints, and highlight the project's logging and persistence behavior.
- Natural-language prompt → structured JSON scene parameters
- Image generation (demo mode uses Unsplash images; production uses OpenAI image API)
- Persistent history stored locally (using
lowdbJSON file) - Clean responsive UI built with Tailwind CSS
- Structured server logging with
winstonand request logging viamorgan
- Frontend: React 18, Vite, Tailwind CSS
- Backend: Node.js (ES modules), Express
- Persistence: lowdb (file-based JSON DB for local use)
- Logging: winston (file + console), morgan (HTTP request logging)
Prerequisites: Node.js 18+ and npm
- Clone the repository
git clone https://github.com/VijayPawar09/Fibo_Scene_Generator.git
cd Fibo_Scene_Generator- Install server dependencies and run the server
cd server
npm install
# create .env (see .env.example or the Env section below)
npm run dev- Install client dependencies and run the frontend
cd ../client
npm install
npm run devOpen the UI at: http://localhost:5173 (Vite will print the exact URL). The backend runs at http://localhost:5000 by default.
Create a .env file in the server/ folder with at least the following keys (an example may be present as .env.example):
DEMO_MODE=true|false— whentrue, the server returns demo Unsplash images instead of calling the image API (useful for local testing)OPENAI_API_KEY=— your OpenAI API key (only required ifDEMO_MODE=false)PORT=— optional (defaults to5000)
Important: Never commit .env or API keys to the repository. The repository contains push-protection rules and secret scanning; do not push secrets.
- History is persisted locally in
server/db.jsonusinglowdb. The controllerserver/controller/historyController.jsreads/writes this file. - Logs are written to
server/logs/combined.logandserver/logs/error.logviawinston. HTTP requests are also logged usingmorgan.
If you want a production-grade DB, replace lowdb with MongoDB / Postgres and update the controller accordingly.
Base URL: http://localhost:5000/api
Endpoints:
-
POST
/api/fibo/generate-image- Body: { description, camera_angle, lighting, color_palette, resolution }
- Response (demo):
{ success: true, data: { image_url, status } }
-
POST
/api/prompt/convert- Body: { prompt }
- Response:
{ success: true, json: { scene, camera, lighting, color_palette } }
-
POST
/api/history/add- Body:
{ prompt, json, imageUrl } - Response:
{ success: true, entry }
- Body:
-
GET
/api/history- Response:
{ success: true, history: [...] }
- Response:
-
POST
/api/generate(alternate route used byclient/src/pages/Generate.jsx)- Body:
{ prompt, size }(demo mode returns an Unsplash URL or production returns a base64 data URL)
- Body:
Example (cURL) — add history:
curl -X POST http://localhost:5000/api/history/add \
-H "Content-Type: application/json" \
-d '{"prompt":"A serene lake at sunset", "json":{}, "imageUrl":"https://..."}'- The server uses
winstonto capture structured logs toserver/logs/and also prints to console. - A global error handler is registered in
server.jswhich returns a 500 JSON response for unhandled errors and logs a stack trace. - HTTP requests are logged (combined format) via
morganand forwarded to thewinstonlogger.
If you see failures when pushing to GitHub, check the logs and make sure .env wasn't accidentally committed — GitHub Push Protection may block pushes containing secrets.
- Server crashes with
lowdb: missing default data— ensureserver/db.jsis present and writable; the server createsdb.jsonautomatically on first run. - Port in use — set
PORTin.envor stop the process using the port (Windows:netstat -ano | findstr :5000thentaskkill /PID <pid> /F). - Demo images not appearing — confirm
DEMO_MODE=trueinserver/.env.
If you run into issues, check server/logs/combined.log and server/logs/error.log for details.
Contributions are welcome! Please open issues or pull requests. When contributing:
- Keep secrets out of commits (use
.envfiles) - Run the server and client locally and verify no regressions
- Format code consistently (Prettier / ESLint if available)
This project is available under the MIT License.
If you'd like, I can also generate a CONTRIBUTING.md, .env.example, and a short developer checklist. Want me to add those now?