Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
Twenty is an open-source CRM designed to provide a modern, extensible, and community-driven platform. It aims to offer a better user experience by learning from the shortcomings of existing CRMs and building a cohesive interface inspired by tools like Notion and Airtable. The project is built on the belief that open-source can create a powerful ecosystem, free from the vendor lock-in and high costs associated with proprietary software.
This guide provides a comprehensive overview for developers to get started with the Twenty project, covering local setup, self-hosting, application development, and contributing to the codebase. The project is a monorepo managed by Nx and Yarn, with a clear separation between the frontend, backend, and various supporting packages.
Sources: README.md:15-23, CLAUDE.md:5-6
Architecture Overview
Twenty is built as an Nx monorepo with a modern tech stack. The backend and frontend are distinct packages, communicating via a GraphQL API.
Sources: CLAUDE.md:49-53
Tech Stack
| Layer | Technology | Description |
|---|---|---|
| Monorepo | Nx, Yarn 4 | Manages the workspace and dependencies. |
| Frontend | React 18, TypeScript, Vite | For the main application UI. |
| State Management | Recoil, Apollo Client | Global state and GraphQL cache management. |
| Styling | Emotion | CSS-in-JS styling with a styled-components pattern. |
| Backend | NestJS, GraphQL Yoga | API server built with a code-first GraphQL approach. |
| Database | PostgreSQL, TypeORM | Primary relational database and ORM. |
| Caching/Jobs | Redis, BullMQ | Used for caching, session management, and background job processing. |
| Analytics | ClickHouse | Optional analytics database. |
Sources: CLAUDE.md:49-68, README.md:112-116
Package Structure
The monorepo is organized into several packages within the packages/ directory, each with a specific responsibility.
This diagram illustrates the high-level structure of the Twenty monorepo.
twenty-front/: The main React frontend application.twenty-server/: The NestJS backend API server.twenty-ui/: A shared library of UI components used by the frontend.twenty-shared/: Common types and utilities shared between packages.twenty-emails/: Email templates built with React Email.twenty-docs/: The official documentation site, powered by Mintlify.create-twenty-app/: Scaffolding CLI for creating new Twenty applications.twenty-sdk/: CLI and SDK for developing and publishing applications.
Sources: CLAUDE.md:55-64, packages/create-twenty-app/README.md:11, packages/twenty-sdk/README.md:11
Local Development Setup
To start developing on Twenty locally, you need to set up the development environment, which includes the frontend, backend, and background worker.
The following flowchart shows the steps to get the local development environment running.
Key Development Commands
A set of nx commands are available to manage the development lifecycle.
| Command | Description |
|---|---|
yarn start | Starts the complete development environment (frontend, backend, worker). |
npx nx start twenty-front | Starts only the frontend development server. |
npx nx start twenty-server | Starts only the backend server. |
npx nx run twenty-server:worker | Starts the background job worker. |
npx nx test <package> | Runs unit tests for a specific package. |
npx nx lint <package> | Lints a specific package. |
npx nx build <package> | Builds a specific package for production. |
npx nx run twenty-server:database:reset | Resets the development database. |
npx nx run twenty-front:graphql:generate | Generates GraphQL types for the frontend. |
Sources: CLAUDE.md:10-45
Self-Hosting
Twenty provides multiple options for self-hosting, with Docker Compose being the primary method supported by the core team. Community-maintained options for Kubernetes are also available.
Sources: README.md:32-33, packages/twenty-docker/k8s/README.md:2-4
Docker Compose (Recommended)
The recommended way to self-host is using Docker Compose. Detailed instructions are available in the official documentation.
Sources: README.md:32, packages/twenty-docs/docs.json:115-122
Kubernetes
For more complex deployments, Kubernetes manifests and Terraform configurations are provided by the community. These files require customization for your specific environment.
Prerequisites:
- A running Kubernetes cluster
kubectlterraform- Docker
Deployment Steps (using kubectl):
- Clone the repository: `git clone https://github.com/twentyhq/twenty.git%60
- Navigate to the k8s directory:
cd twenty/packages/twenty-docker/k8s - Create the required server secret:
kubectl create secret generic -n twentycrm tokens --from-literal accessToken=changeme --from-literal loginToken="changeme" --from-literal refreshToken="changeme" --from-literal fileToken="changeme" - Apply the manifests:
kubectl apply -f .
Sources: packages/twenty-docker/k8s/README.md:10-43
Building Custom Applications
Twenty is designed to be extensible through custom applications. The create-twenty-app package and the twenty-sdk provide the tools to scaffold, develop, and sync these applications with your Twenty workspace.
Sources: packages/create-twenty-app/README.md:11-14, packages/twenty-sdk/README.md:11-14
Scaffolding with create-twenty-app
This is the quickest way to start a new Twenty app.
Prerequisites:
- Node.js 24+ and Yarn 4
- A Twenty workspace and an API key.
The following sequence diagram shows the workflow for creating and deploying a new application.
Quick Start Commands:
# Create a new app project
npx create-twenty-app@latest my-twenty-app
cd my-twenty-app
# Authenticate with your Twenty workspace
yarn auth
# Add a new entity to your app
yarn create-entity
# Generate typed clients from your workspace schema
yarn generate
# Start dev mode for automatic syncing
yarn dev
# Or run a one-time sync
yarn sync
Sources: packages/create-twenty-app/README.md:21-44
Using the twenty-sdk
The twenty-sdk provides the core CLI commands for app development, which are wrapped by the scripts in a create-twenty-app project. You can also use it directly in an existing project.
twenty-sdk Command | Description |
|---|---|
twenty auth login | Authenticate using your API key. |
twenty app add | Add a new entity to your application via guided prompts. |
twenty app generate | Generate a typed Twenty client and TypeScript definitions. |
twenty app dev | Start dev mode to automatically sync local changes. |
twenty app sync | Perform a one-time sync of local changes. |
twenty app uninstall | Uninstall the application from the workspace. |
Sources: packages/twenty-sdk/README.md:29-48
Contributing
Contributions are welcome, whether to the core product or the documentation.
Code Contributions
- Fork the repository.
- Make your changes following the development principles (e.g., functional components, named exports).
- Run linting (
npx nx lint <package>) and testing (npx nx test <package>) to ensure quality. - Submit a pull request.
First-time contributors will be prompted to agree to the Contributor License Agreement (CLA).
Sources: CLAUDE.md:66-73, dangerfile.ts:28-41
Documentation Contributions
The documentation is located in packages/twenty-docs and is built using Mintlify.
- Fork the repository.
- Make changes to the MDX files in the
user-guide/,developers/, ortwenty-ui/directories. - Test your changes locally by running
npx nx run twenty-docs:devfrom the monorepo root. - Submit a pull request.