# Forse Growth Agent Monorepo This repository is a pnpm + Turborepo monorepo with the following workspaces: - `backend`: Express + TypeScript API server - `frontend`: Next.js 14 app - `packages/tsconfig`: Shared TypeScript configs - `packages/types`: Shared TypeScript types (`@forse/types`) ## Prerequisites - Node.js 18+ (LTS recommended) - pnpm (this repo uses the root `pnpm-lock.yaml`) ## Install ```bash pnpm install ``` ## Develop Runs dev servers in parallel via Turborepo: ```bash pnpm dev ``` Typical dev URLs: - Backend API: http://localhost:3001 (check server config) - Frontend: http://localhost:3000 ## Build ```bash pnpm build ``` Notes: - `build` depends on `codegen` in the Turbo pipeline. - Backend generates `backend/openapi.json` during `codegen`. ## Codegen Run all code generation tasks across the monorepo: ```bash pnpm codegen ``` - Backend: generates OpenAPI spec (`backend/openapi.json`). - Frontend and shared packages provide no-op `codegen` scripts to keep the pipeline consistent. ## Lint and Test ```bash pnpm lint pnpm test ``` ## Workspaces - `backend` depends on `@forse/types` for shared TypeScript types. - `frontend` imports types from `@forse/types` directly. The legacy shim `frontend/lib/types/dynamic-form.ts` has been removed. ## Turborepo The Turbo pipeline is defined in `turbo.json`: - `dev`: non-cached, persistent processes - `codegen`: writes `**/openapi.json` - `build`: depends on `^build` and `codegen`, outputs `dist/**`, `.next/**`, and OpenAPI artifacts Common scripts at the repo root: ```bash pnpm dev # turbo run dev --parallel pnpm build # turbo run build pnpm codegen # turbo run codegen pnpm lint # turbo run lint pnpm test # turbo run test ``` ## Backend Key scripts: ```bash pnpm --filter ./backend dev pnpm --filter ./backend codegen pnpm --filter ./backend build pnpm --filter ./backend start ``` OpenAPI: - Generate: `pnpm --filter ./backend codegen` - Served at `/docs` when `openapi.json` exists (generated at build/codegen) Database: - Migrations via Knex CLI - Per-organisation schemas: we use schema-per-org (e.g. `org_polygon`, `org_rootstock`). Org schemas are created automatically when organizations are seeded. Local dev setup: ```bash # Run migrations pnpm --filter ./backend run migrate:dev # Seed dev data pnpm --filter ./backend run seed:dev:ts ``` Reset database (keeps Docker running): ```bash pnpm --filter ./backend run seed:reset:dev pnpm --filter ./backend run migrate:dev pnpm --filter ./backend run seed:dev:ts ``` Verify in psql: ```sql \dn -- list schemas \dt org_polygon.* -- list tables in org_polygon schema SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema='org_polygon'; ``` ## Frontend Key scripts: ```bash pnpm --filter ./frontend dev pnpm --filter ./frontend build pnpm --filter ./frontend start ``` Imports: - Use `@forse/types` for shared types. ## Conventions - One lockfile at repo root only. No nested `pnpm-lock.yaml` in packages. - Prefer workspace protocol `workspace:*` for internal deps. - Keep `packages/types` as type-only exports; no runtime side effects. ## Troubleshooting - If the docs at `/docs` 404, run `pnpm --filter ./backend codegen`. - If builds don’t see generated artifacts, ensure `pnpm codegen` runs and check `turbo.json` outputs include `openapi.json`. :) :)