Upgrade to Pro — share decks privately, control downloads, hide ads and more …

FloorPlan: Visualize databases' evolution

FloorPlan: Visualize databases' evolution

As software matures, more functionality is added, code gets moved, re-written or removed. In the same rhythm, team members change and with them historical knowledge might get lost. For that reason, it is important to have a well-organized project, that is inviting for new contributors while still digestible for one-off readers.

Understanding how data is structured can be very helpful as an initial step for diving into the abstract modeling of the business domain. Database schemas, then, provide that entry window, but building the mental model out of a machine-readable format can be a daunting task even for seasoned engineers, especially when the project grows large and changes rapidly.

In this talk, we will learn how this challenge drove the creation of FloorPlan, an open source Kotlin library to translate database schemas into ER diagrams, discuss its development and application for the team of 20+ Android engineers at SoundCloud.

Júlio Zynger

October 22, 2020
Tweet

More Decks by Júlio Zynger

Other Decks in Technology

Transcript

  1. SoundCloud www.juliozynger.com • 200+ million tracks → world’s largest open

    audio platform • Over 25 million creators • Available in 190 countries • 90%+ of usage comes from mobile devices
  2. SoundCloud www.juliozynger.com • Started as Rails application • Microservice extraction

    • Dozens of engineers, hundreds of services • Polyglot development and tooling
  3. SoundCloud www.juliozynger.com • ~20 engineers • ~60 merged PRs per

    week • ~250 modules, ~8000 tests, ~15 databases
  4. SoundCloud www.juliozynger.com Room Google’s solution Onboardable Well-documented SQLDelight Code generation

    SQL / Java,Kt separation Multiplatform Bare SQL Propeller Lean API Type Safety Observability, etc.
  5. A document shouldn’t try to do what the code already

    does well. www.juliozynger.com “ ― Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software
  6. DBML (dbml.org) www.juliozynger.com • Open-source DSL language • Define and

    document DB schemas • Designed to be simple, consistent and highly-readable
  7. DBML (dbml.org) www.juliozynger.com Table users { id integer [pk] username

    varchar role varchar } Table posts { id integer [pk] title varchar body text [note: 'Content of the post'] user_id integer } Ref: posts.user_id > users.id
  8. Rendering: GraphViz www.juliozynger.com • Open-source graph visualization software • Java

    bindings through graphviz-java val graph: Graph = mutGraph() graph.addNodes(tables.map { it.toNode() }) graph.addLinks(references.map { it.toLink() }) g.render(Format.SVG)
  9. www.juliozynger.com Gradle Plugin floorPlan { schemaLocation = "$projectDir/schemas" outputLocation =

    "$projectDir/floorplan-output" outputFormat { svg { enabled = true } } }
  10. www.juliozynger.com Gradle Plugin apply plugin: 'kotlin-kapt' apply plugin: 'com.juliozynger.floorplan' kapt

    { arg("room.schemaLocation", "$projectDir/schemas") ... } floorPlan { schemaLocation = "$projectDir/schemas" ... } dependencies { implementation Libs.room_runtime ... } room-support.gradle apply from: "$rootProject.projectDir/android-library.gradle" apply from: "$rootProject.projectDir/room-support.gradle" dependencies { implementation Libs.dagger implementation Libs.appcompat testImplementation Libs.junit ... } some-module/build.gradle
  11. www.juliozynger.com SoundCloud-Android ├─ app ├─ docs ├─ modules │ ├─

    discovery │ │ ├─ src │ │ ├─ schemas │ │ └─ floorplan-output │ ├─ player │ │ ├─ src │ │ ├─ schemas │ │ └─ floorplan-output │ ├─ upload │ │ ├─ src │ │ ├─ schemas │ │ └─ floorplan-output └─ ... Serving SoundCloud-Android ├─ app ├─ docs │ └─ databases │ ├─ discovery │ ├─ player │ └─ upload │ ├─ 1.svg │ ├─ 2.svg │ └─ ... ├─ modules │ └─ ... └─ mkdocs.yml </>
  12. www.juliozynger.com Wrap-up • Source code is source for docs •

    No disruption through full automation • Value generation in each step of the pipeline
  13. www.juliozynger.com Wrap-up • Source code is source for docs •

    No disruption through full automation • Value generation in each step of the pipeline • Workflow augmentation
  14. www.juliozynger.com Wrap-up • Source code is source for docs •

    No disruption through full automation • Value generation in each step of the pipeline • Workflow augmentation • Enable potential extension
  15. www.juliozynger.com Wrap-up • Source code is source for docs •

    No disruption through full automation • Value generation in each step of the pipeline • Workflow augmentation • Enable potential extension • Accessibility through environment agnostic tooling
  16. www.juliozynger.com Wrap-up • Source code is source for docs •

    No disruption through full automation • Value generation in each step of the pipeline • Workflow augmentation • Enable potential extension • Accessibility through environment agnostic tooling • Inter business department involvement