Skip to content

Commit

Permalink
doc: Added database diagram to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiky committed Jan 15, 2024
1 parent aaf9ca2 commit cd2140e
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ A Postman's collection can be found [here](postman-collection/).

To try out our product, you can use our [demo](https://demo.lokapp.io).

## Database model

![Database Diagram](./documentation/database-model.png)

## License

Distributed under the Apache 2.0 License. See `LICENSE` for more information.
Expand Down
Binary file added documentation/database-model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions documentation/database-model.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@startuml
!include dbdiagramtheme.puml

table( projects ) #header:07198C {
primary_key( id, integer )
column( name, "character varying", true )
column( description, "character varying" )
column( color, "character varying", true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
}

table( users ) #header:F39C1B {
primary_key( id, "character varying" )
column( username, "character varying" )
column( email, "character varying", true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
}

table( invitations ) #header:F39C1B {
primary_key( id, integer )
foreign_key( projectId, integer )
foreign_key( ownerId, "character varying" )
foreign_key( guestId, "character varying" )
column( role, "character varying", true )
column( createdAt, timestamp )
column( sourceLanguagesIds, "character varying" )
column( targetLanguagesIds, "character varying" )
}

table( users_projects ) #header:F39C1B {
primary_key( projectId, integer )
primary_key( userId, "character varying" )
column( role, "character varying", true )
column( createdAt, timestamp )
column( sourceLanguagesIds, "character varying" )
column( targetLanguagesIds, "character varying" )
}

table( groups ) {
primary_key( id, integer )
foreign_key( projectId, integer, false )
column( name, "character varying", true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
}

table( project_languages ) {
primary_key( id, integer )
foreign_key( projectId, integer )
column( name, "character varying", true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
column( isRtl, boolean, true )
}

table( translation_keys ) #header:C0392A {
primary_key( id, integer )
foreign_key( projectId, integer )
foreign_key( groupId, integer, false )
column( name, "character varying", true )
column( isPlural, boolean, true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
}

table( translation_values ) #header:C0392A {
primary_key( id, integer )
column( name, "character varying", true )
column( quantityString, "character varying", true )
column( createdAt, timestamp, true )
column( updatedAt, timestamp, true )
foreign_key( keyId, integer )
foreign_key( languageId, integer )
column( status, "character varying", true )
}

invitations::ownerId }|-- users::id
invitations::guestId }|-- users::id
invitations::projectId }|-- projects::id
users_projects::userId }|-- users::id
users_projects::projectId }|-- projects::id
groups::projectId }|-- projects::id
translation_keys::groupId }|-- groups::id
translation_keys::projectId }|-- projects::id
project_languages::projectId }|-- projects::id
translation_values::keyId }|-- translation_keys::id
translation_values::languageId }|-- project_languages::id

@enduml
41 changes: 41 additions & 0 deletions documentation/dbdiagramtheme.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@startuml
left to right direction
skinparam roundcorner 10
skinparam shadowing false
skinparam handwritten false
skinparam BackgroundColor #44444D
skinparam class {
FontColor white
AttributeFontColor white
BackgroundColor #38383F
ArrowColor white
BorderColor #38383F
HeaderBackgroundColor #232323
HeaderFontStyle bold
}

!define table(x) entity x << (T, white) >>

!function primary_key($name, $type, $nonnull=true)
!$nn = ""
!if ($nonnull == true)
!$nn = "<<NN>>"
!endif
!return "<b><color:#b8861b><&key></color> " + $name + ": " + $type + " <<PK>> " + $nn + "</b>"
!endfunction
!function foreign_key($name, $type, $nonnull=true)
!$nn = ""
!if ($nonnull == true)
!$nn = "<<NN>>"
!endif
!return "<color:#aaaaaa><&key></color> " + $name + ": " + $type + " <<FK>> " + $nn
!endfunction
!function column($name, $type, $nonnull=false)
!$nn = ""
!if ($nonnull == true)
!$nn = "<<NN>>"
!endif
!return "<color:#efefef><&media-record></color> " + $name + ": " + $type + " " + $nn
!endfunction

@enduml

0 comments on commit cd2140e

Please sign in to comment.