database/migrations/.
Schema overview
The database consists of the following core tables:- users - User accounts and profiles
- entries - Diary entries
- friend_requests - Friend request management
- entry_users - Shared diary entries (many-to-many)
- image_users - User profile pictures
- image_entries - Entry image attachments
- likes - Entry likes/reactions
- sessions - Active user sessions
- password_reset_tokens - Password reset functionality
Entity relationship diagram
Tables
users
Stores user account information and profile settings. Migration:0001_01_01_000000_create_users_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | User unique identifier |
| name | varchar(255) | NOT NULL | User’s display name |
| varchar(255) | NOT NULL, UNIQUE | User’s email address | |
| password | varchar(255) | NOT NULL | Hashed password |
| admin | boolean | DEFAULT false | Admin privilege flag |
| colorConfiguration | varchar(255) | NULLABLE | Custom color theme preference |
| created_at | timestamp | NULLABLE | Account creation timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Has many
entries(as creator) - Has many
friend_requests(as sender or receiver) - Has many
image_users(profile pictures) - Has many
likes - Belongs to many
entriesthroughentry_users(shared entries)
entries
Stores diary entry content and metadata. Migration:2025_05_21_013634_create_entries_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Entry unique identifier |
| body | text | NOT NULL | Entry content/text |
| visibility | varchar(255) | NOT NULL | Visibility level: ‘public’, ‘private’, or ‘friends’ |
| creator_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | Entry author |
| created_at | timestamp | NULLABLE | Entry creation timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Foreign key on
creator_id
- Belongs to
users(creator) - Has many
image_entries - Has many
likes - Belongs to many
usersthroughentry_users(shared with)
private- Only visible to creatorpublic- Visible to everyonefriends- Visible to friends only
friend_requests
Manages friend connections between users. Migration:2025_05_21_013616_create_friend_requests_table.php (updated by 2025_07_12_223135_add_change_variables_in_friend_requests.php)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Request unique identifier |
| status | varchar(255) | NOT NULL | Request status: ‘pending’, ‘accepted’, or ‘rejected’ |
| send_at | datetime | NOT NULL | Request sent timestamp |
| response_at | datetime | NULLABLE | Request response timestamp |
| sender_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | User who sent request |
| recived_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | User who received request |
- Foreign key on
sender_id - Foreign key on
recived_id
- Belongs to
users(sender) - Belongs to
users(receiver)
pending- Awaiting responseaccepted- Friend request acceptedrejected- Friend request rejected
entry_users
Pivot table for sharing diary entries with specific users. Migration:2025_05_21_013654_create_entry_users_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Relation unique identifier |
| entry_id | bigint unsigned | FOREIGN KEY → entries.id, ON DELETE CASCADE | Shared entry |
| user_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | User with access |
| created_at | timestamp | NULLABLE | Share timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Foreign key on
entry_id - Foreign key on
user_id
- Belongs to
entries - Belongs to
users
image_users
Stores user profile pictures. Migration:2025_05_21_013722_create_image_users_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Image unique identifier |
| name | varchar(255) | NOT NULL | Image filename |
| path | varchar(255) | NOT NULL | Storage path |
| selected | boolean | DEFAULT true | Currently active profile picture |
| user_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | Image owner |
| created_at | timestamp | NULLABLE | Upload timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Foreign key on
user_id
- Belongs to
users
selected at a time.
image_entries
Stores images attached to diary entries. Migration:2025_05_21_013732_create_image_entries_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Image unique identifier |
| name | varchar(255) | NOT NULL | Image filename |
| path | varchar(255) | NOT NULL | Storage path |
| entry_id | bigint unsigned | FOREIGN KEY → entries.id, ON DELETE CASCADE | Associated entry |
| created_at | timestamp | NULLABLE | Upload timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Foreign key on
entry_id
- Belongs to
entries
likes
Tracks user reactions/likes on diary entries. Migration:2025_05_21_013929_create_likes_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | bigint unsigned | PRIMARY KEY, AUTO_INCREMENT | Like unique identifier |
| type | varchar(255) | NOT NULL | Reaction type (e.g., ‘like’, ‘love’) |
| entry_id | bigint unsigned | FOREIGN KEY → entries.id, ON DELETE CASCADE | Liked entry |
| user_id | bigint unsigned | FOREIGN KEY → users.id, ON DELETE CASCADE | User who liked |
| created_at | timestamp | NULLABLE | Like timestamp |
| updated_at | timestamp | NULLABLE | Last update timestamp |
- Foreign key on
entry_id - Foreign key on
user_id
- Belongs to
entries - Belongs to
users
sessions
Laravel session storage table. Migration:0001_01_01_000000_create_users_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | varchar(255) | PRIMARY KEY | Session unique identifier |
| user_id | bigint unsigned | NULLABLE, INDEX | Authenticated user ID |
| ip_address | varchar(45) | NULLABLE | Client IP address |
| user_agent | text | NULLABLE | Client user agent |
| payload | longtext | NOT NULL | Serialized session data |
| last_activity | integer | NOT NULL, INDEX | Unix timestamp of last activity |
- Index on
user_id - Index on
last_activity
password_reset_tokens
Stores password reset tokens. Migration:0001_01_01_000000_create_users_table.php
| Column | Type | Constraints | Description |
|---|---|---|---|
| varchar(255) | PRIMARY KEY | User email address | |
| token | varchar(255) | NOT NULL | Reset token hash |
| created_at | timestamp | NULLABLE | Token creation timestamp |
Cascade behaviors
All foreign key relationships useON DELETE CASCADE and ON UPDATE CASCADE, meaning:
- Deleting a user will delete all their entries, friend requests, images, and likes
- Deleting an entry will delete all associated images, likes, and sharing relationships
- This maintains referential integrity automatically
Database conventions
Naming conventions
- Table names: plural, snake_case (e.g.,
friend_requests) - Column names: snake_case (e.g.,
created_at) - Primary keys:
id - Foreign keys:
{table_singular}_id(e.g.,user_id) - Pivot tables: alphabetical order (e.g.,
entry_users)
Timestamps
Most tables include Laravel’s automatic timestamps:created_at- Set when record is createdupdated_at- Updated when record is modified
Querying examples
Get all public entries with creator and images
Get user’s friends
Get entries shared with a user
Migration files
All migrations are located indatabase/migrations/:
0001_01_01_000000_create_users_table.php2025_05_21_013616_create_friend_requests_table.php2025_05_21_013634_create_entries_table.php2025_05_21_013654_create_entry_users_table.php2025_05_21_013722_create_image_users_table.php2025_05_21_013732_create_image_entries_table.php2025_05_21_013929_create_likes_table.php2025_07_12_223135_add_change_variables_in_friend_requests.php
Next steps
- Review the architecture overview
- Explore frontend components
- Set up your development environment