Introduction to models

  • All models are defined in models.py in the app/ directory. They use Flask-SQLAlchemy to map Python classes to database tables.

  • The database is DBMS-agnostics, so SQLite is used for development and testing, while PostgreSQL is used in production.

Models

User

The user model stores registered user, handles authentication, session management, admin status, blocking and API token generation.

Field

Type

Description

id

Integer

Primary key.

username

String(50)

Unique. Used for login.

email

String(100)

Unique. Normalized to lowercase.

password_hash

String(128)

Bcrypt hash. Raw passwords are never stored.

last_seen

DateTime

Updated on activity. UTC.

is_admin

Boolean

Grants access to the admin blueprint.

is_blocked

Boolean

Blocked users are logged out on every request.

failed_login_attempts

Integer

Reset on successful login or when unblocked.

created_at

DateTime

Set on registration. UTC.

token

String(32)

API token. Generated on registration.

token_expiration

DateTime

Token expires after 1 hour. Auto-renews if less than 60 seconds remain.

Rooms

The room model represents a call session. Each room created by the user has a unique code and belongs to an owner.

Field

Type

Description

id

Integer

Primary key.

room_code

String(9)

Unique. Generated automatically when user creates a room.

created-at

DateTime

Set on creation. UTC

owner_id

Integer

Foreign key. Displays the id of the user who created the room. Cascades on delete.

RoomParticipant

This model breaks down a table which has many-to-many relationship between users and rooms.

Field

Type

Description

id

Integer

Primary key.

rp_user_id

Integer

Foreign key to user.id. Cascades on Delete.

rp_room_id

Integer

Foreign key to room.id. Cascades on Delete.

Transcript

This model stores the sign language recognition output that is generated by the model during the call. A single room can have multiple transcripts.

Field

Type

Description

id

Integer

Primary key.

ts_content

Text

The recognized sign language output. Nullable

created-at

DateTime

Set on creation. UTC

room_id

Integer

Foreign key to room.id.

Messages

This model saves the messages sent by the users while in call.

Field

Type

Description

id

Integer

Primary key.

msg_content

Text

Message content. Nullables

created-at

DateTime

Set on creation. UTC

user_id

Integer

Foreign key to user.id. Set to NULL if user is deleted.

room_id

Integer

Foreign key to room.id.