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.

The Sealearn backend is configured entirely through environment variables loaded at startup via dotenv. Every service the platform depends on — MongoDB, Redis, OAuth providers, AI inference, file storage, and transactional email — is wired through the values described below. Copy the example block at the bottom of this page into a .env file at the root of the backend/ directory before running the server for the first time.

Server

PORT
number
default:"3000"
The HTTP port the Express server listens on. When deploying to a managed platform (Railway, Render, Fly.io) this variable is usually injected automatically; set it explicitly only when running on a bare VM or container.
CLIENT_URL
string
required
Primary origin of the React frontend, added to the CORS allow-list. During local development this is typically http://localhost:5173 (the default Vite dev-server port). In production set it to your Vercel deployment URL, e.g. https://sealearn.vercel.app.
CLIENT_URL_WWW
string
required
The www. variant of the frontend origin, also included in the CORS allow-list. Set this to the same value as CLIENT_URL if you do not use a www subdomain; leaving it empty causes the server to fall back to http://localhost:5173.
FRONTEND_URL
string
required
The base URL of the frontend used when building OAuth callback redirect URLs after a successful login. This value is appended with a path such as /oauth-success?token=… before the user is redirected from the API back to the browser.
BACKEND_API
string
required
The publicly accessible base URL of the backend API itself (e.g. https://api.sealearn.app). Used by the email service to construct verification and password-reset links that point back to API endpoints.

Database

MONGODB_URI
string
required
Full MongoDB connection string used by Mongoose. Accepts any valid MongoDB URI, including MongoDB Atlas SRV strings (mongodb+srv://…) and local mongodb://localhost:27017/sealearn URIs. The process exits immediately if the connection cannot be established at startup.

Authentication

JWT_SECRET
string
required
Secret key used to sign and verify JSON Web Tokens. Tokens issued by Sealearn are valid for 7 days. Use a randomly generated string of at least 32 characters; never reuse the same value across environments.
GOOGLE_CLIENT_ID
string
OAuth 2.0 client ID obtained from the Google Cloud Console. Required for the Google Sign-In flow (passport-google-oauth20). Leave unset if you are not enabling Google login.
GOOGLE_CLIENT_SECRET
string
OAuth 2.0 client secret paired with GOOGLE_CLIENT_ID. Keep this value out of source control.
GOOGLE_CALLBACK_URL
string
The absolute callback URL registered in the Google Cloud Console, e.g. https://api.sealearn.app/api/auth/google/callback. Must exactly match one of the authorised redirect URIs configured in your OAuth application.
DISCORD_CLIENT_ID
string
Application ID from the Discord Developer Portal. Required for Discord OAuth (passport-discord). Leave unset if you are not enabling Discord login.
DISCORD_CLIENT_SECRET
string
OAuth secret paired with DISCORD_CLIENT_ID.
DISCORD_CALLBACK_URL
string
Absolute callback URL registered in the Discord Developer Portal, e.g. https://api.sealearn.app/api/auth/discord/callback.

AI Services

The AI service uses Groq as its primary inference provider and falls back to Gemini automatically when every Groq key’s circuit breaker is open. You can set any combination of the three Groq key slots — the pool skips keys that are absent or rate-limited. However, at least one Groq key or a Gemini key must be present for AI-powered question generation and evaluation to work.
GROQ_API_KEY_1
string
First Groq API key used to call llama-3.3-70b-versatile. The AI service maintains an internal pool of all three key slots, rotating through them round-robin and protecting each with an independent circuit breaker that opens after 3 consecutive failures and resets after 60 seconds.
GROQ_API_KEY_2
string
Second Groq API key. Having multiple keys significantly increases the sustained request throughput before rate limits are hit.
GROQ_API_KEY_3
string
Third Groq API key. Any key slot left empty is silently filtered out of the pool at startup — there is no requirement to populate all three.
GEMINI_API_KEY
string
Google Gemini API key used to call gemini-2.0-flash. This model acts as the automatic fallback when all Groq keys are exhausted. It is also used directly for theory-slide generation and open-response evaluation in some code paths.

Email

RESEND_API_KEY
string
required
API key for the Resend transactional email service. Used to send account-verification emails (link valid for 24 hours) and password-reset emails (link valid for 1 hour). Without this key neither of those flows will complete.
RESEND_FROM
string
required
The verified sender address used in the from field of outgoing emails, e.g. SEA <noreply@sealearn.app>. The domain must be verified inside your Resend dashboard before emails can be delivered.

File Uploads

CLOUDINARY_CLOUD_NAME
string
required
The Cloudinary cloud name found in your Cloudinary Console. Used to construct upload and delivery URLs for user-uploaded assets such as avatars and lesson media.
CLOUDINARY_API_KEY
string
required
Cloudinary API key paired with CLOUDINARY_CLOUD_NAME.
CLOUDINARY_API_SECRET
string
required
Cloudinary API secret. Required for authenticated upload operations. Keep this out of client-side code and version control.

Real-Time / Cache

Redis is required for full platform functionality. The duel system (real-time 1-vs-1 battles) and friend invite state both depend on Redis for shared in-memory coordination across connections. If REDIS_URL is absent or the connection fails, duel and invite features will not work. Additionally, at least one AI key (GROQ_API_KEY_1 through GROQ_API_KEY_3 or GEMINI_API_KEY) must be set for question generation and evaluation to function.
REDIS_URL
string
required
Full Redis connection URL. Accepts standard redis:// and TLS rediss:// schemes. For managed Redis use an Upstash URL (rediss://…) or the connection string provided by your hosting platform.

Example .env File

Copy this template into backend/.env and fill in your own values. Lines prefixed with # are optional features that can be enabled later.
# ── Server ────────────────────────────────────────────────────
PORT=3000
CLIENT_URL=http://localhost:5173
CLIENT_URL_WWW=http://localhost:5173
FRONTEND_URL=http://localhost:5173
BACKEND_API=http://localhost:3000/api

# ── Database ──────────────────────────────────────────────────
MONGODB_URI=mongodb+srv://<user>:<password>@cluster0.mongodb.net/sealearn?retryWrites=true&w=majority

# ── Authentication ────────────────────────────────────────────
JWT_SECRET=replace_with_a_long_random_secret_string

# Google OAuth (optional – remove if not using Google login)
GOOGLE_CLIENT_ID=your-google-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_CALLBACK_URL=http://localhost:3000/api/auth/google/callback

# Discord OAuth (optional – remove if not using Discord login)
DISCORD_CLIENT_ID=your-discord-application-id
DISCORD_CLIENT_SECRET=your-discord-client-secret
DISCORD_CALLBACK_URL=http://localhost:3000/api/auth/discord/callback

# ── AI Services ───────────────────────────────────────────────
GROQ_API_KEY_1=gsk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
GROQ_API_KEY_2=gsk_yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
GROQ_API_KEY_3=gsk_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
GEMINI_API_KEY=AIzaSy_your_gemini_api_key

# ── Email ─────────────────────────────────────────────────────
RESEND_API_KEY=re_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
RESEND_FROM=SEA <noreply@yourdomain.com>

# ── File Uploads ──────────────────────────────────────────────
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=000000000000000
CLOUDINARY_API_SECRET=your-cloudinary-api-secret

# ── Real-Time / Cache ─────────────────────────────────────────
REDIS_URL=rediss://default:<password>@your-upstash-host.upstash.io:6380

Build docs developers (and LLMs) love