Skip to content

Domain model

Fredrik Jonathan Marjoni edited this page Apr 21, 2026 · 11 revisions

Domain-model

@startuml
' ===== HmH Domain Model - Simplified Layer Flow (Updated with OrganizationScraper) =====
skinparam componentStyle rectangle
skinparam defaultFontSize 12

title Help-Me-Help: Frontend → Backend Data Flow

' Define layers as horizontal rows
together {
  rectangle "**FRONTEND**" as FE #LightBlue {

    rectangle "App\n(Entry Point)" as App #AliceBlue

    rectangle "Views" as Views #AliceBlue {
      component "HomePageView" as V1
      component "LoginPageView" as V2
      component "CausesPageView" as V3
      component "OrganizationPageView" as V4
      component "DonationPageView" as V5
      component "UserPageView" as V6
    }

    rectangle "Controllers" as Controllers #AliceBlue {
      component "NavigationController" as NC
      component "AuthController" as AC
      component "LoginController" as LC
      component "OrganizationController" as OC
      component "DonationController" as DC
    }

    rectangle "AppState\n(Session Data)" as State #AliceBlue
  }
}

together {
  rectangle "**BACKEND**" as BE #LightGreen {

    rectangle "Services\n(Business Logic)" as Services #Honeydew {
      component "UserService" as US
      component "OrganizationService" as OS
      component "DonationService" as DS
    }

    rectangle "Repositories\n(Data Access)" as Repos #Honeydew {
      component "UserRepository" as UR
      component "OrganizationRepository" as OR
      component "DonationRepository" as DR
    }

    rectangle "Scrapers\n(Web Extraction)" as Scrapers #LemonChiffon {
      component "OrganizationScraper" as SCRAPE
    }

    rectangle "Domain Models" as Models #Honeydew {
      component "User / Customer" as MU
      component "Organization" as MO
      component "Donation" as MD
    }
  }
}

together {
  rectangle "**DATA ACCESS**" as DA #LightYellow {

    rectangle "Wrappers\n(External Connectors)" as Wrappers #LemonChiffon {
      component "DbWrapper" as DBW
      component "OrgApiWrapper" as OAPI
    }
  }
}

together {
  rectangle "**EXTERNAL SYSTEMS**" as EXT #LightGray {
    database "H2 Database\n(Users, Donations)" as H2
    cloud "Innsamlingskontrollen API\n(Organizations)" as API
    cloud "Organization Websites\n(Descriptions, Logos)" as WEBSITES
  }
}

together {
  rectangle "**UTILS**" as Utils #LavenderBlush {
    component "ParameterValidator" as PV
  }
}

' ========== FLOW ARROWS ==========

' App initialization flow
App -[#blue,bold]down-> NC : "initializes"
App -[#blue]down-> DBW : "creates"
App -[#blue]down-> OAPI : "creates"
App -[#blue]down-> SCRAPE : "creates"
App -[#blue]down-> State : "creates"

' Views → Controllers
Views -[#gray,dashed]down-> Controllers : "user actions"
Controllers -[#gray,dashed]up-> Views : "updates UI"

NC -[#blue]down-> AC : "creates"
NC -[#blue]down-> LC : "creates"
NC -[#blue]down-> OC : "creates"
NC -[#blue]down-> DC : "creates"

' Controllers ↔ State
Controllers .[#purple].> State : "read/write\nsession"

'validation from Util
UR .[#gray].> PV : "validates"
OR .[#gray].> PV : "validates"
US .[#gray].> PV : "validates"

' Controllers → Services
LC -[#green,bold]down-> US : "login/register"
OC -[#green,bold]down-> OS : "fetch orgs"
DC -[#green,bold]down-> DS : "donate"
AC -[#green,bold]down-> US : "auth"


' Services → Repositories
US -[#green,bold]down-> UR
OS -[#green,bold]down-> OR
DS -[#green,bold]down-> DR
DS -[#green,bold]down-> OR

' Services → Scraper
OS -[#darkgreen,bold]down-> SCRAPE : "fetch logos\n& descriptions"

' Repositories → Scraper
OR -[#darkgreen,bold]down-> SCRAPE : "fetch descriptions"

' Repositories ↔ Models
UR -[#orange]right-> MU : "CRUD"
OR -[#orange]right-> MO : "CRUD"
DR -[#orange]right-> MD : "CRUD"

' Wrappers ↔ Repositories (data flow)
DBW .[#red,dashed]up.> UR : "import/export"
DBW .[#red,dashed]up.> DR : "import/export"
OAPI .[#red,dashed]up.> OR : "import"

' Scraper → Wrappers/External
SCRAPE -[#darkred,bold]down-> OAPI : "queries API"
SCRAPE -[#darkred,bold]down-> WEBSITES : "scrapes pages"

' Wrappers → External Systems
DBW -[#red,bold]down-> H2 : "JDBC"
OAPI -[#red,bold]down-> API : "HTTP/JSON"

' ========== LEGEND ==========
legend right
  |= Color |= Meaning |
  | <#Blue> | Initialization |
  | <#Gray> | UI Interaction |
  | <#Purple> | State Access |
  | <#Green> | Business Logic |
  | <#DarkGreen> | Web Scraping |
  | <#Orange> | Data Management |
  | <#Red> | External I/O |
endlegend

@enduml

***