This repository contains a small monorepo with a frontend (Vite + React), a backend (Express + Socket.io), and shared packages (@openchat/lib, @openchat/components).
This README explains how to get the project running locally and developer recommendations.
Requirements
This repository contains a monorepo for OpenChat:
apps/frontend— Vite + React clientapps/backend— Express + Socket.io server (with Prisma schema)packages/lib— shared utilities (helpers, socket client)packages/components— shared UI components
This README covers how to set up the project locally, common workflows for developing across the workspace, and troubleshooting tips.
- Node.js: >= 20.19 (20.x recommended). Use
nvmto manage Node versions — a.nvmrcis included. - pnpm: v7+ (workspace-aware). Install with
npm i -g pnpmif needed.
- Use the recommended Node version:
nvm install
nvm use
node -v # should be >= 20.19 (20.x recommended)- Install dependencies (from repo root):
pnpm install- Run development servers:
pnpm run dev:all # runs frontend + backend concurrently (defined in root package.json)
# or run individually
pnpm --filter frontend dev
pnpm --filter backend devOpen the frontend URL printed by Vite (typically http://localhost:5173). The backend listens on port 3001 by default.
VITE_SOCKET_URL— frontend socket URL (default:http://localhost:3001). Use this in.envat the frontend root if needed.PORTorSOCKET_PORT— backend port (default:3001).
Create an .env file in apps/frontend or apps/backend for local overrides when needed.
To build all packages and apps in the workspace:
pnpm -w -r buildTo build a single package/app (example frontend):
pnpm --filter frontend buildIf you change the Prisma schema (apps/backend/prisma/schema.prisma) apply migrations locally with:
cd apps/backend
pnpm prisma migrate devOr generate clients only:
pnpm prisma generate- Import shared code using the workspace package names, e.g.:
import { cn, socket } from '@openchat/lib'
import { Button } from '@openchat/components'-
During development, the Vite config and TypeScript path mappings resolve those imports to the local
src/folders so you can edit packages in place. -
When editing a package (
packages/liborpackages/components), run that package's build (or run the workspace build) so consuming apps get the latestdist/outputs when necessary:
pnpm --filter @openchat/lib build
pnpm -w -r build- Avoid committing generated JS inside
src/of packages. Onlydist/should contain build artifacts. - The repo includes clean scripts in packages to remove stray
.jsinsrcbefore building. To run all clean scripts:
pnpm -w -r run clean- Install dependencies:
pnpm install - Start frontend dev:
pnpm --filter frontend dev - Start backend dev:
pnpm --filter backend dev - Start both:
pnpm run dev:all - Build everything:
pnpm -w -r build - Run workspace tests (if any):
pnpm -w -r test
-- If Vite fails with Node crypto errors, you're likely on an unsupported Node version. Switch to Node 20.x (>=20.19):
nvm install 20
nvm use 20-
If shared imports resolve incorrectly, verify
tsconfig.jsonpathsandapps/frontend/vite.config.*aliases are present. They map@openchat/*to the packages'srcfolders. -
If Tailwind styles don't appear in a consuming app, check PostCSS configuration and ensure
@tailwindand@importordering is correct in the app'sindex.css.
- If you plan to publish packages, add an
exportsfield to each package'spackage.jsonand produce both ESM and CJS outputs in the build. For internal development the TypeScript path mappings and Vite aliases are sufficient.
- Create a new folder under
apps/orpackages/. - Add a
package.jsonwith the workspace name (e.g.@openchat/yourpkg). - Add TypeScript sources under
src/and update rootpnpm -w -r buildif needed. - Add path mappings in the root
tsconfig.jsonif you want to import it by package name during dev.
This repository does not include any CI/workflow configuration by default. If you want CI, I can add a GitHub Actions workflow that uses Node 20 and runs builds, linting, and tests.
If you'd like, I can:
- Remove remaining generated JS files under
src/across the repo and addprebuildscripts to enforce a clean source tree. - Add
exportsfields to allpackage.jsonfiles and produce ESM+CJS builds. - Integrate Tailwind + shadcn into
apps/frontend(or add it to other apps) and wire workspace imports for UI components.
Tell me which of the above you'd like next and I will implement it.