baoliay2008 / lccn_predictor

LeetCode Contest Rating Prediction

Home Page:https://lccn.lbao.site

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

This is a Leetcode weekly and biweekly contest rating predictor. The APP is available online at ๐Ÿ”— lccn.lbao.site

Hopefully, you can get the predicted result within 15-30 minutes after the contest has finished.

Features

  • โšก๏ธ Fast
    1. The core prediction algorithm is accelerated by a JIT compiler(Numba) which costs around 20 seconds on a two-cores Intel(R) Xeon(R) Platinum 8255C CPU (@ 2.50GHz).
    2. User's latest rating was cached several times before predicting which can save a lot of time fetching data.
  • ๐ŸŽฏ Accurate
    1. If there were no massive rejudges(say, everyone's global ranking stays unchanged), the rating difference should be negligible.
    2. Please note that a normal case is that there would be some misconduct detection, so your global ranking will be slightly higher even if your submissions are not rejudged, which results in a slightly higher rating :)
  • ๐Ÿ“ฑ Responsive web page

    Tested on phones and tablets.

More Information

Underlying Mechanism

Algorithm

Database

Backend

  • APScheduler: background tasks
  • Numpy and Numba: core prediction algorithm implementation and acceleration
  • FastAPI: restful API
  • ๐Ÿšฎ Jinja: HTML templates for server-side rendering

Frontend

Development

Backend Deployment

virtualenv

git clone git@github.com:baoliay2008/lccn_predictor.git
cd lccn_predictor

# write your mongodb environment config
cp config.yaml.template config.yaml
vi config.yaml

python3.10 -m virtualenv venv/
source venv/bin/activate

pip3 install -r requirements.txt

python main.py
uvicorn api.entry:app --host 0.0.0.0 --port 55555

Docker

git clone git@github.com:baoliay2008/lccn_predictor.git
cd lccn_predictor

# write production environment mongodb config
cp config.yaml.template config.yaml
vi config.yaml

# build docker image
docker image build -t lccn_predictor:0.1.2 .

# create docker volume
docker volume create lccn_predictor

# run container
docker run -d -v lccn_predictor:/lccn_predictor -p 55555:55555 --name lp lccn_predictor:0.1.2

docker exec -it lp bash

docker container stop lp

docker container start lp

Frontend Deployment

cd client

# install dependencies
npm install

# change `baseUrl` to your local backend process
vi src/data/constants.js
# if you followed instruction above
# it should be "http://localhost:55555/api/v1"

# local test
npm start

# publish
npm run build

License

MIT License

Changelog

  • v0.0.1(2022/11/14)

    make this repo public, first release.

  • v0.0.2(2022/11/25)

    first version in production

  • v0.1.1(2023/02/14)

    change frontend from server-side rendering(Jinja + Materialize) to client-side rendering(React).

  • v0.1.2(2023/10/04)

    refine backend logic to enhance robustness and clean up deprecated static site rendering code


Supported by

JetBrains Logo (Main) logo

About

LeetCode Contest Rating Prediction

https://lccn.lbao.site

License:MIT License


Languages

Language:Python 62.7%Language:JavaScript 25.0%Language:HTML 10.9%Language:CSS 0.9%Language:Dockerfile 0.5%