Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ricardomb-tech/surqo/llms.txt

Use this file to discover all available pages before exploring further.

The Surqo frontend is a Next.js 15 application deployed to Vercel for three reasons: its native GitHub Integration triggers automatic production deploys on every push to master, its edge CDN serves static assets globally from the nearest PoP, and its preview deployment system gives each pull request its own isolated URL for testing before merging. Zero configuration is needed beyond connecting the repository and setting four environment variables.

Deployment Steps

1

Connect the GitHub repository to Vercel

  1. Go to vercel.com and sign in.
  2. Click Add New → Project.
  3. Select Import Git Repository and choose ricardomb-tech/surqo.
  4. Set the Root Directory to frontend (since this is a monorepo with backend/ and frontend/ subdirectories).
  5. Vercel auto-detects Next.js — leave all build settings at their defaults.
2

Configure environment variables

In the Vercel project dashboard, go to Settings → Environment Variables and add the following four variables. Set them for Production, Preview, and Development environments:
NEXT_PUBLIC_API_URL=https://surqo-api.fly.dev
NEXT_PUBLIC_WS_URL=wss://surqo-api.fly.dev
NEXT_PUBLIC_SUPABASE_URL=https://xxxxxxxxxxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=sb_publishable_...
NEXT_PUBLIC_WS_URL must use wss:// (WebSocket over TLS) in production — not ws://. Browsers block unencrypted WebSocket connections on HTTPS pages. For local development, set this to ws://localhost:8000.
3

Deploy

Push any commit to the master branch to trigger an automatic production deploy:
git push origin master
Vercel picks up the push via its GitHub webhook, builds the Next.js app, and deploys to the global edge network within ~60 seconds. You can monitor the build in real time under Deployments in the Vercel dashboard.
4

Configure the custom domain

To serve the frontend from surqo.online instead of the default surqo.vercel.app:
  1. In the Vercel dashboard, go to Settings → Domains.
  2. Add surqo.online and www.surqo.online.
  3. At your domain registrar (e.g. Hostinger), update the nameservers to point to Vercel’s DNS:
ns1.vercel-dns.com
ns2.vercel-dns.com
DNS propagation typically takes 5–30 minutes. Vercel automatically provisions a Let’s Encrypt SSL certificate once the nameservers resolve.
Surqo’s production domain is already configured this way — the Hostinger nameservers point to ns1.vercel-dns.com and ns2.vercel-dns.com.

Preview Deployments

Every pull request targeting master automatically gets its own isolated preview URL in the format surqo-git-<branch>-ricardomb-tech.vercel.app. This lets you test UI changes, verify environment variable behaviour, and share a live link for review — all before any code lands in production. Preview deployments share the same environment variables configured in Vercel’s dashboard.

Route Protection

The /(app)/* routes — dashboard, sensors, farms, alerts, and the AI analysis page — require authentication. This is enforced at the SSR middleware layer before any page renders, so unauthenticated users never receive protected HTML.
frontend/src/middleware.ts
// All routes under /(app)/ require authentication.
// Unauthenticated requests are redirected to /login.
// Supabase SSR reads the session from HTTP-only cookies,
// making the auth check happen on the server before any client JS runs.
export const config = { matcher: ['/(app)/:path*'] }
The middleware uses @supabase/ssr to read the Supabase session from HTTP-only cookies. This means the access token is never exposed to JavaScript on the client, and route protection cannot be bypassed by manipulating client-side state.

Environment Variable Reference

VariableValuePurpose
NEXT_PUBLIC_API_URLhttps://surqo-api.fly.devREST API base URL for all fetch calls
NEXT_PUBLIC_WS_URLwss://surqo-api.fly.devWebSocket base URL for live sensor feed
NEXT_PUBLIC_SUPABASE_URLhttps://xxxx.supabase.coSupabase project URL for auth client
NEXT_PUBLIC_SUPABASE_ANON_KEYsb_publishable_...Supabase anon/public key (safe to expose)
For local development, create a frontend/.env.local file with the same variables, substituting http://localhost:8000 for NEXT_PUBLIC_API_URL and ws://localhost:8000 for NEXT_PUBLIC_WS_URL. This file is gitignored and will never be committed.

Build docs developers (and LLMs) love