-
Notifications
You must be signed in to change notification settings - Fork 0
database
Here we have the basic layout of the Databases & disk data of the API.
The database used for users & challenges is SQLITE with an async connector.
For the connector we use databases package which is an SQLAlchemy Core compactible wrapper around the aiosqlite connector.
The only configuration needed for databases to operate is the Settings.DATA_FOLDER
to be set to an existing directory and have write permissions, if the zerospeech.db
file does not exist it is created with all the empty tables at API startup.
see connect config and api startup
The schema of the database is declared in the zerospeech.db.schema module. Tables are declared using basic SQLAlchemy Core Syntax and mapped to a Pydantic dataclass for validation and easier manipulation.
- users_credentials: Table containing all users and their auth credentials.
*Any sensitive information is hashed & salted
-
logged_users: Table containing all active user sessions & their tokens.
-
password_reset_users: Table containing all password reset sessions.
-
challenges: Table containing all registered challenges.
-
challenge_submissions: Table containing all submissions uploaded to the challenges
-
evaluators: Table containing all registered evaluation functions for the submissions.
All queries & interactions with the database is in the zerospeech.db.q module. Queries are in async functions using SQLAlchemy Core Queriyng language.
All file data is saved in a folder configured as Settings.DATA_FOLDER
.
User profile data is stored as a json file at Settings.USER_DATA_DIR / <username>.json
.
Submissions are uploaded as zip files containing various files used to calculate a score. All files relative to each submission is stored at :
Settings.SUBMISSION_DIR / <submission_id>
Static files are served in the API under the path : <api-url>/static/<path>
And are stored in : Settings.DATA_FOLDER / _static
Template files are used for api HTML responses, email notifications, mattermost notifications.
They are created using Jinja2 Templating language, and are stored in the zerospeech.templates module.