You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: project/README.md
+77-2Lines changed: 77 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,23 @@
1
+
# Project
2
+
3
+
This Turborepo includes a Next.js frontend, a NestJS API gateway, and NestJS microservices, using shadcn/ui for CSS and Zod for validation.
4
+
1
5
## Layout
2
6
3
7
This Turborepo includes the following packages/apps:
4
8
5
9
### Apps
6
10
7
-
-`web`: another [Next.js](https://nextjs.org/) app
11
+
-`web`: [Next.js](https://nextjs.org/) app for the frontend
8
12
-`api-gateway`: [NestJS](https://nestjs.com/) backend serving as an entry point into microservices
9
-
-`questions-service`: [NestJS](https://nestjs.com/) backend handling all questions related functions.
13
+
-`questions-service`: [NestJS](https://nestjs.com/) backend handling all questions related functions
10
14
11
15
### Packages
12
16
13
17
-`@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
14
18
-`@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
19
+
-`@repo/dtos`: Shared DTOs and Zod schemas
20
+
-`@repo/pipes`: Shared NestJS pipes
15
21
16
22
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
17
23
@@ -20,6 +26,10 @@ Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
20
26
-[TypeScript](https://www.typescriptlang.org/) for static type checking
21
27
-[ESLint](https://eslint.org/) for code linting
22
28
-[Prettier](https://prettier.io) for code formatting
29
+
-[shadcn/ui](https://ui.shadcn.com/) for CSS
30
+
-[Zod](https://zod.dev/) for validation
31
+
32
+
## Getting Started
23
33
24
34
### Build
25
35
@@ -37,3 +47,68 @@ To develop all apps and packages, run the following command:
37
47
pnpm install
38
48
pnpm dev
39
49
```
50
+
51
+
## Development Guide
52
+
53
+
### Frontend Development
54
+
55
+
The frontend is located in `apps/web`. This is a Next.js application where you'll develop your user interface.
56
+
57
+
### Creating a New Microservice
58
+
59
+
To create a new microservice:
60
+
61
+
1. Navigate to the `apps` directory
62
+
2. Run the following command:
63
+
```
64
+
nest new {service} --strict --skip-git --package-manager=pnpm
65
+
```
66
+
Replace `{service}` with the name of your new microservice.
67
+
68
+
### Integrating a New Microservice
69
+
70
+
After creating a new microservice, you need to integrate it with the API gateway:
71
+
72
+
1. Register the microservice client in `api-gateway/src/api-gateway-module.ts`
73
+
2. Create a new controller within `api-gateway/src/{service}` which redirects requests to the microservice. You can follow the format of `api-gateway/src/questions/questions.controller.ts`
74
+
75
+
### Shared Packages
76
+
77
+
-`packages/dtos`: This is where we define our schemas and DTOs using Zod. These can be shared across the frontend and backend, and are used for validation pipes on the backend.
78
+
-`packages/pipes`: This is where we store pipes to be shared across NestJS apps.
79
+
80
+
### Using Shared Packages
81
+
82
+
To use packages in other packages or apps:
83
+
84
+
1. Add the package name (found in that package's `package.json`) to the `package.json` of your target app or package.
85
+
2. You can then import it in your code.
86
+
87
+
### Validation
88
+
89
+
We use Zod for validation across the project. Define your schemas in `packages/dtos`, and use them for both frontend and backend validation.
90
+
91
+
### Styling
92
+
93
+
We use shadcn/ui for CSS. Refer to the [shadcn/ui documentation](https://ui.shadcn.com/) for usage instructions.
94
+
95
+
## Best Practices
96
+
97
+
- Keep your microservices small and focused on a specific domain.
98
+
- Use the shared DTOs for consistency between frontend and backend.
99
+
- Leverage the API gateway for cross-cutting concerns like authentication.
100
+
- Write unit tests for your services and controllers.
101
+
- Use Zod schemas for both runtime validation and TypeScript type inference.
102
+
103
+
## Troubleshooting
104
+
105
+
If you encounter any issues:
106
+
107
+
1. Ensure all dependencies are installed with `pnpm install`
108
+
2. Check that you're using the correct Node.js version (specified in `.nvmrc`)
109
+
3. Clear your build cache with `pnpm clean`
110
+
4. If problems persist, please open an issue in the repository
111
+
112
+
## Contributing
113
+
114
+
Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.) backend handling all questions related functions.
0 commit comments