---
title: "Mi Horario UCAB"
year: "2018"
motto: "Schedule Creator"
description: "Project for the \"Reto al ingenio 2018\". Winner of the Best Application award. Application to create schedules."
stack: ["django", "python", "javascript"]
website: "https://github.com/RolandoAndrade/mihorarioucab"
url: "https://rolandoandrade.me/projects/mi-horario-ucab/"
author: "Rolando Andrade"
---

# Mi Horario UCAB

> Schedule Creator

Project for the "Reto al ingenio 2018". Winner of the Best Application award. Application to create schedules.

Year: 2018. Stack: django, python, javascript. Website: https://github.com/RolandoAndrade/mihorarioucab

Repositories:

- [github](https://github.com/RolandoAndrade/mihorarioucab)

Each semester at UCAB, students repeated the same ritual. They opened many browser tabs, compared course sections, checked professor schedules and made sure by hand that nothing overlapped. One mistake meant a conflict that could ruin the whole semester. With hundreds of subjects across dozens of degree programs, finding a valid combination often took hours.

In November 2018, I entered the "Reto al Ingenio" competition with a fix. Mi Horario UCAB is a web application that builds class schedules for you. You pick your degree program and the courses you need. The system generates schedules with no conflicts. The project won Best Application at the competition.

## A calendar you can drag

Mi Horario UCAB opens on a canvas with an empty weekly calendar. It shows time blocks from 7 AM to 6 PM on all seven days. Three floating buttons do the work: add subjects, generate a schedule and download the result.

To add a subject, you choose your degree program from a dropdown. The system loads every course for that program, sorted by semester. Pick "Informatics Engineering" and "Semester III" and you see subjects like Algorithms, Data Structures and Database Systems. Each subject lists all its sections with their professors and time slots.

The most useful part is the random scheduler. After you pick your courses, you click the refresh button and the algorithm runs. It searches the combinations of sections and checks each one for time conflicts. When it finds a valid schedule, it paints each course on the canvas in its own color. If no valid combination exists, it tells you.

You can drag courses around the board to explore other options. Each card shows the subject name and can move. When you are happy, you download the schedule as a PDF to use during enrollment.

## Django behind a canvas

The backend uses Django, a Python web framework, with Django REST Framework for the API. The frontend is plain JavaScript. It draws the schedule grid with HTML5 Canvas, a browser element for drawing shapes and text.

### Subjects and degree programs

The system models university schedules with two main entities: subjects and degree programs. A subject stores everything about one course section. That means its semester, its NRC code, the professor, the course name and the time slots for each day of the week.

Each day stores its times as a simple string with the start and end hours. Monday through Sunday each have their own field. A section that meets Monday and Wednesday from 9 AM to 11 AM stores those times in the Monday and Wednesday columns.

Degree programs have a many to many relationship with subjects. One subject can belong to many programs. This matches how universities share common courses across similar degrees.

### One request fills the screen

The backend has endpoints to read degree programs and subjects. The career endpoint returns all programs with their courses. A separate endpoint returns only the program names to fill the dropdown. Subject endpoints support full CRUD (create, read, update and delete) for administrators.

I used Django REST Framework serializers to shape the JSON responses. A serializer turns database records into data the browser can read. The career serializer nests the subject data inside each program. One request returns everything the screen needs. That means fewer round trips to the server and a simpler frontend.

### Drawing the board

The frontend draws everything on one HTML5 Canvas element. The board has a header row with the days, a left column with the hours and a grid of time cells. I wrote one class for each part. Header draws the top bar. Hours draws the time labels. Board puts the whole layout together.

Course cards are colored rectangles. Each card knows its position, size and color. When the scheduler picks a section, it finds the card's place from the day column and the time row. The card stretches to cover the length of the class.

Colors come from a fixed palette. Each course gets its own color, so you can tell subjects apart on a crowded calendar. A course keeps its color even when you generate a new schedule.

### Backtracking finds a fit

The core of the application is the schedule generator. It uses backtracking. Backtracking is a way to search: try a choice, and if it leads to a dead end, undo it and try the next one.

The algorithm takes one course at a time and tries each of its sections.

1. It checks the section against every course already placed. Two sections conflict if they share any hour on the same day.
2. If the section fits, the algorithm adds it to the working schedule and moves to the next course.
3. If no section of a course fits, it goes back and tries a different section for the previous course.

![The scheduler places one course at a time and goes back when a course has no free section](https://storage.rolandoandrade.me/blog/mi-horario-ucab-backtracking.webp)

This recursive search stops at the first valid schedule. It does not list every possible one. For a typical student schedule with 5 to 7 courses, it finds an answer almost instantly.

The conflict check compares time ranges on matching days. Each section stores start and end hours for the days it meets. The check looks for any overlap.

### A PDF for enrollment day

You can download the schedule with the jsPDF library. The download button takes the current canvas and turns it into a PDF document. Students get a copy of their plan they can carry anywhere.

## Problems along the way

### No API for course data

The university had no public API for course data. I had to scrape the enrollment system, which means reading its pages with code, and format the data for my database. To do that, I had to understand how UCAB organized its course offerings and map it to my simpler model.

### Four characters per class time

Storing class times meant a tradeoff between simple storage and easy math. I stored times as 4 character strings with the start and end hours. The JavaScript code reads these strings and turns them into numbers it can compare to detect conflicts.

### Instant feedback on every move

Users needed to see a change the moment they moved something. The Canvas API redraws quickly. Keeping the state of many interactive pieces in sync still took careful work. Each card tracks its own position, and the board keeps the global layout.

## Built under a deadline

Mi Horario UCAB taught me to build a complete application under competition pressure. I had little time, so I had to choose what mattered. The core feature, automatic schedule generation, worked perfectly. Polish could wait.

I learned that backtracking solves constraint problems well. Scheduling looked hard at first. Breaking it into "try a section, check conflicts, go deeper or go back" made it manageable.

Django and plain JavaScript showed me both sides of web development. Django handles the data models, serialization and API routes. JavaScript makes the interactive frontend. Knowing both layers makes you a better engineer.

Winning Best Application told me the approach worked. Students had a real problem that software could solve. Finding problems like that and building focused tools for them is what software engineering is about.

[Book a call with Rolando](https://rolandoandrade.me/pricing/)
