Skip to content

Repositories

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

An interface, its base class and a user repository, beside a cache manager and the configurationAn interface, its base class and a user repository, beside a cache manager and the configuration

Spec

repositories.json
{
"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

Terminal window
diago render repositories.json > repositories.svg

Open it in the playground to edit it in your browser.