Source code of centrífuga4, Xamfrà's student management platform.
DEPLOY APP TO PRODUCTION
DEPLOY DOCS TO GH-PAGES
- Clone this repository
- Install Python 3 and Pip
- Install Python requirements using
pip install -r requirements.txt
- Install npm
- Run
npm install
inside web_app to install the npm modules
- Python backend
- Add all the required environment variables
- Use development/generate_sample_db.py to create a new database. It will contain a user '[email protected]' : 'admin'
- Run development/wsgi_development.py to run the backend development server
- Frontend development server
- Run
npm start
inside web_app to start the frontend development server
- Run
- Run Redis Server and email_queue/worker.py.
- Run
npm build
inside web_app to build the React files into static files - Run wsgi_production.py to run the server
- Run Redis Server worker.py.
v0 by A. Rius
v1-4 by @miquelvir
Due to budget constraints, reduced development and maintenance group, and for simplicity's sake, centrifuga4 is build following a monolithic approach. However, code decoupling and modularity are still important.
Web process: a Flask server serving the static files (including the React frontend) and all the APIs.
- Data API (for DB data access and modification)
- Auth API (to login, logout and ping)
- Front end static files
- Invites API (to create and send user invites, as well as to create users from invites)
- Password reset API (to ask for a password reset, as well as to change the password from a password reset request)
- Document validation page (checks the content and validity of a JWT token signed by the server and displays it in a simple static page).
The one being used is Heroku; the Procfile specifies how the workers are to be run (web uses wsgi.py).
For now, it is run on the free tier; if dyno hours were not enough, then it would be useful to increment to a Hobby plan (which would allow for a custom domain together with SSL). Similarly, if more than 500 students + 100 courses are needed, Heroku Postgres would probably need to be upgraded. An alternative is deploying a small server to Xamfrà.
One can manually export a PostgreSQL dump file from Heroku (see instructions).
Heroku (on the Free tier) does an automatic daily backup, and stores up to 2 copies of it. To convert the db.dump
to a usable .sql file,
you can use:
pg_restore --verbose --clean --no-acl --no-owner db.dump -f db.sql
Create a .env on the root folder of the project with the following variables:
- SMTP_PASSWORD
- REDIS_URL
- MANUAL_DATABASE_URL
- DATABASE_URL
- SECRET, can be anything for development (e.g. 'super-secret')
- wkhtmltopdf, the path to wkhtmltopdf (e.g. '/usr/bin/wkhtmltopdf')
- ENVIRONMENT, one of the following:
- 'development' (using a separate React development server),
- 'production' (for the final Heroku deployment),
- 'development-built' (development, but using the build version of the React frontend)
- RECAPTCHA (the private key)
- EMAIL_DEBUGGING_MODE=1 #todo explain
- SMTP_BULK_PASSWORD
- SMTP_BULK_USER=news_xamfra96
- SMTP_BULK_DOMAIN=newsletter.xamfra.net
- SMTP_DOMAIN=smtp.xamfra.net
- SMTP_USER=[email protected]
- DISCORD_LOGIN_NOTIFICATIONS
- DISCORD_LOGIN_NOTIFICATIONS_ALERT
FE is built on React with Material UI. Fullcalendar is used for displaying schedules/calendars.
Frontend uses Google reCAPTCHA service for bot detection in all API calls which do not require authentication. E.g: password recovery, pre-enrolment, etc.
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a