Monza Motors uses four Supabase tables to power the entire platform. The vehicle catalog (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jason-AML/MonzaSport-Nextjs/llms.txt
Use this file to discover all available pages before exploring further.
vehiculos) holds every listing and references manufacturer plant records (fabricas) as well as supplemental media stored in stored. Chat history is persisted in messages, scoped to each authenticated user via a foreign key to Supabase’s built-in auth.users table.
Tables
vehiculos — Vehicle Catalog
The primary table. Every vehicle listing in the /collection route is sourced from here.
| Field | Type | Description |
|---|---|---|
id | uuid | Primary key |
nombre_vehiculo | text | Vehicle display name (e.g. “Apex GT-R”) |
modelo | text | Model name / trim level |
anio | integer | Model year — used by getCollectionByYear() to filter listings |
precio | integer | Price in USD |
motor | text | Engine type or displacement (e.g. “4.0L Twin-Turbo V8”) |
poder_hp | integer | Horsepower output |
aceleracion_0_100 | numeric | 0–100 km/h time in seconds |
velocidad_maxima | integer | Top speed in km/h |
torque_nm | integer | Torque in Newton-metres |
peso_kg | integer | Curb weight in kilograms |
url_img | text | Primary image URL (served from Supabase Storage or remote CDN) |
description | text | Long-form vehicle description displayed on the detail page |
fabricas — Manufacturer Plants
Holds manufacturer and facility metadata. Each vehicle is linked to one plant record.
| Field | Type | Description |
|---|---|---|
id | uuid | Primary key |
fabricante | text | Manufacturer name (e.g. “Apex Motors”) |
nombre_planta | text | Production facility / plant name |
ciudad | text | City where the plant is located |
pais | text | Country of the facility |
stored — Vehicle Media & Metadata
stored rows are fetched as a joined sub-select on vehiculos via stored(*). They hold supplemental media assets or structured metadata records associated with a vehicle.
| Field | Type | Description |
|---|---|---|
(joined via stored(*) select) | — | Additional media files or metadata associated with the parent vehicle record |
The full column definition for
stored is managed in your Supabase project dashboard. Because it is always fetched as stored(*) in a join, any columns you add automatically become available on the vehicle detail response without changing the query.messages — AI Chat History
Stores every message exchanged in the AI chat interface, keyed by authenticated user.
| Field | Type | Description |
|---|---|---|
id | uuid | Primary key |
user_id | uuid | Foreign key → auth.users.id |
role | text | Either 'user' or 'assistant' |
content | text | Full message text |
created_at | timestamptz | UTC timestamp set automatically on insert |
Relationships
vehiculos→fabricas: A vehicle belongs to exactly one manufacturer plant. The join is expressed asvehiculos.select('*, fabricas(*), stored(*)')ingetCollectionById.vehiculos→stored: Thestoredtable is fetched as a nested join on the vehicle detail query. Multiple stored records can be associated with a single vehicle.messages→auth.users:messages.user_idreferences the Supabase-managedauth.userstable, ensuring every message is tied to a verified account.
Row-Level Security
Row-Level Security (RLS) must be enabled on all tables. The following policies are recommended for a production deployment.
messages — users should only access their own chat history:
vehiculos and fabricas — public catalog data, readable by everyone:
Realtime
Supabase Realtime is enabled on themessages table so that AI assistant replies appear in the chat interface instantly — without polling.
The useChat hook in src/hooks/useChat.js subscribes to INSERT events on messages, filtered by the current user’s id:
POST /api/chat route handler writes the assistant’s reply to messages, the Realtime subscription fires immediately and appends the new message to the local state — delivering a live, push-based chat experience.