diff --git a/README.md b/README.md
index 06b49ea..2f70b6a 100644
--- a/README.md
+++ b/README.md
@@ -54,14 +54,15 @@ You can use `npx nx list` to get a list of installed plugins. Then, run `npx nx
## Architecture
-| Layer | Description |
-| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| dto(presentation) | Define DTOs for GraphQL schema. |
-| resolver(presentation) | Define GraphQL schema and resolver. |
-| mongoose(infrastructure) | Implements the repository interfaces defined in the domain layer using Mongoose as the ODM (Object Document Mapper).
Includes Mongoose Schema definitions, database connection management, and concrete implementations of repository interfaces (e.g., MongooseUserRepository). |
-| use-case(application) | Define business use cases and encapsulate business logic. |
-| entity(domain) | Define core business entities and business rules.
Maintain entity independence from database and framework. |
-| repository(domain) | Interfaces (or abstract classes), which define methods for manipulating data without concern for specific database implementations.
By defining this interface, we can decouple database access: the specific details of data access will be done by implementation classes, such as specific implementations using tools like Mongoose, TypeORM, Prisma, and so on. |
+| Layer | Description |
+| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| resolver(interface-adapters) | Define GraphQL schema and resolver. |
+| dto(interface-adapters) | Define DTOs for GraphQL schema. |
+| mongoose(infrastructure) | Implements the repository interfaces defined in the domain layer using Mongoose as the ODM (Object Document Mapper).
Includes Mongoose Schema definitions, database connection management, and concrete implementations of repository interfaces (e.g., MongooseUserRepository). |
+| service(application) | As the core of the application layer, it mainly interacts with the domain layer and interface-adapter layer.
If you migrate to a non-NestJS architecture in the future (e.g. other frameworks or microservices), the application tier code can be left unaffected. |
+| use-case(application) | Define business use cases and encapsulate business logic. |
+| entity(domain) | Define core business entities and business rules.
Maintain entity independence from database and framework. |
+| repository(domain) | Interfaces (or abstract classes), which define methods for manipulating data without concern for specific database implementations.
By defining this interface, we can decouple database access: the specific details of data access will be done by implementation classes, such as specific implementations using tools like Mongoose, TypeORM, Prisma, and so on. |
## Useful links
diff --git a/apps/users-e2e/src/users/users.spec.ts b/apps/users-e2e/src/users/users.spec.ts
index b33e9ba..b8a64e1 100644
--- a/apps/users-e2e/src/users/users.spec.ts
+++ b/apps/users-e2e/src/users/users.spec.ts
@@ -5,6 +5,6 @@ describe('GET /', () => {
const res = await axios.get(`/`);
expect(res.status).toBe(200);
- expect(res.data).toEqual({ message: 'Hello User Service' });
+ expect(res.data).toEqual({ message: 'Hello Users Module' });
});
});
diff --git a/apps/users/src/app/app.controller.spec.ts b/apps/users/src/app/app.controller.spec.ts
index b37ff64..125eb8d 100644
--- a/apps/users/src/app/app.controller.spec.ts
+++ b/apps/users/src/app/app.controller.spec.ts
@@ -14,10 +14,10 @@ describe('AppController', () => {
});
describe('getData', () => {
- it('should return "Hello User Service"', () => {
+ it('should return "Hello Users Module"', () => {
const appController = app.get(AppController);
expect(appController.getData()).toEqual({
- message: 'Hello User Service',
+ message: 'Hello Users Module',
});
});
});
diff --git a/apps/users/src/app/app.module.ts b/apps/users/src/app/app.module.ts
index 297ca1f..d09ad89 100644
--- a/apps/users/src/app/app.module.ts
+++ b/apps/users/src/app/app.module.ts
@@ -1,10 +1,11 @@
-import { databaseConfig, userAppConfig } from '@shared/config';
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
+import { databaseConfig, userAppConfig } from '@shared/config';
+
+import { UsersModule } from '../users/users.module';
import { AppController } from './app.controller';
import { AppService } from './app.service';
-import { UsersModule } from '../users/users.module';
@Module({
imports: [
diff --git a/apps/users/src/app/app.service.spec.ts b/apps/users/src/app/app.service.spec.ts
index e9eea2e..55bea7e 100644
--- a/apps/users/src/app/app.service.spec.ts
+++ b/apps/users/src/app/app.service.spec.ts
@@ -14,8 +14,8 @@ describe('AppService', () => {
});
describe('getData', () => {
- it('should return "Hello User Service"', () => {
- expect(service.getData()).toEqual({ message: 'Hello User Service' });
+ it('should return "Hello Users Module"', () => {
+ expect(service.getData()).toEqual({ message: 'Hello Users Module' });
});
});
});
diff --git a/apps/users/src/app/app.service.ts b/apps/users/src/app/app.service.ts
index b0af72b..45117a2 100644
--- a/apps/users/src/app/app.service.ts
+++ b/apps/users/src/app/app.service.ts
@@ -3,6 +3,6 @@ import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getData(): { message: string } {
- return { message: 'Hello User Service' };
+ return { message: 'Hello Users Module' };
}
}
diff --git a/apps/users/src/users/users.module.ts b/apps/users/src/users/users.module.ts
index d8436ae..1ec9dce 100644
--- a/apps/users/src/users/users.module.ts
+++ b/apps/users/src/users/users.module.ts
@@ -1,12 +1,12 @@
+import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
import {
ApolloFederationDriver,
ApolloFederationDriverConfig,
} from '@nestjs/apollo';
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
-import { UsersResolver } from '@users/presentation-resolver';
import { UsersService } from '@users/application';
-import { ApolloServerPluginInlineTrace } from '@apollo/server/plugin/inlineTrace';
+import { UsersResolver } from '@users/interface-adapters';
import { DatabaseModule } from '@shared/infrastructure-mongoose';
@Module({
diff --git a/libs/users/interface-adapters/README.md b/libs/users/interface-adapters/README.md
new file mode 100644
index 0000000..d5ab9f5
--- /dev/null
+++ b/libs/users/interface-adapters/README.md
@@ -0,0 +1,7 @@
+# users-interface-adapters
+
+This library was generated with [Nx](https://nx.dev).
+
+## Running unit tests
+
+Run `nx test users-interface-adapters` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/users/interface-adapters/eslint.config.js b/libs/users/interface-adapters/eslint.config.js
new file mode 100644
index 0000000..07e518f
--- /dev/null
+++ b/libs/users/interface-adapters/eslint.config.js
@@ -0,0 +1,3 @@
+const baseConfig = require('../../../eslint.config.js');
+
+module.exports = [...baseConfig];
diff --git a/libs/users/presentation/dto/jest.config.ts b/libs/users/interface-adapters/jest.config.ts
similarity index 55%
rename from libs/users/presentation/dto/jest.config.ts
rename to libs/users/interface-adapters/jest.config.ts
index dce5b33..71c209d 100644
--- a/libs/users/presentation/dto/jest.config.ts
+++ b/libs/users/interface-adapters/jest.config.ts
@@ -1,10 +1,10 @@
export default {
- displayName: 'users-presentation-dto',
- preset: '../../../../jest.preset.js',
+ displayName: 'users-interface-adapters',
+ preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
- coverageDirectory: '../../../../coverage/libs/users/presentation/dto',
+ coverageDirectory: '../../../coverage/libs/users/interface-adapters',
};
diff --git a/libs/users/interface-adapters/project.json b/libs/users/interface-adapters/project.json
new file mode 100644
index 0000000..96041ca
--- /dev/null
+++ b/libs/users/interface-adapters/project.json
@@ -0,0 +1,9 @@
+{
+ "name": "users-interface-adapters",
+ "$schema": "../../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "libs/users/interface-adapters/src",
+ "projectType": "library",
+ "tags": [],
+ "// targets": "to see all targets run: nx show project users-interface-adapters --web",
+ "targets": {}
+}
diff --git a/libs/users/interface-adapters/src/index.ts b/libs/users/interface-adapters/src/index.ts
new file mode 100644
index 0000000..e2b92de
--- /dev/null
+++ b/libs/users/interface-adapters/src/index.ts
@@ -0,0 +1,4 @@
+// dto
+export * from './lib/dto/user.dto';
+// resolver
+export * from './lib/resolver/users.resolver';
diff --git a/libs/users/presentation/dto/src/lib/user.dto.spec.ts b/libs/users/interface-adapters/src/lib/dto/user.dto.spec.ts
similarity index 100%
rename from libs/users/presentation/dto/src/lib/user.dto.spec.ts
rename to libs/users/interface-adapters/src/lib/dto/user.dto.spec.ts
diff --git a/libs/users/presentation/dto/src/lib/user.dto.ts b/libs/users/interface-adapters/src/lib/dto/user.dto.ts
similarity index 100%
rename from libs/users/presentation/dto/src/lib/user.dto.ts
rename to libs/users/interface-adapters/src/lib/dto/user.dto.ts
diff --git a/libs/users/presentation/resolver/src/lib/users.resolver.spec.ts b/libs/users/interface-adapters/src/lib/resolver/users.resolver.spec.ts
similarity index 100%
rename from libs/users/presentation/resolver/src/lib/users.resolver.spec.ts
rename to libs/users/interface-adapters/src/lib/resolver/users.resolver.spec.ts
diff --git a/libs/users/presentation/resolver/src/lib/users.resolver.ts b/libs/users/interface-adapters/src/lib/resolver/users.resolver.ts
similarity index 93%
rename from libs/users/presentation/resolver/src/lib/users.resolver.ts
rename to libs/users/interface-adapters/src/lib/resolver/users.resolver.ts
index 764a759..ca63644 100644
--- a/libs/users/presentation/resolver/src/lib/users.resolver.ts
+++ b/libs/users/interface-adapters/src/lib/resolver/users.resolver.ts
@@ -1,7 +1,8 @@
import { Args, ID, Query, Resolver, ResolveReference } from '@nestjs/graphql';
import { UsersService } from '@users/application';
import { User } from '@users/domain';
-import { UserDto } from '@users/presentation-dto';
+
+import { UserDto } from '../dto/user.dto';
@Resolver(() => UserDto)
export class UsersResolver {
diff --git a/libs/users/presentation/dto/tsconfig.json b/libs/users/interface-adapters/tsconfig.json
similarity index 90%
rename from libs/users/presentation/dto/tsconfig.json
rename to libs/users/interface-adapters/tsconfig.json
index 07e0ec6..0dc79ca 100644
--- a/libs/users/presentation/dto/tsconfig.json
+++ b/libs/users/interface-adapters/tsconfig.json
@@ -1,5 +1,5 @@
{
- "extends": "../../../../tsconfig.base.json",
+ "extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
diff --git a/libs/users/presentation/resolver/tsconfig.lib.json b/libs/users/interface-adapters/tsconfig.lib.json
similarity index 85%
rename from libs/users/presentation/resolver/tsconfig.lib.json
rename to libs/users/interface-adapters/tsconfig.lib.json
index 28369ef..e583571 100644
--- a/libs/users/presentation/resolver/tsconfig.lib.json
+++ b/libs/users/interface-adapters/tsconfig.lib.json
@@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
- "outDir": "../../../../dist/out-tsc",
+ "outDir": "../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
diff --git a/libs/users/presentation/resolver/tsconfig.spec.json b/libs/users/interface-adapters/tsconfig.spec.json
similarity index 84%
rename from libs/users/presentation/resolver/tsconfig.spec.json
rename to libs/users/interface-adapters/tsconfig.spec.json
index 6668655..69a251f 100644
--- a/libs/users/presentation/resolver/tsconfig.spec.json
+++ b/libs/users/interface-adapters/tsconfig.spec.json
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
- "outDir": "../../../../dist/out-tsc",
+ "outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
diff --git a/libs/users/presentation/dto/README.md b/libs/users/presentation/dto/README.md
deleted file mode 100644
index 447a3e3..0000000
--- a/libs/users/presentation/dto/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# users-presentation-dto
-
-This library was generated with [Nx](https://nx.dev).
-
-## Running unit tests
-
-Run `nx test users-presentation-dto` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/users/presentation/dto/eslint.config.js b/libs/users/presentation/dto/eslint.config.js
deleted file mode 100644
index cdd3cba..0000000
--- a/libs/users/presentation/dto/eslint.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-const baseConfig = require('../../../../eslint.config.js');
-
-module.exports = [...baseConfig];
diff --git a/libs/users/presentation/dto/project.json b/libs/users/presentation/dto/project.json
deleted file mode 100644
index a87f550..0000000
--- a/libs/users/presentation/dto/project.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "name": "users-presentation-dto",
- "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
- "sourceRoot": "libs/users/presentation/dto/src",
- "projectType": "library",
- "tags": [],
- "// targets": "to see all targets run: nx show project users-presentation-dto --web",
- "targets": {}
-}
diff --git a/libs/users/presentation/dto/src/index.ts b/libs/users/presentation/dto/src/index.ts
deleted file mode 100644
index a234d86..0000000
--- a/libs/users/presentation/dto/src/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './lib/user.dto';
diff --git a/libs/users/presentation/dto/tsconfig.lib.json b/libs/users/presentation/dto/tsconfig.lib.json
deleted file mode 100644
index 28369ef..0000000
--- a/libs/users/presentation/dto/tsconfig.lib.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "module": "commonjs",
- "outDir": "../../../../dist/out-tsc",
- "declaration": true,
- "types": ["node"]
- },
- "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
- "include": ["src/**/*.ts"]
-}
diff --git a/libs/users/presentation/dto/tsconfig.spec.json b/libs/users/presentation/dto/tsconfig.spec.json
deleted file mode 100644
index 6668655..0000000
--- a/libs/users/presentation/dto/tsconfig.spec.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "extends": "./tsconfig.json",
- "compilerOptions": {
- "outDir": "../../../../dist/out-tsc",
- "module": "commonjs",
- "types": ["jest", "node"]
- },
- "include": [
- "jest.config.ts",
- "src/**/*.test.ts",
- "src/**/*.spec.ts",
- "src/**/*.d.ts"
- ]
-}
diff --git a/libs/users/presentation/resolver/README.md b/libs/users/presentation/resolver/README.md
deleted file mode 100644
index 30d3458..0000000
--- a/libs/users/presentation/resolver/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# users-presentation-resolver
-
-This library was generated with [Nx](https://nx.dev).
-
-## Running unit tests
-
-Run `nx test users-presentation-resolver` to execute the unit tests via [Jest](https://jestjs.io).
diff --git a/libs/users/presentation/resolver/eslint.config.js b/libs/users/presentation/resolver/eslint.config.js
deleted file mode 100644
index cdd3cba..0000000
--- a/libs/users/presentation/resolver/eslint.config.js
+++ /dev/null
@@ -1,3 +0,0 @@
-const baseConfig = require('../../../../eslint.config.js');
-
-module.exports = [...baseConfig];
diff --git a/libs/users/presentation/resolver/jest.config.ts b/libs/users/presentation/resolver/jest.config.ts
deleted file mode 100644
index 96ea3cb..0000000
--- a/libs/users/presentation/resolver/jest.config.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export default {
- displayName: 'users-presentation-resolver',
- preset: '../../../../jest.preset.js',
- testEnvironment: 'node',
- transform: {
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }],
- },
- moduleFileExtensions: ['ts', 'js', 'html'],
- coverageDirectory: '../../../../coverage/libs/users/presentation/resolver',
-};
diff --git a/libs/users/presentation/resolver/project.json b/libs/users/presentation/resolver/project.json
deleted file mode 100644
index ec728b4..0000000
--- a/libs/users/presentation/resolver/project.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "name": "users-presentation-resolver",
- "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
- "sourceRoot": "libs/users/presentation/resolver/src",
- "projectType": "library",
- "tags": [],
- "// targets": "to see all targets run: nx show project users-presentation-resolver --web",
- "targets": {}
-}
diff --git a/libs/users/presentation/resolver/src/index.ts b/libs/users/presentation/resolver/src/index.ts
deleted file mode 100644
index 281b820..0000000
--- a/libs/users/presentation/resolver/src/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './lib/users.resolver';
diff --git a/libs/users/presentation/resolver/tsconfig.json b/libs/users/presentation/resolver/tsconfig.json
deleted file mode 100644
index 07e0ec6..0000000
--- a/libs/users/presentation/resolver/tsconfig.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "extends": "../../../../tsconfig.base.json",
- "compilerOptions": {
- "module": "commonjs",
- "forceConsistentCasingInFileNames": true,
- "strict": true,
- "noImplicitOverride": true,
- "noImplicitReturns": true,
- "noFallthroughCasesInSwitch": true,
- "noPropertyAccessFromIndexSignature": true
- },
- "files": [],
- "include": [],
- "references": [
- {
- "path": "./tsconfig.lib.json"
- },
- {
- "path": "./tsconfig.spec.json"
- }
- ]
-}
diff --git a/tsconfig.base.json b/tsconfig.base.json
index cd1cedb..b0b2056 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -20,15 +20,14 @@
"@shared/infrastructure-mongoose": [
"libs/shared/infrastructure/mongoose/src/index.ts"
],
- "@users/domain": ["libs/users/domain/src/index.ts"],
"@users/application": ["libs/users/application/src/index.ts"],
+ "@users/domain": ["libs/users/domain/src/index.ts"],
"@users/infrastructure-mongoose": [
"libs/users/infrastructure/mongoose/src/index.ts"
],
- "@users/presentation-dto": ["libs/users/presentation/dto/src/index.ts"],
- "@users/presentation-resolver": [
- "libs/users/presentation/resolver/src/index.ts"
- ]
+ "@users/interface-adapters": [
+ "libs/users/interface-adapters/src/index.ts"
+ ],
}
},
"exclude": ["node_modules", "tmp"]