susunjadwal-backend
susunjadwal-backend copied to clipboard
SusunJadwal - Universitas Indonesia's #1 Student Course Planner App.
Susun Jadwal
Susun Jadwal is an open source tool to plan class schedules for university students.
Susun Jadwal by Ristek Fasilkom UI. https://susunjadwal.cs.ui.ac.id/
Monorepo setup with React frontend and Flask backend.
Structure explained
app/ // general views
models/ // mongoDB models
scraper/ // courses (academic.ui.ac.id) scraper
sso/ // SSO UI authentication logic
README.md // important info
requirements.txt // dependency list
start.sh // script to start server
...
README.md // workspace-wide information shown in github
Contributing Guide
Feel free to contribute by submitting a pull request.
Susun Jadwal Backend
Requirements
-
python
andpip
-
docker
Configuration
Development
- Create virtual environment using
python3 -m venv env
- Activate virtualenv
source ./env/bin/activate
- Install requirements
pip install -r requirements.txt
- Add your credential to scrap schedule from SIAK in
scraper/credentials.json
with the following structure:
{
"<kd_org>": {
"username": "<username>",
"password": "<password>"
}
}
You can also see scraper/credentials.template.json
for example and sso/additional-info.json
for list of kd_org
.
- Start database using
bash start_db.sh
- Go to mongo console by running
docker exec -it ristek-mongo mongo -u <admin_username>
- Create database by running
use <db_name>
. By default, Flask use database namedtest
so it becomesuse test
- Create user for database:
db.createUser(
{
user: "<db_user>",
pwd: "<db_pwd>",
roles:[
{
role: "readWrite",
db: "<db_name>"
}
]
}
);
You can quit mongo console now by using Ctrl + D.
- Create config file,
instance/config.cfg
. You can seeinstance/config.template.cfg
for example and edit db name, username, and password to match the one you created before - Run
docker-compose up -d
to start the rabbit mq - Create
.env
file from.env.example
file - Finally, run Flask by using
FLASK_ENV="development" flask run
Production
Old
We actually have a slightly different setup in the real Ristek server. For future maintainers, you may want to contact past contributors.
- Do everything in development step except step no 10, running Flask. Don't forget to modify
instance/config.cfg
,start_db.sh
, andscraper/credentials.json
if you want to - Run gunicorn using
bash start.sh
- Set your Nginx (or other reverse proxy of your choice) to reverse proxy to
sunjad.sock
. For example, to reverse proxy/susunjadwal/api
you can set
location ^~ /susunjadwal/api {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/path/to/susunjadwal/backend/sunjad.sock;
}
- Run the schedule scrapper cron job using
crontab -e
and add the line to runcron.sh
. For example, to run it every 10 minutes add*/10 * * * * bash /path/to/susunjadwal/backend/cron.sh
New
- Do everything in development step except step no 10, running Flask.
- Create
config.cfg
and fill the DB credentials according the given specification indocker-compose-deploy.yaml
(host must bemongo
) - Run
docker-compose -f docker-compose-deploy.yaml up -d
to execute all
License
See LICENSE.md. This software actually goes a long way back, thank you so much to everyone involved.