-
Notifications
You must be signed in to change notification settings - Fork 24
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.
- Java 8
- Dropwizard for main REST server app
- MySQL for database
- JPA implemented with Hibernate for ORM
- Caffeine for cache
- Dagger for dependency injection
- Immutables for objects immutability
- Guava for collections
Judgels adapts the database design explained here: Phabricator Database Schema. In particular:
- Here, by "objects" we mean objects as in REST resources. For example: users, problems, contests.
- Each object in Judgels has a database-generated auto-increment ID. We don't use this ID for referencing objects.
- Instead, each object in Judgels has a unique identifier called JID (Judgels ID) in the form of JIDXXXXYYYYYYYYYYYYYYYYYYYY, where X is object type code and Y is a shortened UUID. For example: JIDUSER7uMucIkm1exJTu7sJvxR.
- JIDs as unique identifiers enables easy backup or migration between different Judgels app instances.
- In addition to JID, each object may have user-friendly ID. For example: usernames, problem slugs, contest slugs.
- Complex properties 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.
-
Service: declares the REST API endpoints. Example:
ContestService
. -
Resource: implements the REST API endpoints. Example:
ContestResource
. -
Role checker: authorizes REST API calls. Example:
ContestRoleChecker
. -
Store: manages CRUD operations of business objects. Example:
ContestStore
. -
Dao: declares the CRUD operations in database. Example:
ContestDao
. -
HibernateDao: implements the CRUD operations in database. Example:
ContestHibernateDao
. -
Model: represents a row in a database. Example:
ContestModel
.