Skip to main content

Introduction

The SGD-MCS backend is built on Google Apps Script and provides a comprehensive API for managing academic entities, documents, and file storage through Google Drive and Google Sheets.

Architecture

The backend is organized into specialized services:
  • EntityManager: Universal CRUD operations for all database entities
  • DriveManager: Automated folder structure and Drive integration
  • DriveFileManager: Advanced file and folder operations
  • SearchService: Universal search across database entities
  • DataService: Bulk data retrieval for listings

Calling the API

All backend functions are accessed via google.script.run from the frontend:
// Example: Create a new student
google.script.run
  .withSuccessHandler((response) => {
    if (response.success) {
      console.log('Created:', response.id);
    }
  })
  .withFailureHandler((error) => {
    console.error('Error:', error);
  })
  .createItem('estudiante', {
    Nombre1: 'Juan',
    Apellido1: 'Pérez',
    Cedula: '1234567890',
    Cohorte_Ingreso: '2024-1'
  });

Response Format

Most API functions return a standardized response object:
{
  success: true,        // Boolean indicating operation success
  message: 'Created',   // Human-readable message
  id: 'EST0001',        // Entity ID (when applicable)
  // ... additional data
}
Some services (SearchService, DataService) return JSON strings that need to be parsed:
const results = JSON.parse(response);

Entity Types

The system supports five main entity types:
TypeSpanishID PrefixDescription
estudianteEstudianteESTGraduate students
docenteDocenteDOCFaculty members
externoExternoEXTExternal evaluators
tesisTesisTESThesis projects
eventoEventoEVEAcademic events

Automatic Features

Auto-Generated IDs

All entities automatically receive unique IDs (e.g., EST0001, DOC0042) when created without an ID.

Audit Trail

The system automatically logs:
  • User email
  • Timestamps (creation and last update)
  • Action history for all operations

Drive Integration

Each entity can have an associated Drive folder created automatically with the structure:
Root/
  Estudiantes/
    2024-1/
      EST0001 - Juan Pérez/
  Tesis/
    2024/
      TES0001 - Machine Learning Research/

Getting Started

  1. Create an entity: Use EntityManager.createItem()
  2. Manage files: Use DriveManager to manage folders and files
  3. Search data: Use SearchService.executeSearch()
  4. List entities: Use DataService for bulk retrieval

Error Handling

All functions use try-catch blocks and return error information:
google.script.run
  .withSuccessHandler((response) => {
    if (!response.success) {
      alert('Operation failed: ' + response.message);
    }
  })
  .withFailureHandler((error) => {
    console.error('Script error:', error);
  })
  .createItem('estudiante', data);

Next Steps

EntityManager

Create, update, and delete entities

DriveManager

Manage Drive folders and structure

SearchService

Search across all entities

DataService

Retrieve entity listings

Build docs developers (and LLMs) love