App structure

Systems, services, APIs, oh my


Encore is designed around the application. A single Encore application should contain all the backend logic for your whole product.

Don't worry about splitting up a large application into multiple smaller ones; Encore is designed to scale to large code bases, and provides the best developer experience when all the functionality is contained in the same Encore application.

Structure

Encore divides applications into systems, services, and components. See the backend architecture best practices guide for more information on this structure.

In Encore, services are represented as Go packages (see defining services for more information). To group related services together into a system, you can move the related service packages within a subdirectory (that represents the system) within the project.

Example

For example, a Trello clone might consist of two systems: the Trello system (for managing trello boards & cards), the User system (for user and organization management, and authentication), and the Premium system (for subscriptions and paid features).

On disk it might look like this:

/my-trello-clone
├── encore.app       // ... and other top-level project files
│
├── premium          // premium system
│   ├── payment      // payment service
│   └── subscription // subscription service
│
├── trello           // trello system
│   ├── board        // board service
│   └── card         // card service
│
└── usr              // user system
    ├── org          // org service
    └── user         // user service

Each service consists of Go files that implement the service business logic, database migrations for defining the structure of the database(s), and so on. See the docs on defining services for more information on what this structure looks like.