Skip to main content

Prerequisites

Before you begin, make sure you have the following:
  • Node.js 18 or later
  • pnpm (recommended) — or npm/yarn
  • A Supabase project (free tier works)
  • A Groq API key (or OpenAI key) for the Montero AI tutor
  • An email provider: Resend API key or SMTP credentials for Nodemailer
1

Clone the repository

git clone https://github.com/maikerleon/system-student.git
cd system-student
The repository contains two apps:
  • monty-app/ — student, teacher, and tutor-facing application
  • monty-panel/ — admin control panel
2

Install dependencies

Install dependencies for both apps. Run these from the repository root:
cd monty-app && pnpm install
cd ../monty-panel && pnpm install
3

Configure environment variables for monty-app

Create a .env file in the monty-app/ directory:
monty-app/.env
# Supabase — public vars (accessible in browser)
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_PUBLIC_KEY=your-anon-key

# Supabase — private vars (server-side only)
SUPABASE_URL=postgresql://postgres:password@db.your-project.supabase.co:5432/postgres
SUPABASE_SERVICE_KEY=your-service-role-key
SUPABASE_JWT=your-supabase-jwt-secret

# JWT secret — used by both apps, must match
SECRET_KEY=your-strong-random-secret

# AI providers
GROQ_API_KEY=your-groq-api-key
OPENAI_API_KEY=your-openai-api-key

# YouTube Data API v3 (for video recommendations in Montero)
YOUTUBE_API=your-youtube-api-key

# Teacher ID verification service
SCRAPING_API_KEY=your-scraping-api-key

# Email sender address and Resend API key
EMAIL=noreply@yourdomain.com
RESEND_API_KEY=your-resend-api-key

# Public base URL (used in email links and QR codes)
URL_GENERAL=https://yourdomain.com/
SECRET_KEY must be identical in both monty-app/.env and monty-panel/.env. Both apps verify JWT tokens signed with this secret.
SUPABASE_URL is the PostgreSQL connection string (postgresql://...), used for direct database access. PUBLIC_SUPABASE_URL is the Supabase REST/realtime URL (https://...supabase.co).
4

Configure environment variables for monty-panel

Create a .env file in the monty-panel/ directory:
monty-panel/.env
# Supabase — public vars
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_PUBLIC_KEY=your-anon-key

# Supabase — private vars (server-side only)
SUPABASE_URL=postgresql://postgres:password@db.your-project.supabase.co:5432/postgres
SUPABASE_SERVICE_KEY=your-service-role-key

# JWT secret — must match monty-app
SECRET_KEY=your-strong-random-secret

# Email sender address and Resend API key
EMAIL=noreply@yourdomain.com
RESEND_API_KEY=your-resend-api-key

# Public base URL
URL_GENERAL=https://yourdomain.com/
SUPABASE_URL in monty-panel is used by the postgres library for direct PostgreSQL access — required for backup generation (generate-backup endpoint). This is the same PostgreSQL connection string format as in monty-app.
5

Set up the Supabase database

System Student uses the following tables in your Supabase project. Create them via the Supabase SQL editor or migration files:
TablePurpose
usersStudent accounts
tutorsTutor accounts
teachersTeacher accounts
classesClass definitions
adminsAdmin accounts
chat_historyMontero AI conversation records
configSystem-wide configuration
viewsSession/analytics tracking
logsAudit log entries
Row Level Security (RLS) policies should be configured to match your deployment needs. The apps use the SUPABASE_SERVICE_ROLE_KEY for server-side operations, which bypasses RLS.
6

Start the development servers

Open two terminal windows and start each app:Terminal 1 — monty-app (student/teacher/tutor app):
cd monty-app
pnpm dev
The student app runs at http://localhost:5173 by default.Terminal 2 — monty-panel (admin panel):
cd monty-panel
pnpm dev
The admin panel runs at http://localhost:5174 (or the next available port).
7

Create your first admin account

Admin accounts are created directly in the Supabase admins table. Passwords must be hashed with bcrypt before inserting.You can generate a bcrypt hash using Node.js:
hash-password.js
import bcrypt from 'bcrypt';
const hash = await bcrypt.hash('your-password', 10);
console.log(hash); // Insert this into the admins table
Then insert the record in Supabase SQL editor:
INSERT INTO admins (name, last_name, email, password)
VALUES ('Admin', 'Name', 'admin@example.com', '$2b$10$...');
8

Access the platform

With both servers running:
URLApplicationAccess with
http://localhost:5173Student/Teacher/Tutor appStudent, teacher, or tutor account
http://localhost:5174Admin panelAdmin account
After login, the auth hook (hooks.server.ts) reads the u_token cookie, verifies it with SECRET_KEY, and redirects users to their role-specific dashboard:
  • /app/alumno — students
  • /app/maestro — teachers
  • /app/tutor — tutors

Building for production

# Build monty-app
cd monty-app && pnpm build

# Build monty-panel
cd monty-panel && pnpm build
Start the production server for monty-app (which includes start in its scripts):
cd monty-app && node build
Use pnpm preview in either app to preview the production build locally before deploying.

Next steps

Architecture

Understand how the two apps share data and how authentication works

User Roles

Learn about the four roles: student, teacher, tutor, and admin

Admin Panel

Configure the system, manage users, and set up promotions

Montero AI

Explore the AI tutor and how it serves students