The application uses MongoDB as its primary data store. Due to the document-oriented nature of MongoDB, we do not have rigid tables, but we enforce schemas using Pydantic Models in the application layer.
Although MongoDB is NoSQL, the entities have implicit relationships.
erDiagram
USERS ||--|{ TASKS : "owns"
USERS {
ObjectId _id PK
string email UK
string hashed_password
string name
enum role "USER | ADMIN"
list permissions
datetime created_at
}
TASKS {
ObjectId _id PK
string title
string description
string owner_id FK "Reference to USERS._id"
datetime created_at
}
Stores all registered user information.
- _id: Automatically generated MongoDB ObjectId.
- email: Unique index ensures no duplicate registrations.
- role: Determines access level. Defaults to
USER. - permissions: List of granular permission strings (extensible).
Stores to-do items for users.
- _id: Automatically generated MongoDB ObjectId.
- owner_id: A string representation of the User's ObjectId. This links the task to a specific user.
- Index: Typically indexed on
owner_idfor fast retrieval of a user's tasks.
We use Pydantic models to validate data before it enters the database.
- Location:
backend/app/models/ - Files:
user.py,task.py
MongoDB uses _id (ObjectId), but API clients typically expect id (string).
- Our Pydantic models use
Field(alias="_id")to map the database_idto the APIidfield automatically.