671de4170f
- Migrated developer docs to Twenty website - Modified User Guide and Docs layout to include sections and subsections **Section Example:** <img width="549" alt="Screenshot 2024-05-30 at 15 44 42" src="https://github.com/twentyhq/twenty/assets/102751374/41bd4037-4b76-48e6-bc79-48d3d6be9ab8"> **Subsection Example:** <img width="557" alt="Screenshot 2024-05-30 at 15 44 55" src="https://github.com/twentyhq/twenty/assets/102751374/f14c65a9-ab0c-4530-b624-5b20fc00511a"> - Created different components (Tabs, Tables, Editors etc.) for the mdx files **Tabs & Editor** <img width="665" alt="Screenshot 2024-05-30 at 15 47 39" src="https://github.com/twentyhq/twenty/assets/102751374/5166b5c7-b6cf-417d-9f29-b1f674c1c531"> **Tables** <img width="698" alt="Screenshot 2024-05-30 at 15 57 39" src="https://github.com/twentyhq/twenty/assets/102751374/2bbfe937-ec19-4004-ab00-f7a56e96db4a"> <img width="661" alt="Screenshot 2024-05-30 at 16 03 32" src="https://github.com/twentyhq/twenty/assets/102751374/ae95b47c-dd92-44f9-b535-ccdc953f71ff"> - Created a crawler for Twenty Developers (now that it will be on the twenty website). Once this PR is merged and the website is re-deployed, we need to start crawling and make sure the index name is ‘twenty-developer’ - Added a dropdown menu in the header to access User Guide and Developers + added Developers to footer https://github.com/twentyhq/twenty/assets/102751374/1bd1fbbd-1e65-4461-b18b-84d4ddbb8ea1 - Made new layout responsive Please fill in the information for each mdx file so that it can appear on its card, as well as in the ‘In this article’ section. Example with ‘Getting Started’ in the User Guide: <img width="786" alt="Screenshot 2024-05-30 at 16 29 39" src="https://github.com/twentyhq/twenty/assets/102751374/2714b01d-a664-4ddc-9291-528632ee12ea"> Example with info and sectionInfo filled in for 'Getting Started': <img width="620" alt="Screenshot 2024-05-30 at 16 33 57" src="https://github.com/twentyhq/twenty/assets/102751374/bc69e880-da6a-4b7e-bace-1effea866c11"> Please keep in mind that the images that are being used for Developers are the same as those found in User Guide and may not match the article. --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
132 lines
3.9 KiB
Plaintext
132 lines
3.9 KiB
Plaintext
---
|
|
title: Folder Architecture
|
|
info: A detailed look into our server folder architecture
|
|
icon: TbFolder
|
|
image: /images/user-guide/fields/field.png
|
|
---
|
|
|
|
|
|
The backend directory structure is as follows:
|
|
|
|
```
|
|
server
|
|
└───ability
|
|
└───constants
|
|
└───core
|
|
└───database
|
|
└───decorators
|
|
└───filters
|
|
└───guards
|
|
└───health
|
|
└───integrations
|
|
└───metadata
|
|
└───workspace
|
|
└───utils
|
|
```
|
|
|
|
## Ability
|
|
|
|
Defines permissions and includes handlers for each entity.
|
|
|
|
## Decorators
|
|
|
|
Defines custom decorators in NestJS for added functionality.
|
|
|
|
See [custom decorators](https://docs.nestjs.com/custom-decorators) for more details.
|
|
|
|
## Filters
|
|
|
|
Includes exception filters to handle exceptions that might occur in GraphQL endpoints.
|
|
|
|
## Guards
|
|
|
|
See [guards](https://docs.nestjs.com/guards) for more details.
|
|
|
|
## Health
|
|
|
|
Includes a publicly available REST API (healthz) that returns a JSON to confirm whether the database is working as expected.
|
|
|
|
## Metadata
|
|
|
|
Defines custom objects and makes available a GraphQL API (graphql/metadata).
|
|
|
|
## Workspace
|
|
|
|
Generates and serves custom GraphQL schema based on the metadata.
|
|
|
|
### Workspace Directory Structure
|
|
|
|
```
|
|
workspace
|
|
|
|
└───workspace-schema-builder
|
|
└───factories
|
|
└───graphql-types
|
|
└───database
|
|
└───interfaces
|
|
└───object-definitions
|
|
└───services
|
|
└───storage
|
|
└───utils
|
|
└───workspace-resolver-builder
|
|
└───factories
|
|
└───interfaces
|
|
└───workspace-query-builder
|
|
└───factories
|
|
└───interfaces
|
|
└───workspace-query-runner
|
|
└───interfaces
|
|
└───utils
|
|
└───workspace-datasource
|
|
└───workspace-manager
|
|
└───workspace-migration-runner
|
|
└───utils
|
|
└───workspace.module.ts
|
|
└───workspace.factory.spec.ts
|
|
└───workspace.factory.ts
|
|
```
|
|
|
|
|
|
The root of the workspace directory includes the `workspace.factory.ts`, a file containing the `createGraphQLSchema` function. This function generates workspace-specific schema by using the metadata to tailor a schema for individual workspaces. By separating the schema and resolver construction, we use the `makeExecutableSchema` function, which combines these discrete elements.
|
|
|
|
This strategy is not just about organization, but also helps with optimization, such as caching generated type definitions to enhance performance and scalability.
|
|
|
|
### Workspace Schema builder
|
|
|
|
Generates the GraphQL schema, and includes:
|
|
|
|
#### Factories:
|
|
|
|
Specialised constructors to generate GraphQL-related constructs.
|
|
- The type.factory translates field metadata into GraphQL types using `TypeMapperService`.
|
|
- The type-definition.factory creates GraphQL input or output objects derived from `objectMetadata`.
|
|
|
|
#### GraphQL Types
|
|
|
|
Includes enumerations, inputs, objects, and scalars, and serves as the building blocks for the schema construction.
|
|
|
|
#### Interfaces and Object Definitions
|
|
|
|
Contains the blueprints for GraphQL entities, and includes both predefined and custom types like `MONEY` or `URL`.
|
|
|
|
#### Services
|
|
|
|
Contains the service responsible for associating FieldMetadataType with its appropriate GraphQL scalar or query modifiers.
|
|
|
|
#### Storage
|
|
|
|
Includes the `TypeDefinitionsStorage` class that contains reusable type definitions, preventing duplication of GraphQL types.
|
|
|
|
### Workspace Resolver Builder
|
|
|
|
Creates resolver functions for querying and mutatating the GraphQL schema.
|
|
|
|
Each factory in this directory is responsible for producing a distinct resolver type, such as the `FindManyResolverFactory`, designed for adaptable application across various tables.
|
|
|
|
### Workspace Query Builder
|
|
|
|
Includes factories that generate `pg_graphql` queries.
|
|
|
|
### Workspace Query Runner
|
|
|
|
Runs the generated queries on the database and parses the result. |