Skip to main content

Oprec Backend

πŸ”Ž Background

Overview​

This service is the Backend API for the RISTEK Open Recruitment website. It acts as the core engine handling user registrations via UI SSO, student profiles, available divisions and specific tasks linked to them, and storing candidate submissions securely.

Stakeholders​

Scope & Boundaries​

  • In Scope: User Profiles, Division listing and tasks, Submissions, SSO/LDAP integration, API authentication, Database models, Admin panel logic.
  • Out of Scope: Frontend application, email delivery mechanism, complex analytics.

βš™οΈ Architecture & Design

System Diagram​

Architecture Decisions (ADRs)​

  • Language/Framework: Python 3.11.3 / Django 3.1.7 / Django Rest Framework
  • Database: PostgreSQL 15 (Relational Data)
  • Communication: Synchronous RESTful API over HTTP, with Token-based Authentication.
  • Documentation Engine: drf_yasg (Swagger/OpenAPI UI integration)
  • Infrastructure setup: Docker managed by docker-compose.yml (dev) and Amazon Elastic Container Registry (ECR).

πŸ’»Technical Specifications

API Documentation​

The application exposes OpenAPI documentation through drf-yasg at /__docs/.

Core routes under /api/:

  • /login/: Handles authentication and generates an auth token.
  • /login-ldap/: Provides an alternate login endpoint through LDAP.
  • /event-deadlines/: Defines registration, selection, and announcement timelines.
  • /profile/: Gets and updates applicant profile information.
  • /date-time/: Syncs server time with the client.
  • /submissions/ and /submissions/<id>/: Handles file task submission URLs linked to divisions.
  • /divisions/ and /divisions/tasks/: Returns available divisions and assignment prompts.
  • /remaining-task/: Returns remaining unsubmitted tasks for each applicant.

Data Model/Schema​

Core entities live under the openrecruitment app:

  • UserProfile: Stores student demographics and assigned priority divisions.
  • EventDeadline: Stores timeline points such as REGISTRATION_START and ANNOUNCEMENT.
  • Division: Stores division names, requirements, descriptions, and deadlines.
  • DivisionInterest and DivisionAchievement: Extends division-specific applicant data.
  • Task: Represents a test assignment tied to a division.
  • Submission: Binds a UserProfile to a Task with an external attachment URL.

Project Structure​

oprec-backend/
β”œβ”€β”€ .github/ # GitHub Actions (e.g., CI/CD deploy-staging.yml to ECR)
β”œβ”€β”€ marvel/ # Django project root module; contains settings.py, WSGI/ASGI configurations, root urls.py, CAS handling core logic.
β”œβ”€β”€ openrecruitment/ # Primary Django App for business logic
β”‚ β”œβ”€β”€ api/ # Submodule for DRF Serializers, API views, and sub-routes
β”‚ β”œβ”€β”€ seeds/ # Database seed information (.json files)
β”‚ β”œβ”€β”€ models.py # Database schema map
β”‚ β”œβ”€β”€ views.py # Core endpoints and business action (login logic)
β”‚ β”œβ”€β”€ admin.py # Django internal admin panel schema maps
β”‚ └── apps.py # Django app definition
β”œβ”€β”€ tests/ # Test suite configurations (using django-nose)
β”œβ”€β”€ Dockerfile # Docker setup logic
β”œβ”€β”€ Makefile # Useful build scripts (`make install`, `make run_dev`)
β”œβ”€β”€ dev.docker-compose.yml # PostgreSQL & Django container layout for dev
β”œβ”€β”€ manage.py # Django binary manager
└── requirements.txt # Python pip dependencies

Components​

  • Django Auth & SSO Module: marvel/etc/cas.py, openrecruitment/views.py

    • Hooks into University SSO and LDAP schemas to issue standard tokens after verification.
  • REST Views: openrecruitment/api/views.py

    • Orchestrates DRF endpoints and applies IsAuthenticated checks across protected backend routes.
  • Settings Module: marvel/settings.py

    • Loads .env via python-dotenv and configures trusted frontend origins through CORS_ORIGIN_WHITELIST.

☁️ Operational Playbook

Infrastructure​

  • Cloud Provider: AWS EC2 Instance (Deployment using manually managed Compose stack).
  • Container Registry: Amazon ECR logic driven by GitHub actions .github/workflows/deploy-staging.yml.
  • Link: [https://api.join.ristek.cs.ui.ac.id]

Environment Variables​

(example)

KeyDescriptionDefault (Dev)Sensitive?
PORTPort mapping8000No
DATABASE_URLFull connection string to remote DB if usedβ€”Yes
DJANGO_ENVApp environment (local/production)localNo
SECRET_KEYSecure Django Cryptographic Keyβ€”Yes
POSTGRES_DBPostgreSQL NameoprecNo
POSTGRES_PORTPostgres host port5432No
POSTGRES_USERDB Userβ€”Yes
POSTGRES_PASSWORDDB Passwordβ€”Yes

πŸ™‹Questions

πŸ—’ List of frequently asked questions or question that need to be answered that is related to this initiative ..