Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/andrespaul123/micole-flutter/llms.txt

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

Mi Cole grants access to features and screens based on a role that is returned by the API at login time. Every user belongs to exactly one role, stored in the roles array of the JWT response. The app reads roles[0] from the persisted session and uses it to build a role-appropriate navigation shell and to decide which routes are reachable. Understanding roles is the starting point for every integration, from user provisioning to UI customisation.

How Roles Are Assigned

When the backend authenticates a user it returns a roles array inside the JSON response:
{
  "token": "eyJ0eXAiOiJKV1Qi...",
  "user": {
    "id": 7,
    "name": "María González",
    "email": "maria@school.com"
  },
  "roles": ["director"]
}
The Users model parses this array and the AuthViewModel exposes the first element as the active role:
// lib/feature/login/users.dart

factory Users.fromJson(Map<String, dynamic> json) {
  List<String> rolesList = [];

  if (json['roles'] != null) {
    rolesList = List<String>.from(json['roles']);
  } else if (json['role'] != null) {
    rolesList = [json['role']];
  }

  return Users(
    id: json['user']?['id'],
    name: json['user']?['name'] ?? '',
    email: json['user']?['email'] ?? '',
    token: json['token'] ?? '',
    roles: rolesList,
  );
}
// lib/feature/login/auth_viewmodel.dart

String? get role {
  if (user == null || user!.roles.isEmpty) return null;
  return user!.roles.first; // active role used throughout the app
}
The role is also saved individually to SecureStorage under the role key so it is available immediately on cold start without waiting for a network request.

How the Router Uses Roles

GoRouter in lib/core/router/app_router.dart does not gate individual routes behind role checks — instead the HomeDashboard and MainLayout widgets read AuthViewModel.role and render only the navigation items and links that are appropriate for the signed-in user. A director never sees a link to /colegios (super-admin only), and a estudiante never sees /profesores. The global redirect callback enforces only the authenticated / unauthenticated boundary:
// lib/core/router/app_router.dart

redirect: (context, state) {
  final loggedIn = authViewModel.isLoggedIn;
  final isAuthPage =
      state.matchedLocation == '/login' ||
      state.matchedLocation == '/register';

  if (!loggedIn && !isAuthPage) return '/login';   // protect all app routes
  if (loggedIn && isAuthPage)  return '/home';     // skip login if already in
  return null;
},
authViewModel is passed as refreshListenable so the router re-evaluates the redirect on every notifyListeners() call — including after login, logout, and session restoration.

Role Capabilities

The super-admin has platform-wide authority. This account is created via the registration endpoint (POST /api/auth/register) and is the only role that can provision new schools.Accessible routes:
RouteDescription
/homePlatform dashboard
/colegiosList all tenant schools
/colegios/createCreate a new school
/colegios/:tenantId/modulesEnable or disable feature modules per school
Capabilities:
  • Create, view, and manage all tenant schools on the platform
  • Assign and revoke feature modules for individual tenants (e.g. enable the circulars module for school X)
  • Access the full tenant list and navigate to any school’s configuration
The super-admin does not manage users, subjects, or academic data inside a school. That is the director’s responsibility.

Role Capabilities Summary

The table below provides a condensed side-by-side comparison of what each role can access.
Capabilitysuper-admindirectorprofesorestudiantepadre
Manage schools (tenants)
Configure tenant modules
Manage teachers
Manage students
Manage parents
Manage courses & sections
Manage subjects
Manage academic periods
Enroll students
Publish circulars
View own class roster
Record attendance
Create agenda / exams
Write anecdotal notes
Maintain grade book
View timetable
Submit tasks
Access library
View children’s grades
View children’s attendance
View children’s agenda
View children’s anecdotes

Build docs developers (and LLMs) love