Skip to content

Dev's Guide: Backend basic concepts

Ashar Fuadi edited this page Aug 10, 2018 · 17 revisions

This section explains the basic knowledge required for understanding Judgels codebase on the backend side.

Tech stack

Database design

Judgels adapts the database design explained here: Phabricator Database Schema. Some highlights:

  • Each object in Judgels has a JID (Judgels ID) in the form of JID-XXX-YYYYYYYYYYYYYYYYYYYY, where X is object type code and Y is a shortened UUID.
  • No foreign keys, since we want that objects can be migrated between different Judgels app instances.
  • Properties that have complex structure are stored either on disk database as JSON strings. For example: grading result details.

Additionally, each object may have the following columns:

  • createdBy, createdAt, createdIp: user, time, and IP when this object is created.
  • updatedBy, updatedAt, updatedIp: user, time, and IP when this object is updated.

Application layers

  1. Service: declares the REST API endpoints. Example: ContestService.
  2. Resource: implements the REST API endpoints. Example: ContestResource.
  3. Role checker: authorizes REST API calls. Example: ContestRoleChecker.
  4. Store: manages CRUD operations of business objects. Example: ContestStore.
  5. Dao: declares the CRUD operations in database. Example: ContestDao.
  6. HibernateDao: implements the CRUD operations in database. Example: ContestHibernateDao.
  7. Model: represents a row in a database. Example: ContestModel.