Skip to content

Commit

Permalink
docs: add database design document
Browse files Browse the repository at this point in the history
Add database-design.md with database schema section give overview of the tables, data dictionary section explaining the different properties in the tables
Add the database er diagram image and file to assets
Update api readme to include link to the database design doc
  • Loading branch information
Lakshaya committed Feb 9, 2024
1 parent c77fa4b commit 8aedf1e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Imagine having a central hub where you can create and send notifications seamles
- [Usage Guide](docs/usage-guide.md)
- [Add New Provider](docs/add-new-provider.md)
- [Block Diagram](docs/block-diagram.md)
- [Database Design](docs/database-design.md)
- [API Test Cases](docs/api-test-cases.md)

## Contributing
Expand Down
1 change: 1 addition & 0 deletions apps/api/docs/assets/OsmoX_database_schema.erd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<diagram version="1" name="empty" time="202402091410"><entities><data-source id="mariaDB-18a2afe4364-97643446055c0ad"><entity id="1" name="notify_migrations" fq-name="osmo_notify.notify_migrations" order="0" color-bg="133,88,206" color-fg="255,255,255" font="Segoe UI:9:0" x="49" y="39"><path name="osmo_notify"/></entity><entity id="2" name="notify_notifications" fq-name="osmo_notify.notify_notifications" order="1" color-bg="133,88,206" color-fg="255,255,255" font="Segoe UI:9:0" x="217" y="39"><path name="osmo_notify"/></entity></data-source></entities><relations/></diagram>
Binary file added apps/api/docs/assets/OsmoX_database_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions apps/api/docs/database-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Database Design

This document provides a comprehensive and structured overview of the database design for OsmoX.

It serves as a reference guide for stakeholders, including developers, database administrators, project managers, and other parties involved in the development, maintenance, and understanding of the application's database.

The tables discussed below are created as part of the database migration.

## Database Schema

The database schema consists of the following 2 tables:

- **notify_migrations:** Contains the migration records
- **notify_notifications:** Contains details about all the notifications created

This schema can be visualized in the following image:

![OsmoX API Database Schema](./assets/OsmoX_database_schema.png)

The ERD diagram file for this schema can be accessed [here](./assets/OsmoX_database_schema.erd).

## Data Dictionary

### notify_migrations

| Attribute | Data Type | Not Null | Default | Description |
| --------- | ------------ | -------- | ------- | -------------------------------------------------------------- |
| id | int(11) | True | | Primary key, stores the id value for different migrations |
| timestamp | bigint(20) | True | | Stores the timestamp for when the migration record was created |
| name | varchar(255) | True | | Stores the name of the migration ran |

### notify_notifications

| Attribute | Data Type | Not Null | Default | Description |
| --------------- | ------------ | -------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id | int(11) | True | | Primary key, stores the id value for different notifications |
| channel_type | tinyint(4) | True | | Stores the channel type used for the notification. Can be a value from [Available Channel Types](./usage-guide.md#5-available-channel-types) |
| data | text | True | | Stores JSON data about the notification such as the from/to addresses, subject and body content |
| delivery_status | tinyint(4) | True | 1 | Stores the current delivery status of the notification. Can be a value from [Delivery Status Information](./usage-guide.md#6-delivery-status-information) |
| result | text | False | NULL | Stores the JSON result after attempting to send the notification |
| created_on | timestamp | True | current_timestamp() | Stores the timestamp for the creation of the notification |
| updated_on | timestamp | True | current_timestamp() | Stores the timestamp for the last update to the notification |
| created_by | varchar(255) | True | | Stores the name of the service/app that created the notification |
| updated_by | varchar(255) | True | | Stores the name of the service/app that last updated the notification |
| status | tinyint(4) | True | 1 | Stores whether the notification must be considered as active(1) or inactive(0) |

0 comments on commit 8aedf1e

Please # to comment.