uml.plantuml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. @startuml
  2. top to bottom direction
  3. skinparam packageStyle rectangle
  4. skinparam linetype ortho
  5. package "Database" {
  6. class DbConfig {
  7. +CONNECTION_STRING : string
  8. }
  9. class DatabaseManager {
  10. +CreateConnection() : NpgsqlConnection
  11. }
  12. }
  13. package "Models" {
  14. class User {
  15. +Id : int
  16. +Username : string
  17. +PasswordHash : string
  18. +Email : string
  19. +CreatedAt : DateTime
  20. }
  21. class Book {
  22. +Id : int
  23. +Title : string
  24. +Author : string
  25. +PublicationYear : int
  26. +OwnerId : int
  27. +CreatedAt : DateTime
  28. }
  29. }
  30. package "Repositories" {
  31. interface IUserRepository {
  32. +Create(user : User) : int
  33. +GetAll() : IEnumerable<User>
  34. +GetById(id : int) : User
  35. +Update(user : User) : bool
  36. +Delete(id : int) : bool
  37. }
  38. interface IBookRepository {
  39. +Create(book : Book) : int
  40. +GetAll() : IEnumerable<Book>
  41. +GetById(id : int) : Book
  42. +Update(book : Book) : bool
  43. +Delete(id : int) : bool
  44. }
  45. class UserRepository {
  46. -_databaseManager : DatabaseManager
  47. +Create(user : User) : int
  48. +GetAll() : IEnumerable<User>
  49. +GetById(id : int) : User
  50. +Update(user : User) : bool
  51. +Delete(id : int) : bool
  52. }
  53. class BookRepository {
  54. -_databaseManager : DatabaseManager
  55. +Create(book : Book) : int
  56. +GetAll() : IEnumerable<Book>
  57. +GetById(id : int) : Book
  58. +Update(book : Book) : bool
  59. +Delete(id : int) : bool
  60. }
  61. }
  62. package "Utils" {
  63. class PasswordHasher {
  64. +HashPassword(password : string) : string
  65. +VerifyPassword(password : string, hash : string) : bool
  66. }
  67. class LoggerConfigurator {
  68. +Configure()
  69. }
  70. }
  71. package "Tests" {
  72. class DatabaseTests {
  73. +Database_Should_Connect_Successfully()
  74. }
  75. class UserRepositoryTests {
  76. +Create_Should_Add_User()
  77. +GetAll_Should_Return_Users()
  78. +Update_Should_Modify_User()
  79. +Delete_Should_Remove_User()
  80. }
  81. class TestHelper {
  82. +CleanupUsers()
  83. }
  84. }
  85. UserRepository --> DatabaseManager
  86. BookRepository --> DatabaseManager
  87. UserRepository ..|> IUserRepository
  88. BookRepository ..|> IBookRepository
  89. Book --> User : owner_id
  90. UserRepository --> User
  91. BookRepository --> Book
  92. UserRepositoryTests --> IUserRepository
  93. DatabaseTests --> DatabaseManager
  94. TestHelper --> DatabaseManager
  95. DbConfig <-- DatabaseManager
  96. @enduml