From da07789a3e294591d06319b8bfabd151fe77e5a6 Mon Sep 17 00:00:00 2001 From: devleejb Date: Thu, 8 Feb 2024 11:49:49 +0900 Subject: [PATCH] Add architecture documentation --- backend/design/README.md | 1 + backend/design/architecture.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 backend/design/architecture.md diff --git a/backend/design/README.md b/backend/design/README.md index 65f8c9ae..65235cb7 100644 --- a/backend/design/README.md +++ b/backend/design/README.md @@ -2,6 +2,7 @@ ## Contents +- [Architecture](./architecture.md): The architecture of CodePair's NestJS backend - [Yorkie Auth Webhook](./auth-webhook.md): Auth Webhook to prevent users from accessing unauthorized documents using a Public Key ## Maintaining the Document diff --git a/backend/design/architecture.md b/backend/design/architecture.md new file mode 100644 index 00000000..2b24d096 --- /dev/null +++ b/backend/design/architecture.md @@ -0,0 +1,33 @@ +# Yorkie Auth Webhook + +This document covers ㅅhe architecture of CodePair's NestJS backend. + +## Architecture + +Below is the diagram of the CodePair Backend Architecture. Currently, it adheres to the default architecture that can be generated through [NestJS CLI](https://docs.nestjs.com/cli/overview). +If you want to add a new component, you can use the command `nest generate controller [CONTROLLER_NAME]`. + +``` + CodePair Backend + ┌───────┐ ┌──────────────────────────────────────────────────────────────────────┐ + │Request├─────►│ │ + └───────┘ │ ┌────┐ ┌─────┐ ┌──────────┐ ┌───────┐ ┌──────────┐ │ + │ │Pipe│────►│Guard│────►│Controller│────►│Service│────►│Repository│ │ +┌────────┐ │ └────┘ └─────┘ └──────────┘ └───────┘ └──────────┘ │ +│Response│◄─────┤ │ +└────────┘ └──────────────────────────────────────────────────────────────────────┘ + +``` + +- Pipe: Handles data transformation/validation in the request/response pipeline. +- Guard: Implements access control and validation logic for routes. +- Controller: Defines the endpoints/routes and their corresponding request handling logic. +- Service: Contains the business logic and performs operations required by the application. +- Repository: Handles data persistence and retrieval operations from the data source. + +Note that the naming for the Repository Layer is `PrismaService`. + +## Note + +For now, we are using the architecture recommended by NestJS as a reference. +However, in the future, we can evolve towards implementing Clean Architecture by introducing interfaces between each layer. \ No newline at end of file