This monorepo is designed to demonstrate a comprehensive setup using Turbo, showcasing various modern development techniques and tools across multiple workspaces. Below is a quick overview to get you started.
The monorepo consists of three workspaces:
-
apps:
- Routing with React Router V6
- Internationalization with i18next
- Progressive Web Apps (PWA)
- Server-Side Rendering (SSR)
- Code Splitting
- Tailwind CSS with Flowbite
-
hms-apps:
- Microservices Architecture with gRPC
- Shadcn/UI components (Shadcn UI)
- Dark/Light Mode Switching (see
mode-toggle.tsx
in/components
) - Data Grid with useReactTable (see
DisplayUsers.tsx
) - Navigation (Shadcn UI Navigation Menu)
- React Query for server state management (see
App.tsx
andUsers.tsx
)
-
packages:
- Shared libraries (Turbo Handbook)
Follow these steps to set up the monorepo:
-
Install Global Dependencies:
npm install -g @nestjs/cli turbo copyfiles
-
Clone the Repository:
git clone https://github.com/piosystems/turbo-nest-grpc-vite-react-ssr-tailwind-pwa-i18n-template.git cd turbo-nest-grpc-vite-react-ssr-tailwind-pwa-i18n-template
-
Install Local Dependencies:
npm install
-
Protocol Buffers: To modify
.proto
files and generate corresponding TypeScript files, download Protocol Buffers from the official releases. Use the following script for generating TypeScript files:"../protoc-25.1-osx-x86_64/bin/protoc --plugin=../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./ --ts_proto_opt=nestJs=true ./proto/identity.proto"
- Start Development Servers:
- For the
apps
workspace:npm run dev
- For the
hms-apps
workspace:npm run hms:dev
- For the
-
Build Applications:
- For the
apps
workspace:npm run build
- For the
hms-apps
workspace:npm run hms:build
- For the
-
Update Asset Map: If there are changes to the code or CSS before building, update the
main.js
andstyles.css
entries in theassetMap
located inapps/demo-backend/src/backend.settings.ts
. Re-run the build after adjustments.
-
Start/Stop Production Services:
- To start services with PM2:
npm run hms:start:all
- To stop services with PM2:
npm run hms:stop:all
- To start services with PM2:
-
Preview Users-Demo Frontend: After building, you can preview the
users-demo-frontend
by running:npm run preview
After successfully starting the applications, you can access them via the following URLs:
-
apps workspace:
-
hms-apps workspace:
- After building and running the preview:
-
API Gateway:
- Accessible via
npm run hms:start:all
:
- Accessible via
The following features have been successfully implemented:
-
Static Serving: The
users-demo-frontend
is now served statically from the API gateway, eliminating the need for a separate preview process. Access it via http://localhost:3002/v1/view-users. -
Enhancements: SSR, PWA, Internationalization, and other enhancements have been integrated, following the pattern used in the
apps
template where thedemo-frontend
is served from thedemo-backend
with SSR and other features. -
TypeORM Integration: The
hms-apps/identity/src/users
now utilizes TypeORM for entity management, replacing the previous hardcoded array implementation.