Repositories
A class diagram. An interface, its base class and a user repository, beside a cache manager and the configuration.






Class showcase
┌────────────────────────────┐
│ «interface» │
│ Repository<T> │
├────────────────────────────┤
│ + findById(id: string): T │
│ + save(entity: T): void │
└────────────────────────────┘
△
╎
╎
┌──────────────────────────────┐
│ «abstract» │
│ BaseRepository<T> │
├──────────────────────────────┤
│ # table: string │
├──────────────────────────────┤
│ + findById(id: string): T * │
│ + save(entity: T): void * │
│ # connection(): Db │
└──────────────────────────────┘
△
│
│
┌────────────────────────────────────┐
│ UserRepository │
├────────────────────────────────────┤
│ + findById(id: string): User │
│ + save(entity: User): void │
│ + findByEmail(email: string): User │
└────────────────────────────────────┘
╎
╎
▼
┌────────────────────────────────────┐
│ «singleton» │
│ CacheManager │
├────────────────────────────────────┤
│ - instance: CacheManager $ │
├────────────────────────────────────┤
│ + getInstance(): CacheManager $ │
│ + get(key: string): any │
│ + set(key: string, val: any): void │
└────────────────────────────────────┘
│ 1
│
│ 1
┌────────────────────┐
│ «entity» │
│ AppConfig │
├────────────────────┤
│ - env: string │
│ - version: string │
└────────────────────┘
Spec
{ "type": "class", "title": "Class showcase", "classes": [ { "id": "repo", "label": "Repository", "stereotype": "interface", "type_params": ["T"], "color": "blue", "methods": [ {"visibility": "+", "text": "findById(id: string): T"}, {"visibility": "+", "text": "save(entity: T): void"} ] }, { "id": "baseRepo", "label": "BaseRepository", "stereotype": "abstract", "type_params": ["T"], "attributes": [{"visibility": "#", "text": "table: string"}], "methods": [ {"visibility": "+", "text": "findById(id: string): T", "abstract": true}, {"visibility": "+", "text": "save(entity: T): void", "abstract": true}, {"visibility": "#", "text": "connection(): Db"} ] }, { "id": "userRepo", "label": "UserRepository", "color": "green", "methods": [ {"visibility": "+", "text": "findById(id: string): User"}, {"visibility": "+", "text": "save(entity: User): void"}, {"visibility": "+", "text": "findByEmail(email: string): User"} ] }, { "id": "cache", "label": "CacheManager", "stereotype": "singleton", "color": "purple", "attributes": [{"visibility": "-", "text": "instance: CacheManager", "static": true}], "methods": [ {"visibility": "+", "text": "getInstance(): CacheManager", "static": true}, {"visibility": "+", "text": "get(key: string): any"}, {"visibility": "+", "text": "set(key: string, val: any): void"} ] }, { "id": "config", "label": "AppConfig", "stereotype": "entity", "attributes": [ {"visibility": "-", "text": "env: string"}, {"visibility": "-", "text": "version: string"} ] } ], "relations": [ { "id": "r-baseRepo-repo", "from": "baseRepo", "to": "repo", "kind": "realization", "color": "blue" }, {"id": "r-userRepo-baseRepo", "from": "userRepo", "to": "baseRepo", "kind": "inheritance"}, { "id": "r-userRepo-cache", "from": "userRepo", "to": "cache", "kind": "dependency", "color": "red" }, { "id": "r-cache-config", "from": "cache", "to": "config", "kind": "association", "from_card": "1", "to_card": "1" } ]}Draw it yourself
diago render repositories.json > repositories.svgOpen it in the playground to edit it in your browser.