Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DerBasilisk/SEA-ServicioEvaluaconAsistida/llms.txt

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

Sealearn is a split-stack application: the Express API (backend) and the React + Vite client (frontend) are deployed independently. The backend can run on any Node.js 18+ host — Railway, Render, Fly.io, a bare VPS, or a Docker container — while the frontend is optimised for Vercel and ships with a vercel.json rewrite rule that ensures React Router works correctly for all client-side routes. This guide walks through both deployments in order, then covers OAuth callback registration, production environment variables, and database seeding.

Backend Deployment

Requirements

RequirementMinimum version / notes
Node.js18 LTS or later
MongoDBAtlas M0 free tier or self-hosted 6.x+
RedisUpstash free tier, Redis Cloud, or self-hosted 6.x+
1
Provision external services
2
Before deploying the API itself, make sure the three stateful services are ready:
3
  • MongoDB — Create a MongoDB Atlas cluster and copy the SRV connection string. Whitelist your backend host IP in the Atlas Network Access panel (or use 0.0.0.0/0 for managed platforms that do not expose a stable egress IP).
  • Redis — Create an Upstash Redis database and copy the rediss:// URL from the connection details page. Upstash’s free tier is sufficient for development and low-traffic production workloads.
  • Cloudinary — Create a free account and note your cloud name, API key, and API secret from the dashboard.
  • 4
    Set environment variables
    5
    Set every variable listed in the Environment Variables reference on your hosting platform. The minimum set required for the backend to start and serve all routes in production is:
    6
    PORT=8080
    MONGODB_URI=mongodb+srv://...
    REDIS_URL=rediss://...
    JWT_SECRET=<long-random-string>
    CLIENT_URL=https://your-app.vercel.app
    CLIENT_URL_WWW=https://www.your-app.vercel.app
    FRONTEND_URL=https://your-app.vercel.app
    BACKEND_API=https://your-api.domain
    GROQ_API_KEY_1=gsk_...
    GEMINI_API_KEY=AIzaSy...
    RESEND_API_KEY=re_...
    RESEND_FROM=SEA <noreply@yourdomain.com>
    CLOUDINARY_CLOUD_NAME=...
    CLOUDINARY_API_KEY=...
    CLOUDINARY_API_SECRET=...
    GOOGLE_CLIENT_ID=...
    GOOGLE_CLIENT_SECRET=...
    GOOGLE_CALLBACK_URL=https://your-api.domain/api/auth/google/callback
    DISCORD_CLIENT_ID=...
    DISCORD_CLIENT_SECRET=...
    DISCORD_CALLBACK_URL=https://your-api.domain/api/auth/discord/callback
    
    7
    Deploy and start the server
    8
    The production start command is:
    9
    node server.js
    
    10
    For local development with automatic restarts on file changes, use the dev script which runs nodemon:
    11
    npm run dev
    
    12
    On platforms like Railway or Render, point the start command to node server.js. The server will connect to MongoDB first and only begin accepting HTTP traffic after the database connection succeeds.
    13
    Verify the health check
    14
    Once the server is running, confirm it is accepting requests by calling the health endpoint. A successful response looks like this:
    15
    curl https://your-api.domain/api/health
    
    16
    {
      "ok": true,
      "message": "SEA API corriendo",
      "timestamp": "2025-01-15T12:00:00.000Z"
    }
    
    17
    Use this endpoint as your platform’s health-check probe. On Railway, Render, and Fly.io you can configure it under the service health-check settings so the platform automatically restarts unhealthy instances.
    18
    Seed the database
    19
    Run the subject and shop seed scripts once after the first deploy (or after wiping the database). These scripts connect to MONGODB_URI and insert the default curriculum data that the frontend expects:
    20
    node seeds/seedSubject.js
    node seeds/seedShop.js
    
    21
    Do not run the seed scripts against a production database that already has live user data — they are designed for initial setup and may overwrite existing records.
    22
    Configure CORS
    23
    Set CLIENT_URL and CLIENT_URL_WWW to your Vercel deployment domain. The CORS middleware in server.js builds its allow-list from these two values plus a dynamic regex that also permits any preview deployment URL matching https://sea-frontend*.vercel.app:
    24
    // server.js (excerpt — do not edit, shown for reference)
    app.use(cors({
      origin: [
        process.env.CLIENT_URL || "http://localhost:5173",
        process.env.CLIENT_URL_WWW || "http://localhost:5173",
        /https:\/\/sea-frontend.*\.vercel\.app$/
      ],
      credentials: true,
    }));
    
    25
    If your Vercel project slug does not start with sea-frontend, add your exact domain to CLIENT_URL and requests will still be allowed.

    OAuth Callback URLs

    After deploying the backend, register the following callback URLs in each OAuth provider’s developer console. The paths are fixed and must match exactly.

    Google

    1. Open the Google Cloud ConsoleAPIs & ServicesCredentials.
    2. Edit your OAuth 2.0 client and add the following to Authorised redirect URIs:
    https://your-api.domain/api/auth/google/callback
    
    1. Set GOOGLE_CALLBACK_URL on the backend to the same value.

    Discord

    1. Open the Discord Developer Portal → your application → OAuth2.
    2. Add the following to Redirects:
    https://your-api.domain/api/auth/discord/callback
    
    1. Set DISCORD_CALLBACK_URL on the backend to the same value.
    OAuth providers reject redirects to URLs that are not explicitly registered. If you change your API domain, update the callback URLs in both the provider console and the corresponding backend environment variables simultaneously, otherwise all OAuth logins will fail with a redirect-mismatch error.

    Production Checklist

    Use this checklist before going live:
    [ ] MONGODB_URI points to a production Atlas cluster (not a dev/test cluster)
    [ ] REDIS_URL is set and the connection is verified
    [ ] JWT_SECRET is at least 32 random characters and not shared with any other environment
    [ ] CLIENT_URL and CLIENT_URL_WWW are set to the production Vercel domain
    [ ] GOOGLE_CALLBACK_URL and DISCORD_CALLBACK_URL match the registered redirect URIs
    [ ] RESEND_FROM uses a domain verified in the Resend dashboard
    [ ] At least one of GROQ_API_KEY_1/2/3 or GEMINI_API_KEY is set
    [ ] Seed scripts have been run once: node seeds/seedSubject.js && node seeds/seedShop.js
    [ ] VITE_API_URL and VITE_SOCKET_URL are set in the Vercel project environment variables
    [ ] GET /api/health returns { ok: true } from the production URL
    

    Build docs developers (and LLMs) love