This is the backend for the ordering system for BAID's Whale Cafe. Built with FastAPI + SQLAlchemy.
To run in production, follow the tutorial under WebArtistryBAID/whale-docker.
To run in development:
- Ensure that you have at least Python 3.12 available.
- Run WebArtistryBAID/baid-onelogin and create an OAuth2 app. Set
http://your-host/login/authorize
as a redirect URI. Allow the scopesbasic
,phone
, andsms
. - Clone the repository.
- Run
pip install -r requirements.txt
. - Export all the following environment variables:
Name | Description |
---|---|
DATABASE_URL |
The database URL to use. Typically sqlite:///database.db . |
API_HOST |
The full URL on which this API is running on, no trailing slash. |
FRONTEND_HOST |
The full URL on which the frontend is hosted, no trailing slash. |
ONELOGIN_HOST |
The full URL on which OneLogin is hosted, no trailing slash. |
JWT_SECRET_KEY |
The JWT secret key to use. You can generate one with openssl rand -hex 32 . |
ONELOGIN_CLIENT_ID |
The client ID for the registered OneLogin app. |
ONELOGIN_CLIENT_SECRET |
The client secret for the registered OneLogin app. |
DEVELOPMENT |
Set to true to bypass CORS protections and enable certain development-only features. |
TIME_ZONE |
Asia/Shanghai by default. |
- Run
alembic upgrade head
to apply database migrations. You only need to do this when new migrations are released. - Run
python -m uvicorn main:app --reload
.
Settings are stored in the database as a key-value pair.
Key | Description |
---|---|
shop-open |
1 for ordering being open, and 0 for not. |
total-quota |
The number of cups that can be ordered. |
order-quota |
The number of cups that can be ordered per order. |
Some users have specific permissions that allow them to access more features. These include:
Permission | Description |
---|---|
admin.cms |
Allows entering CMS. |
admin.manage |
Allows managing orders. |
Project Whale is integrated with certain third-party service providers:
- SEIUE, for user authentication
To contribute, simply open a pull request.
Whale is BAID's Whale Cafe's ordering system.
Copyright (C) 2024 Team WebArtistry
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.