How jagrut-bhole/promptvision works
Project type and purpose
• This is a full-stack web application (“AI Image Generation Website”) that lets users generate AI images via Pollinations AI, authenticate with JWT, and share or browse a community gallery.
• Frontend: React.js + TailwindCSS, served via Vite.
• Backend: Node.js + Express.js, using MongoDB + Mongoose, with JWT/bcrypt for authentication.
File structure
• Top level: two directories, client/ and server/.
• client/ contains a React/Vite app:
– src/components (UI components, pages under src/pages), src/services/api.js for Axios calls, src/contexts/AuthContext, src/hooks/useAuth.
– Build config: vite.config.js, package.json, etc.
• server/ contains an Express API:
– src/routes (auth.routes.js, image.routes.js)
– src/controllers (user.controllers.js, image.controllers.js)
– src/models (user.models.js, image.models.js)
– src/middlewares (auth.middlewares.js)
– src/db (Mongo connection), src/utils (apiError, apiResponse, asyncHandler)
– Entry point: src/index.js → app.js
• Config files: .env for server settings (port, CORS, JWT secrets, Mongo URI).
README for additional insights
• Tech stack, features, API endpoints, project structure.
• Mentions external dependency: Pollinations AI.
a. Main components
– Frontend (React App)
– Backend API (Express Server)
– Database (MongoDB)
– External AI Service (Pollinations API)
– Authentication layer (JWT, bcrypt)
b. Relationships & interactions
1. User’s browser → React UI
2. React UI uses Axios to call Backend REST API endpoints (/api/auth/*, /api/images/*).
3. Backend:
• Auth routes → auth.middleware validates/refreshes JWT → controllers handle register/login/logout → Mongoose persists/fetches users.
• Image routes → controllers call Pollinations API to generate images → stored in Mongo, returned to client.
– UI → API (HTTP request/response)
– API → MongoDB (read/write)
– API → External AI Service (HTTP)
c. Architectural patterns
– Layered backend: routes → controllers → models → database.
– Middleware pipeline: CORS, JSON parsing, auth validation.
– Component-based frontend: pages, reusable UI components, context for auth state.
d. Key technologies to label
– Frontend: React.js, TailwindCSS, React Router, Axios, Framer Motion
– Backend: Node.js, Express.js, Mongoose, JWT, bcrypt
– Database: MongoDB
– External Service: Pollinations AI
Detailed steps for the principal software engineer
• From Browser → API (include HTTP: GET/POST).
• From API → MongoDB (CRUD).
• From API → Pollinations AI (POST prompt → image).
• Blue for frontend, green for backend, yellow for DB, orange for external.