WnSOJ is a platform where you can solve programming and math tasks, learn new algorithms and concepts and find job. Platform offers effective testing system, categorized problemset, editorials and solutions, submissions, job search, users and statistics.
Check it out at wnsoj.xyz!
- Backend: Django + Django REST Framework (DRF) + Celery (judge workers)
- Frontend: Next.js (App Router) in
frontend/(Tailwind UI) - Auth (browser): Django session cookies (
sessionid) + CSRF (csrftoken) — no JWT, no localStorage - Internal API: Django
/api/*is not public and is protected by a shared secret header (X-Internal-API-Key)- Next.js server-side requests include the internal key automatically
- Browser-side mutations go through Next.js route handlers under
/backend/*, which proxy to Django and attach the internal key
- Clone:
git clone https://github.com/spike1236/WnSOJ.git
cd WnSOJ- Create a virtualenv (recommended) and install Python deps:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt- Install runtime requirements:
g++isolate(cgroups v2-based)
- Create
.envfrom.env.templateand fill in values:SECRET_KEY,DEBUG, DB settingsINTERNAL_API_KEY(shared with Next.js)CSRF_TRUSTED_ORIGINS(include your local/prod frontend origin, e.g.http://127.0.0.1:8081if you proxy through nginx)
- Apply migrations (and optionally create an admin user):
python3 manage.py migrate
python3 manage.py createsuperuser- Run:
python3 manage.py runserver
celery -A app worker -l infoOpen http://127.0.0.1:8000 (Django-rendered pages) or start the Next.js frontend (below).
In a separate terminal:
cd frontend
npm install
BACKEND_ORIGIN=http://localhost:8000 INTERNAL_API_KEY=dev-secret npm run devOpen http://localhost:3000.
Notes:
INTERNAL_API_KEYmust match the DjangoINTERNAL_API_KEYin.env.- In dev, Next.js will proxy
/admin/,/static/,/media/to Django. Browser API calls use/backend/*route handlers.
See DEPLOY.md.
Platform provides an extensive set of olympiad programming tasks. To submit solution you need to be signed in system. You can register or sign in into existing account and submit solutions to problems. The testing system runs in parallel with server using Celery worker. You can use Redis, RabbitMQ or Amazon SQS as a broker for Celery worker (more info here; personally, I use Redis).
System will automatically test your solution in isolated sandboxes provided by isolate and report verdict, max used time and max used memory.
Also, each problem has editorial and solution in C++ language.
Platform administrators can add new problems.
In the platform you can also find or publish/edit/delete job. There are 2 types of accounts:
- Common account - these users can find job and communicate with employers by email or phone.
Open job that you liked, read the description and if job suits you, communicate with employer by email or phone. - Business account - these users or companies can publish, edit or delete jobs, also find and communicate by email or phone with other users.
Publish job, edit it if it is need, and just wait until some qualified specialist will communicate with you by email or phone number.
In the profile, you can see user's username, email, phone number and statistics about problems: submissions statistics and last 10 attempts.
Also you can change your icon or password in 'Edit profile' page.
The Django REST endpoints under /api/* are intended for internal use (Next.js server + nginx private connectivity) and are protected by INTERNAL_API_KEY. Requests without the correct X-Internal-API-Key receive 404.
The browser should talk only to the Next.js app. Client-side mutations use Next.js /backend/* route handlers which proxy to Django and attach the internal key.
Recommended approach:
- Public: Next.js on
/ - Public: Django on
/admin/,/static/,/media/ - Do not expose Django
/api/publicly (it is protected, but should still be treated as internal-only)
Set env vars:
- Django:
INTERNAL_API_KEY - Next.js:
BACKEND_ORIGIN(internal Django origin) andINTERNAL_API_KEY(same value)
Following technologies and libraries were used to create this project:
Following components were used to create this project:
- Rakhmetulla Akram - spike1236
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
See LICENSE file for details.
