How detalhe/vehicle-ai works
Project type and purpose
• This is a full-stack web application.
File structure
• Top level
• index.js (Express server entrypoint)
• package.json / package-lock.json (dependencies)
• .env (holds GOOGLE_API_KEY)
• vercel.json (Vercel deployment config)
• public/ (client-side static assets)
• css/index.css
• js/script.js
• img/ (logos, defaults)
• views/ (EJS templates)
• index.ejs (renders upload form + results)
README for additional insights
• Frameworks: Node.js, Express, EJS
• Uses multer for file uploads, uuid for temp filenames, axios for HTTP calls to @google/generative-ai.
• Deployable on Vercel.
Main components & interactions
a. Frontend (Browser)
• Image upload widget (drag-and-drop or file select)
• New: Text inputs for “Make” and “Model” override or supplement AI results
• Trigger: form submission → HTTP POST /analyze
b. Web Server (Express)
• Route POST /analyze
– multer middleware saves image locally or in memory
– Reads user-entered make/model fields
– Constructs request: image + optional user inputs
– Calls Google Gemini API via @google/generative-ai client
– Merges AI output with user overrides if provided
– Renders views/index.ejs with full result payload
c. External Service
• Google Gemini AI endpoint
d. Static Assets Server
• Serves CSS, JS, default/preview images, and manufacturer logos
Architectural patterns & design principles
• MVC-style separation:
• Model: external AI response + user input
• View: EJS template
• Controller: Express route handlers
• Single process server; no microservices
• Third-party integration via well-encapsulated API module (axios + @google/generative-ai)
• Stateless requests; can horizontally scale behind a load balancer
Incorporating the “add user input for make and model” feature
• Text input fields labeled “Make” and “Model”.
• In the flow, show these fields being packaged along with the image in the HTTP POST to the Express server.