Monza Motors uses Supabase for three core concerns: authentication (sign-up, login, and session management viaDocumentation 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.
@supabase/ssr), the vehicle database (the vehiculos and fabricas tables queried throughout the collection and detail pages), and real-time AI chat messaging (the messages table, which streams assistant replies to the browser). You’ll need to create four tables and configure Row-Level Security before the app works end-to-end.
Create a Supabase project
Create a new project
Go to supabase.com, sign in, and click New project from your organization dashboard. Give the project a name (e.g.,
monza-motors), set a strong database password, and save it somewhere safe — you’ll need it if you ever connect directly via psql.Choose a region
Select the region closest to the majority of your users to minimize database query latency. For a globally distributed user base, choose a central region such as
us-east-1 (N. Virginia) or eu-west-1 (Ireland).Required tables
All four tables below should be created using the SQL Editor in the Supabase dashboard (Database → SQL Editor → New query). Run each block independently so you can catch and fix errors one step at a time.Create the fabricas table
The
fabricas (factories/manufacturers) table stores information about each vehicle manufacturer and their production plant. Each vehicle in the vehiculos table references a row here via fabrica_id.Create the vehiculos table
The
vehiculos (vehicles) table is the heart of the Monza Motors catalogue. It stores all technical specifications, pricing, and media URLs. The collectionClient.js service queries this table for the collection grid, year-based filters, and individual vehicle detail pages.Create the stored table
The
stored table holds additional media URLs (e.g., gallery images or videos) linked to a specific vehicle. The detail page query joins this table via stored(*) when fetching a vehicle by ID.Enable Realtime
The AI chat UI subscribes to new rows in themessages table so that assistant replies appear in the browser without a page refresh. Realtime must be explicitly enabled on this table.
Enable Realtime in the dashboard
In the Supabase dashboard, go to Database → Replication. Under Tables, find the
messages table and toggle Realtime on.Row-Level Security policies
Enabling Row-Level Security (RLS) ensures that users can only access the data they’re allowed to see. Run the following SQL block in the SQL Editor to configure all necessary policies across the four tables.The AI chat API route uses
SUPABASE_SERVICE_ROLE_KEY to initialise its Supabase client, which bypasses RLS entirely. This is intentional — it allows the server-side route to insert assistant messages on behalf of any user without needing to impersonate their session. Never expose SUPABASE_SERVICE_ROLE_KEY to the browser or commit it to source control.Retrieve API keys
Three environment variables must be copied from Supabase into your Vercel project settings (or your local.env.local file).
| Variable | Location in Supabase Dashboard |
|---|---|
NEXT_PUBLIC_SUPABASE_URL | Settings → API → Project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Settings → API → Project API keys → anon / public |
SUPABASE_SERVICE_ROLE_KEY | Settings → API → Project API keys → service_role |
Seed sample data
Once the tables and policies are in place, insert at least one manufacturer and one vehicle before testing the UI. The collection page renders an empty grid ifvehiculos contains no rows.