Skip to main content
Figentra is a TypeScript monorepo framework that ships a suite of typed packages, enforced coding standards, and ready-made architectural patterns so your team spends less time on boilerplate and more time shipping features. This guide walks you through everything from installing the core packages to writing your first contract and throwing a typed error — all in under five minutes.
1

Prerequisites

Before you begin, make sure your development environment meets the following requirements:Figentra is designed to live inside a monorepo workspace. It works with both Turborepo and plain pnpm workspaces. If you already have a workspace, skip to the next step. If you are starting from scratch, the next step covers the minimal setup.
Run node -v and pnpm -v in your terminal to verify the installed versions before continuing.
2

Create your workspace

Initialize a new monorepo workspace and configure pnpm to recognise your packages directory.
Create a pnpm-workspace.yaml file at the repository root to tell pnpm where your packages live:
pnpm-workspace.yaml
If you are using Turborepo, add a turbo.json at the root as well:
turbo.json
3

Add your first Figentra packages

Install the two core Figentra packages you will use in this guide. Run the following command from the root of your monorepo:
The -w flag installs the packages into the workspace root so every app and package in your monorepo can import them without repeating the install.
Always pin all @figentra/* packages to the same version. Mixing versions across packages in the same workspace can lead to subtle type mismatches at compile time.
4

Define a contract

Contracts are the heart of Figentra — they are plain TypeScript interfaces that describe the shape of your data and service boundaries, enforced at the type level across your entire monorepo.Create a new file in your packages directory:
packages/core/src/contracts/user.contract.ts
The defineContract helper attaches metadata — a name and a semver string — to your interface so Figentra can surface meaningful diagnostics when contract versions drift between services.
packages/core/src/services/user.service.ts
5

Handle errors

Figentra provides @figentra/error for typed, structured errors that carry a machine-readable code alongside the human-readable message — making error handling consistent across every service boundary.
packages/core/src/services/user.service.ts
FigentraError extends the native Error class, so it is fully compatible with any existing try/catch logic. The code field lets downstream callers branch on error type without parsing message strings.
Use ErrorCode.VALIDATION for input validation failures and ErrorCode.UNAUTHORIZED for access-control checks. See the Packages Overview for the full list of built-in codes.
6

Run your tests

Figentra’s typed packages are compatible with any test runner. If you have @figentra/testing installed, you get a pre-configured test environment with contract assertion helpers out of the box.
A minimal test for the service you just wrote might look like this:
packages/core/src/services/user.service.test.ts
If pnpm test exits without running any files, confirm that your test runner is configured to pick up .test.ts files. Check vitest.config.ts or your jest.config.ts for the include glob pattern.

You now have a working Figentra setup with a typed contract and structured error handling. Explore what to build next:

Architecture Overview

Understand how Figentra organises packages, enforces boundaries, and scales across large monorepos.

Packages Overview

Browse every first-party @figentra/* package, its API surface, and recommended usage patterns.