Planned backend integration for authentication, real-time data, and cloud storage
The TecNM Control Escolar app is planned to integrate with Supabase as its backend-as-a-service platform. This guide outlines the roadmap and planned features.
Current Status: The app uses FakeData.kt for mock data. Supabase integration is listed in “Próximos pasos” in the README.
// Email/password authenticationval user = supabase.auth.signInWith(Email) { email = "226W0487@tecnm.mx" password = "student_password"}// Or magic link authentication (passwordless)supabase.auth.signInWith(OTP) { email = "226W0487@tecnm.mx" createUser = false}
Features:
Student login with control number
Password reset via email
Session management
Role-based access (student, teacher, admin)
Database Schema: users & profiles
-- Extends Supabase auth.usersCREATE TABLE profiles ( id UUID REFERENCES auth.users PRIMARY KEY, control_number TEXT UNIQUE NOT NULL, full_name TEXT NOT NULL, career TEXT NOT NULL, semester INTEGER NOT NULL, campus TEXT NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW());-- Row-level securityALTER TABLE profiles ENABLE ROW LEVEL SECURITY;CREATE POLICY "Students can view own profile" ON profiles FOR SELECT USING (auth.uid() = id);
CREATE TABLE class_sessions ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), subject TEXT NOT NULL, teacher TEXT NOT NULL, classroom TEXT NOT NULL, day TEXT NOT NULL, start_hour TIME NOT NULL, end_hour TIME NOT NULL, semester TEXT NOT NULL, campus TEXT NOT NULL);CREATE TABLE enrollments ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), student_id UUID REFERENCES profiles(id), class_session_id UUID REFERENCES class_sessions(id), enrolled_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(student_id, class_session_id));-- Students can only see their enrolled classesCREATE POLICY "Students view enrolled classes" ON enrollments FOR SELECT USING (auth.uid() = student_id);
// After scanning QR code with class_session_idval attendance = supabase.from("attendance") .insert(mapOf( "student_id" to currentUser.id, "class_session_id" to scannedClassId, "timestamp" to Clock.System.now(), "status" to "present" ))
Features:
QR code generation by teachers
Geofencing (must be on campus)
Time validation (only during class hours)
Attendance history
Attendance percentage per course
Database Schema: attendance
CREATE TABLE attendance ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), student_id UUID REFERENCES profiles(id), class_session_id UUID REFERENCES class_sessions(id), timestamp TIMESTAMPTZ NOT NULL DEFAULT NOW(), status TEXT NOT NULL CHECK (status IN ('present', 'late', 'absent')), location GEOGRAPHY(POINT), UNIQUE(student_id, class_session_id, timestamp::DATE));CREATE INDEX idx_attendance_student ON attendance(student_id);CREATE INDEX idx_attendance_class ON attendance(class_session_id);
val buildings = supabase.from("buildings") .select() .eq("campus", "Zongolica") .order("name")// Calculate distance from user's locationval userLocation = LocationServices.getFusedLocationProviderClient(context) .lastLocation.await()buildings.forEach { building -> building.distance = calculateDistance( userLocation.latitude, userLocation.longitude, building.latitude, building.longitude )}
Features:
GPS coordinates for each building
Distance calculation from user
Building photos and descriptions
Indoor navigation (future)
Database Schema: buildings
CREATE TABLE buildings ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), name TEXT NOT NULL, description TEXT, category TEXT NOT NULL, campus TEXT NOT NULL, latitude DECIMAL(10, 8), longitude DECIMAL(11, 8), photo_url TEXT);-- Public read access for buildingsCREATE POLICY "Buildings are viewable by everyone" ON buildings FOR SELECT USING (true);
-- Students can only read their own dataCREATE POLICY "Students access own records" ON profiles FOR ALL USING (auth.uid() = id);-- Students can only see their enrolled classesCREATE POLICY "Students view enrolled classes" ON enrollments FOR SELECT USING (auth.uid() = student_id);-- Students can only mark their own attendanceCREATE POLICY "Students mark own attendance" ON attendance FOR INSERT WITH CHECK (auth.uid() = student_id);