---
title: "Liga U"
year: "2021"
motto: "Competition Management OLTP"
description: "I developed an OLTP that automates the management processes of competitions, matches and athletes belonging to the \"Liga Deportiva Universitaria de Caracas.\""
stack: ["react", "nestjs", "nodejs", "typescript", "nextjs"]
website: "https://ligauve.herokuapp.com/"
url: "https://rolandoandrade.me/projects/liga-u/"
author: "Rolando Andrade"
---

# Liga U

> Competition Management OLTP

I developed an OLTP that automates the management processes of competitions, matches and athletes belonging to the "Liga Deportiva Universitaria de Caracas."

Year: 2021. Stack: react, nestjs, nodejs, typescript, nextjs. Website: https://ligauve.herokuapp.com/

A university sports league has hundreds of athletes across many sports. Dozens of teams play in tournaments at the same time. Schedules shift when games run late or a field is not available. Most leagues manage all of this with spreadsheets, group chats and a lot of manual work.

The Liga Deportiva Universitaria de Caracas had this exact problem. Administrators spent hours updating records by hand. Coaches could not find accurate rosters. Athletes had no reliable way to check their next match. The information lived in scattered documents that quickly fell out of sync.

I built Liga U to fix this. It is a transaction processing system made for running a sports league.

## Athletes, competitions and matches

Liga U covers three main areas: athletes, competitions and matches.

For athletes, the system tracks registration, team assignments, eligibility and participation history. Administrators can enroll new athletes, move them between teams, and mark them active or inactive for a season.

A competition is an organized tournament with its own rules. Each one has a format, a schedule and a list of teams. The system supports different formats, like round robin, single elimination and group stages.

A match is one game inside a competition. Each match links two teams, tracks the score, records the venue and time, and stores the final result. The system keeps the full history of every match played.

## Why it needed OLTP

OLTP means Online Transaction Processing. It describes systems that handle many small operations where the data must always stay consistent. Banks are the classic example. A sports league has similar needs.

When someone records a match result, several things must happen together. The score updates. The team standings recalculate. Player statistics change. If one of those steps fails, the data no longer agrees with itself. So the system treats them as a single unit that succeeds or fails as a whole.

I built the backend with NestJS, a TypeScript framework that gives structure to Node.js apps. NestJS uses dependency injection and modules to keep code organized. Dependency injection means each part receives the services it needs instead of creating them. That made it easy to keep athlete management, competition logic and match processing separate.

The database layer used transactions. When several records had to change together, they either all saved or all rolled back. There were no half finished states and no orphaned records.

## Competitions as state machines

The competition module had many edge cases. What happens when a team leaves in the middle of a tournament? How do you break ties in the standings? What if a match is postponed?

I modeled each competition as a state machine. It moves through phases: registration, active and completed. Each phase allows only certain operations. You cannot add teams to an active competition. You cannot record results for a completed one.

Scheduling had to be flexible. Administrators could set proposed dates and venues for matches. They could also mark matches as postponed or cancelled. The system tracked both the planned schedule and what really happened.

Standings recalculated automatically when a result changed. The calculation counted wins, losses and ties, plus the tiebreaker rules of each sport. Each competition could use its own point system.

## One athlete, many teams

Athletes belonged to teams, and teams belonged to competitions. That hierarchy made the data model interesting.

An athlete could play for different teams in different sports. A basketball player could also be on the volleyball team. The system tracked each participation separately. So it could answer questions like "How many competitions has this athlete participated in?" or "What is this athlete's record in basketball specifically?"

Eligibility rules added another layer. Some competitions required athletes to keep good academic standing. Others had age limits. The system stored these rules and flagged athletes who did not meet them.

Transfers handled athletes moving between teams. The system kept a history of every team assignment. That history mattered for statistics and for settling disputes about which team an athlete played for in a past match.

## A view for each role

The interface used React with Next.js. Each kind of user needed a different view.

Administrators saw a dashboard of pending tasks: new registrations to approve, matches waiting for results and competitions that needed a schedule. The most urgent items came first.

Coaches saw their team rosters and upcoming schedules. They could look at opponents and past results. Their access was read only, so they stayed informed without changing anything by mistake.

Athletes had the simplest view: their schedule, their team and their own statistics. The layout worked on phones, so they could check it from anywhere.

## When results change later

Sports data has more edge cases than you might expect. A match goes to overtime. A result is appealed and overturned. A team forfeits. An athlete is suspended in the middle of a competition.

Each case needed careful handling. An overturned result had to recalculate the standings and still keep the record of the original result. A forfeit had to tell a no show apart from a disqualification. A suspension had to reach the eligibility checks.

I added audit logging for every change. Each update stored who made it, when, and the previous value. Administrators could review that full history whenever a question came up.

## Staying fast as data grew

League data grew every season: more competitions, thousands of matches, hundreds of athletes. Queries had to stay fast as the tables got bigger.

Database indexes covered the common queries, like finding an athlete's matches, filtering competitions by status and sorting standings by points. I designed the schema for those queries from the start.

Caching helped with expensive calculations. Standings did not need to recalculate on every page load. The system cached them and cleared the cache only when the underlying data changed.

## What the league taught me

Liga U taught me how the rules of a domain drive technical decisions. Sports league rules look simple until you write them in code. Then you find dozens of special cases that real leagues need.

Transactions became second nature. I learned to ask what happens when an operation fails halfway. Database transactions are the safety net, but the code has to be built to use them correctly.

The project also showed me why typed languages help in complex domains. TypeScript caught many errors before the code ran. The types described how the entities relate better than comments ever could.

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