Codebase

Codebase Overview

Overview of the Directus codebase for new contributors

The directus/directus repository includes the Data Studio, Directus Connect, the JavaScript SDK, and a number of smaller packages used internally. All of these live in a single monorepo.

Data Studio

This contains the Directus Data Studio App, written in Vue.js 3. /app/public contains assets that are included with the app, but not bundled. The source code is located in /app/src with the following directories:

DirectoryContent
/assetsFiles that are included within the app. Are bundled and optimized in the build step.
/components(Base) components that are used across the platform. Contains "basic building blocks" like button, input, etc.
/composablesReusable parts of reactive logic that can be used between Vue components. Includes things reactively calculating time from now, fetching a single item, etc.
/directivesCustom Vue directives (e.g. v-tooltip).
/displaysComponents to display single pieces of data within the app.
/interfacesThe core-included interfaces that allow editing and viewing individual pieces of data.
/langTranslations abstraction, and language files. The language yaml files are maintained through Crowdin.
/layoutsThe core-included layouts that change the way items are represented inside the collection view.
/modulesThe core-included modules that structure major parts of the app.
/operationsOperations are steps in a flow.
/panelsPanels display data in the insight dashboards.
/routesThe routes in the app. Modules define their own routes, so this only includes the "system" things that don't belong to the module, like login.
/storesPinia based stores used for global state tracking.
/stylesAll general styles, CSS variables, mixins and themes are stored inside here. Every component has their own component styles, these are just the global styles.
/typesTypeScript types that are shared between the different parts of the App.
/utilsUtility functions used in various parts of the app.
/viewsThe (two) main views used in the app: public / private. Also contains "internal" coupled components for those two views.

Directus ships with a UI Library that you can use in app extensions.

Directus Connect

This directory contains the Directus REST and GraphQL APIs written in Node.js. The source code is located in /api/src.

DirectoryContent
/cliThe CLI commands and matching functions that the directus package ships with.
/controllersRoute handler controllers for the endpoints in the API.
/databaseDatabase manipulation abstraction, system migrations, and system data. Also where you'd find the main query runner.
/errorsClasses for the different errors the API is expected to throw. Used to set the HTTP status and error codes.
/middlewareVarious (express) routing middleware. Includes things like cache-checker, authenticator, etc.
/servicesInternal services. The main abstraction for interfacing with the data in the database. Both GraphQL and REST requests are "translated" to use these services as the main logic in the platform.
/typesTypeScript types that are shared between the different parts of the API.
/utilsVarious utility functions.

Packages

The /packages directory modularizes smaller parts of the Directus project into separate packages.

Package NameDescription
create-directus-extensionA small util that will scaffold a Directus extension.
create-directus-projectA small installer util that will create a directory, add boilerplate folders, and install Directus through npm.
@directus/composablesShared Vue composables for use in Directus.
@directus/constantsShared constants for Directus.
@directus/envEnvironment variable configuration extraction for Directus.
@directus/errorsUtility functions to help creating and checking against Directus errors.
@directus/extensions-registryAbstraction for exploring Directus extensions on a package registry.
@directus/extensions-sdkA toolkit to develop extensions to extend Directus.
@directus/extensionsShared utilities, types and constants related to Directus extensions.
@directus/format-titleCustom formatter that converts any string into Title Case.
@directus/memoryMemory / Redis abstraction for Directus.
@directus/pressurePressure based rate limiter.
@directus/randomSet of random-utilities for use in tests.
@directus/release-notes-generatorPackage that generates release notes for Directus monorepo.
@directus/schemaUtility for extracting information about the database schema.
@directus/specsOpenAPI Specification of the Directus API.
@directus/storage-driver-azureAzure file storage abstraction for @directus/storage.
@directus/storage-driver-cloudinaryCloudinary file storage abstraction for @directus/storage.
@directus/storage-driver-gcsGCS file storage abstraction for @directus/storage.
@directus/storage-driver-localLocal file storage abstraction for @directus/storage.
@directus/storage-driver-s3S3 file storage abstraction for @directus/storage.
@directus/storage-driver-supabaseSupabase file storage driver for @directus/storage.
@directus/storageObject storage abstraction layer for Directus.
@directus/storesShared Data Studio state for use in components, extensions, and the @directus/app routes. Stores use Pinia.
@directus/system-dataDefinitions and types for Directus system collections.
@directus/tsconfigThe shared TS Config files used by the projects in the Directus ecosystem.
@directus/typesShared types for Directus.
@directus/update-checkCheck if an update is available for a given package.
@directus/utilsUtilities shared between the Directus packages.

JavaScript SDK

The /sdk directory contains the Directus JavaScript SDK available as @directus/sdk package.

Tests

Tests (/tests) are maintained on a per-package base. This folder contains the platform-wide (end-to-end) tests. See Tests for more information.