diff --git a/CHANGELOG.md b/CHANGELOG.md index e3209f8..2fd3f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Asymmetric encryption and decryption**: Supported RSA and other asymmetric encryption algorithms for data protection. - **Symmetric encryption**: Supported symmetric key encryption (e.g. AES) for data protection. - **Hashing and signature verification**: Supported hashing algorithms (e.g. SHA-256, SHA-512) and verified signatures using asymmetric keys (RSA, ECDSA, etc.). +- Adopted Domain-Driven Design to create a **modular, flexible and maintainable** project structure with a focus on the **domain at its core** ## [0.1.0] - TBD-TBD-TBD diff --git a/cmd/crypto-vault-cli/crypto-vault-cli.go b/cmd/crypto-vault-cli/crypto-vault-cli.go index 258e421..8589ba4 100644 --- a/cmd/crypto-vault-cli/crypto-vault-cli.go +++ b/cmd/crypto-vault-cli/crypto-vault-cli.go @@ -13,7 +13,7 @@ import ( "github.com/spf13/cobra" - cryptography "crypto_vault_service/pkg/cryptography" + cryptography "crypto_vault_service/internal/infrastructure/cryptography" ) // Encrypts a file using AES and saves the encryption key diff --git a/cmd/crypto-vault-service/crypto-vault-service.go b/cmd/crypto-vault-service/crypto-vault-service.go index 0a00273..7c6f393 100644 --- a/cmd/crypto-vault-service/crypto-vault-service.go +++ b/cmd/crypto-vault-service/crypto-vault-service.go @@ -1,7 +1,7 @@ package main import ( - v1 "crypto_vault_service/api/v1" + v1 "crypto_vault_service/internal/api/v1" "github.com/gin-gonic/gin" ) diff --git a/docs/architecture-decision-record/ddd.md b/docs/architecture-decision-record/ddd.md new file mode 100644 index 0000000..0440890 --- /dev/null +++ b/docs/architecture-decision-record/ddd.md @@ -0,0 +1,39 @@ +# Domain-driven Design + +Incorporating DDD as an architecture decision impacts the structure and development process of the entire application. By aligning the software architecture with the business domain, we promote a more **modular, flexible and maintainable** design. The goal is to deeply understand the domain, represent it through domain models and ensure that the application closely matches the business processes. + +```sh +. +├── cmd +│ ├── crypto-vault-cli +│ ├── Dockerfile +│ ├── crypto-vault-cli.go +│ └── crypto-vault-service +│ ├── Dockerfile +│ └── crypto-vault-service.go +├── configs +│ ├── dev.yml +│ ├── prd.yml +│ └── qas.yml +├── go.mod +├── go.sum +├── internal +│ ├── api +│ │ └── v1 +│ │ └── v2 +│ │ └── ... +│ ├── app +│ ├── domain +│ ├── infrastructure +│ └── persistence +└── test + ├── data + ├── integration + │ ├── domain + │ ├── infrastructure + │ └── persistence + └── unit + ├── domain + ├── infrastructure + └── persistence +``` \ No newline at end of file diff --git a/api/v1/errors.go b/internal/api/v1/errors.go similarity index 100% rename from api/v1/errors.go rename to internal/api/v1/errors.go diff --git a/api/v1/handlers.go b/internal/api/v1/handlers.go similarity index 100% rename from api/v1/handlers.go rename to internal/api/v1/handlers.go diff --git a/api/v1/middleware.go b/internal/api/v1/middleware.go similarity index 100% rename from api/v1/middleware.go rename to internal/api/v1/middleware.go diff --git a/api/v1/models.go b/internal/api/v1/models.go similarity index 100% rename from api/v1/models.go rename to internal/api/v1/models.go diff --git a/api/v1/responses.go b/internal/api/v1/responses.go similarity index 100% rename from api/v1/responses.go rename to internal/api/v1/responses.go diff --git a/api/v1/routes.go b/internal/api/v1/routes.go similarity index 100% rename from api/v1/routes.go rename to internal/api/v1/routes.go diff --git a/api/v1/utils.go b/internal/api/v1/utils.go similarity index 100% rename from api/v1/utils.go rename to internal/api/v1/utils.go diff --git a/api/v1/version.go b/internal/api/v1/version.go similarity index 100% rename from api/v1/version.go rename to internal/api/v1/version.go diff --git a/internal/app/.gitkeep b/internal/app/.gitkeep new file mode 100644 index 0000000..89eb1f3 --- /dev/null +++ b/internal/app/.gitkeep @@ -0,0 +1 @@ +Service impl \ No newline at end of file diff --git a/internal/domain/.gitkeep b/internal/domain/.gitkeep new file mode 100644 index 0000000..760c903 --- /dev/null +++ b/internal/domain/.gitkeep @@ -0,0 +1 @@ +Domain models, service contracts \ No newline at end of file diff --git a/pkg/storage/az_blob.go b/internal/infrastructure/connector/az_blob.go similarity index 100% rename from pkg/storage/az_blob.go rename to internal/infrastructure/connector/az_blob.go diff --git a/pkg/storage/az_postgres.go b/internal/infrastructure/connector/az_postgres.go similarity index 100% rename from pkg/storage/az_postgres.go rename to internal/infrastructure/connector/az_postgres.go diff --git a/pkg/storage/az_vault.go b/internal/infrastructure/connector/az_vault.go similarity index 100% rename from pkg/storage/az_vault.go rename to internal/infrastructure/connector/az_vault.go diff --git a/pkg/cryptography/aes.go b/internal/infrastructure/cryptography/aes.go similarity index 100% rename from pkg/cryptography/aes.go rename to internal/infrastructure/cryptography/aes.go diff --git a/pkg/cryptography/ecdsa.go b/internal/infrastructure/cryptography/ecdsa.go similarity index 100% rename from pkg/cryptography/ecdsa.go rename to internal/infrastructure/cryptography/ecdsa.go diff --git a/pkg/cryptography/io.go b/internal/infrastructure/cryptography/io.go similarity index 100% rename from pkg/cryptography/io.go rename to internal/infrastructure/cryptography/io.go diff --git a/pkg/cryptography/rsa.go b/internal/infrastructure/cryptography/rsa.go similarity index 100% rename from pkg/cryptography/rsa.go rename to internal/infrastructure/cryptography/rsa.go diff --git a/internal/persistence/.gitkeep b/internal/persistence/.gitkeep new file mode 100644 index 0000000..e430dec --- /dev/null +++ b/internal/persistence/.gitkeep @@ -0,0 +1 @@ +SQL, NoSQL queries or commands \ No newline at end of file diff --git a/tests/data/.gitignore b/test/data/.gitignore similarity index 100% rename from tests/data/.gitignore rename to test/data/.gitignore diff --git a/test/integration/domain/.gitkeep b/test/integration/domain/.gitkeep new file mode 100644 index 0000000..760c903 --- /dev/null +++ b/test/integration/domain/.gitkeep @@ -0,0 +1 @@ +Domain models, service contracts \ No newline at end of file diff --git a/tests/integration-tests/storage/az_blob_test.go b/test/integration/infrastructure/connector/az_blob_test.go similarity index 100% rename from tests/integration-tests/storage/az_blob_test.go rename to test/integration/infrastructure/connector/az_blob_test.go diff --git a/tests/integration-tests/storage/az_postgres_test.go b/test/integration/infrastructure/connector/az_postgres_test.go similarity index 100% rename from tests/integration-tests/storage/az_postgres_test.go rename to test/integration/infrastructure/connector/az_postgres_test.go diff --git a/tests/integration-tests/storage/az_vault_test.go b/test/integration/infrastructure/connector/az_vault_test.go similarity index 100% rename from tests/integration-tests/storage/az_vault_test.go rename to test/integration/infrastructure/connector/az_vault_test.go diff --git a/test/integration/infrastructure/cryptography/aes_test.go b/test/integration/infrastructure/cryptography/aes_test.go new file mode 100644 index 0000000..ba9890f --- /dev/null +++ b/test/integration/infrastructure/cryptography/aes_test.go @@ -0,0 +1 @@ +// tbd \ No newline at end of file diff --git a/tests/integration-tests/cryptography/encryption_test.go b/test/integration/infrastructure/cryptography/ecdsa_test.go similarity index 100% rename from tests/integration-tests/cryptography/encryption_test.go rename to test/integration/infrastructure/cryptography/ecdsa_test.go diff --git a/tests/integration-tests/cryptography/hashing_test.go b/test/integration/infrastructure/cryptography/io_test.go similarity index 100% rename from tests/integration-tests/cryptography/hashing_test.go rename to test/integration/infrastructure/cryptography/io_test.go diff --git a/tests/unit-tests/cryptography/encryption_test.go b/test/integration/infrastructure/cryptography/rsa_test.go similarity index 100% rename from tests/unit-tests/cryptography/encryption_test.go rename to test/integration/infrastructure/cryptography/rsa_test.go diff --git a/test/integration/persistence/.gitkeep b/test/integration/persistence/.gitkeep new file mode 100644 index 0000000..760c903 --- /dev/null +++ b/test/integration/persistence/.gitkeep @@ -0,0 +1 @@ +Domain models, service contracts \ No newline at end of file diff --git a/test/unit/domain/.gitkeep b/test/unit/domain/.gitkeep new file mode 100644 index 0000000..760c903 --- /dev/null +++ b/test/unit/domain/.gitkeep @@ -0,0 +1 @@ +Domain models, service contracts \ No newline at end of file diff --git a/tests/unit-tests/storage/az_blob_test.go b/test/unit/infrastructure/connector/az_blob_test.go similarity index 100% rename from tests/unit-tests/storage/az_blob_test.go rename to test/unit/infrastructure/connector/az_blob_test.go diff --git a/tests/unit-tests/storage/az_postgres_test.go b/test/unit/infrastructure/connector/az_postgres_test.go similarity index 100% rename from tests/unit-tests/storage/az_postgres_test.go rename to test/unit/infrastructure/connector/az_postgres_test.go diff --git a/tests/unit-tests/storage/az_vault_test.go b/test/unit/infrastructure/connector/az_vault_test.go similarity index 100% rename from tests/unit-tests/storage/az_vault_test.go rename to test/unit/infrastructure/connector/az_vault_test.go diff --git a/test/unit/infrastructure/cryptography/aes_test.go b/test/unit/infrastructure/cryptography/aes_test.go new file mode 100644 index 0000000..ba9890f --- /dev/null +++ b/test/unit/infrastructure/cryptography/aes_test.go @@ -0,0 +1 @@ +// tbd \ No newline at end of file diff --git a/tests/unit-tests/cryptography/hashing_test.go b/test/unit/infrastructure/cryptography/ecdsa_test.go similarity index 100% rename from tests/unit-tests/cryptography/hashing_test.go rename to test/unit/infrastructure/cryptography/ecdsa_test.go diff --git a/test/unit/infrastructure/cryptography/io_test.go b/test/unit/infrastructure/cryptography/io_test.go new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/infrastructure/cryptography/rsa_test.go b/test/unit/infrastructure/cryptography/rsa_test.go new file mode 100644 index 0000000..e69de29 diff --git a/test/unit/persistence/.gitkeep b/test/unit/persistence/.gitkeep new file mode 100644 index 0000000..760c903 --- /dev/null +++ b/test/unit/persistence/.gitkeep @@ -0,0 +1 @@ +Domain models, service contracts \ No newline at end of file