Skip to content

Commit 036e198

Browse files
committed
update readme
1 parent decdaaf commit 036e198

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

project/README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
15
## Layout
26

37
This Turborepo includes the following packages/apps:
48

59
### Apps
610

7-
- `web`: another [Next.js](https://nextjs.org/) app
11+
- `web`: [Next.js](https://nextjs.org/) app for the frontend
812
- `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
1014

1115
### Packages
1216

1317
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`)
1418
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo
19+
- `@repo/dtos`: Shared DTOs and Zod schemas
20+
- `@repo/pipes`: Shared NestJS pipes
1521

1622
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
1723

@@ -20,6 +26,10 @@ Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
2026
- [TypeScript](https://www.typescriptlang.org/) for static type checking
2127
- [ESLint](https://eslint.org/) for code linting
2228
- [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
2333

2434
### Build
2535

@@ -37,3 +47,68 @@ To develop all apps and packages, run the following command:
3747
pnpm install
3848
pnpm dev
3949
```
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

Comments
 (0)