encr.dev

module
v1.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: MPL-2.0

README

encore icon

Encore – Backend Development Platform

Encore provides a purpose-built workflow to help you create event-driven and distributed systems — from local development to your cloud on AWS & GCP.

It consists of a Backend SDK, a Local Development Environment with tools like tracing, and a Cloud Platform for automating CI/CD and cloud infrastructure provisioning.

🏁 Try Encore: Quick Start Guide

💻 See example apps: Example Apps Repo

🚀 Discover products built with Encore: Showcase

⭐ Star this repository to help spread the word.

👋 Have questions? Join the friendly developer community on Discord.

📞 See if Encore fits your project: Book a 1:1 intro.

🍿 Intro video

Watch the intro video for a quick introduction to Encore concepts & code examples.

Encore Intro Video

Introduction to Encore

Cloud services enable us to build highly scalable applications, but often lead to a poor developer experience — forcing developers to manage significant complexity during development and do a lot of repetitive manual work.

Encore is purpose-built to solve this problem and provides a complete toolset for backend development — from local development and testing, to cloud infrastructure management and DevOps.

Encore Overview

How it works

Encore's Open Source Backend SDK, available for Go and TypeScript, lets you define resources like services, databases, cron jobs, and Pub/Sub, as type-safe objects in your application code.

With the Backend SDK you only define infrastructure semanticsthe things that matter to your application's behavior — not configuration for specific cloud services. Encore parses your application and builds a graph of both its logical architecture and its infrastructure requirements, it then automatically generates boilerplate and orchestrates the relevant infrastructure for each environment. This means your application code can be used to run locally, test in preview environments, and provision and deploy to cloud environments on AWS and GCP.

This completely removes the need for separate infrastructure configuration like Terraform, increases standardization in both your codebase and infrastructure, and makes your application portable across cloud providers by default.

When your application is deployed to your cloud, there are no runtime dependencies on Encore and there is no proprietary code running in your cloud.

Example: Hello World

Defining microservices and API endpoints is incredibly simple, requiring less than 10 lines of code to define a production-ready deployable service and API endpoint.

Using the TypeScript Backend SDK, it looks like so:

import { api } from "encore.dev/api";

export const get = api(
  { expose: true, method: "GET", path: "/hello/:name" },
  async ({ name }: { name: string }): Promise<Response> => {
    const msg = `Hello ${name}!`;
    return { message: msg };
  }
);

interface Response {
  message: string;
}

Using the Go Backend SDK, it looks like so:

package hello

//encore:api public
func Ping(ctx context.Context, params *PingParams) (*PingResponse, error) {
    msg := fmt.Sprintf("Hello, %s!", params.Name)
    return &PingResponse{Message: msg}, nil
}

Example: Using Pub/Sub

If you want a Pub/Sub Topic, you declare it directly in your application code and Encore will automatically provision the infrastructure and generate the boilerplate code necessary for each environment:

  • NSQ for local development
  • GCP Pub/Sub for environments on GCP
  • SNS/SQS for environments on AWS

Using the TypeScript Backend SDK, it looks like so:

import { Topic } "encore.dev/pubsub"

export interface SignupEvent {
    userID: string;
}

export const signups = new Topic<SignupEvent>("signups", {
    deliveryGuarantee: "at-least-once",
});

Using the Go Backend SDK, it looks like so:

import "encore.dev/pubsub"
 
type User struct { /* fields... */ }
 
var Signup = pubsub.NewTopic[*User]("signup", pubsub.TopicConfig{
  DeliveryGuarantee: pubsub.AtLeastOnce,
})
 
// Publish messages by calling a method
Signup.Publish(ctx, &User{...})

Learn more in the docs

See how to use the Backend SDK in the docs:

Using Encore: An end-to-end workflow from local to cloud

Encore provides purpose-built tooling for each step in the development process, from local development and testing, to cloud DevOps. Here we'll cover the key features for each part of the process.

Local Development

Local Development

When you run your app locally using the Encore CLI, Encore parses your code and automatically sets up the necessary local infrastructure on the fly. No more messing around with Docker Compose!

You also get built-in tools for an efficient workflow when creating distributed systems and event-driven applications:

  • Local environment matches cloud: Encore automatically handles the semantics of service communication and interfacing with different types of infrastructure services, so that the local environment is a 1:1 representation of your cloud environment.
  • Cross-service type-safety: When building microservices applications with Encore, you get type-safety and auto-complete in your IDE when making cross-service API calls.
  • Type-aware infrastructure: With Encore, infrastructure like Pub/Sub queues are type-aware objects in your program. This enables full end-to-end type-safety when building event-driven applications.
  • Secrets management: Built-in secrets management for all environments.
  • Tracing: The local development dashboard provides local tracing to help understand application behavior and find bugs.
  • Automatic API docs & clients: Encore generates API docs and API clients in Go, TypeScript, JavaScript, and OpenAPI specification.

Here's a video showing the local development dashboard:

https://github.com/encoredev/encore/assets/78424526/4d066c76-9e6c-4c0e-b4c7-6b2ba6161dc8

Testing

testing

Encore comes with several built-in tools to help with testing:

  • Built-in service/API mocking: Encore provides built-in support for mocking API calls, and interfaces for automatically generating mock objects for your services.
  • Local test infra: When running tests locally, Encore automatically provides dedicated test infrastructure to isolate individual tests.
  • Local test tracing: The local dev dashboard provides distributed tracing for tests, providing great visibility into what's happening and making it easier to understand why a test failed.
  • Preview Environments: Encore automatically provisions a Preview Environment for each Pull Request, an effective tool when doing end-to-end testing.

DevOps

DevOps

With Encore you can focus your engineering effort on your product and avoid investing time in building a developer platform.

A core feature Encore provides is automatic infrastructure provisioning in your cloud. Because your application code is the source of truth for the application's infrastructure requirements, instead of writing Terraform, YAML, or clicking in cloud consoles, you connect your cloud account and deploy. This approach also lets you swap out your infrastructure over time, without needing to make code changes or manually update infrastructure config files.

When you deploy, Encore automatically provisions infrastructure using battle-tested cloud services on AWS and GCP, such as:

  • Compute: GCP Cloud Run, AWS Fargate, Kubernetes (GKE and EKS)
  • Databases: GCP Cloud SQL, AWS RDS
  • Pub/Sub: GCP Pub/Sub, AWS SQS/SNS
  • Caches: GCP Memorystore, Amazon ElastiCache
  • Secrets: GCP Secret Manager, AWS Secrets Manager
  • Etc.

Encore also provides built-in DevOps tools to help automate >90% of the day-to-day DevOps work:

  • Automatic least-privilege IAM: Encore parses your application code and sets up least-privilege IAM to match the requirements of the application.
  • Infra tracking & approvals workflow: Encore keeps track of all the infrastructure it provisions and provides an approval workflow as part of the deployment process, so Admins can verify and approve all infra changes.
  • Cloud config 2-way sync: Encore provides a simple UI to make configuration changes, and also supports syncing changes you make in your cloud console on AWS/GCP.
  • Cost analytics: A simple overview to monitor costs for all infrastructure provisioned by Encore in your cloud.
  • Logging & Metrics: Encore automatically provides logging, metrics, and integrates with 3rd party tools like Datadog and Grafana.
  • Service Catalog: Encore automatically generates a service catalog with complete API documentation.
  • Architecture diagrams: To help with onboarding and collaboration, Encore generates architecture diagrams for your application, including infrastructure dependencies.
  • Extensible through Encore's Terraform Provider: Extend your system with any infrastructure services you need, integration is simple because all infrastructure is provisioned in your cloud. Encore also has a Terraform Provider to simplify this process.

Here's a video showing the Cloud Platform Dashboard:

https://github.com/encoredev/encore/assets/78424526/8116b387-d4d4-4e54-8768-3686ba0245f5

Why use Encore?

  • Faster Development: Encore streamlines the development process with its Backend SDK, clear abstractions, and built-in development tools, enabling you to build and deploy applications more quickly.
  • Reduced Costs: Encore's automatic infrastructure management minimizes wasteful cloud expenses and reduces DevOps workload, allowing you to work more efficiently.
  • Scalability & Performance: Encore simplifies building large-scale microservices applications that can handle growing user bases and demands, without the normal boilerplate and complexity.
  • Control & Standardization: Built-in tools like automated architecture diagrams, infrastructure tracking and approval workflows, make it easy for teams and leaders to get an overview of the entire application.
  • Security & Compliance: Encore helps ensure your application is secure and compliant by enforcing security standards and provisioning infrastructure according to best practices for each cloud provider.

Common use cases

Encore is designed to give teams a productive and less complex experience when solving most backend use cases. Many teams use Encore to build things like:

  • High-performance B2B Platforms
  • Fintech & Consumer apps
  • Global E-commerce marketplaces
  • Microservices backends for SaaS applications and mobile apps
  • And much more...

Getting started

Open Source

Everything needed to develop and deploy Encore applications is Open Source, including the Backend SDK, parser, compiler, runtime, and CLI. This includes all code needed for local development and everything that runs in your cloud.

The Open Source CLI also provides a mechanism to generate a standalone Docker image for your application, so you easily self-host your application. Learn more in the docs.

Join the most pioneering developer community

Developers building with Encore are forward-thinkers who want to focus on creative programming and building great software to solve meaningful problems. It's a friendly place, great for exchanging ideas and learning new things! Join the conversation on Discord.

We rely on your contributions and feedback to improve Encore for everyone who is using it. Here's how you can contribute:

  • Star and watch this repository to help spread the word and stay up to date.
  • Meet fellow Encore developers and chat on Discord.
  • Follow Encore on Twitter.
  • Share feedback or ask questions via email.
  • Leave feedback on the Public Roadmap.
  • Send a pull request here on GitHub with your contribution.

Videos

Visuals

Code example (Go)

https://github.com/encoredev/encore/assets/78424526/f511b3fe-751f-4bb8-a1da-6c9e0765ac08

Local Development Dashboard

https://github.com/encoredev/encore/assets/78424526/4c659fb8-e9ec-4f14-820b-c2b8d35e5359

Generated Architecture Diagrams & Service Catalog

https://github.com/encoredev/encore/assets/78424526/a880ed2d-e9a6-4add-b5a8-a4b44b97587b

Auto-Provisioning Infrastructure & Multi-cloud Deployments

https://github.com/encoredev/encore/assets/78424526/8116b387-d4d4-4e54-8768-3686ba0245f5

Distributed Tracing & Metrics

https://github.com/encoredev/encore/assets/78424526/35189335-e3d7-4046-bab0-1af0f00d2504

Frequently Asked Questions (FAQ)

Who's behind Encore?

Encore was founded by long-time backend engineers from Spotify, Google, and Monzo with over 50 years of collective experience. We’ve lived through the challenges of building complex distributed systems with thousands of services, and scaling to hundreds of millions of users.

Encore grew out of these experiences and is a solution to the frustrations that came with them: unnecessary crippling complexity and constant repetition of undifferentiated work that suffocates the developer’s creativity. With Encore, we want to set developers free to achieve their creative potential.

Who is Encore for?

For individual developers building for the cloud, Encore provides a radically improved experience. With Encore you’re able to stay in the flow state and experience the joy and creativity of building.

For startup teams who need to build a scalable backend to support the growth of their product, Encore lets them get up and running in the cloud within minutes. It lets them focus on solving the needs of their users, instead of spending most of their time re-solving the everyday challenges of building distributed systems in the cloud.

For individual teams in large organizations that want to focus on innovating and building new features, Encore lets them stop spending time on operations and onboarding new team members. Using Encore for new feature development is easy, just spin up a new backend service in a few minutes.

How is Encore different?

Encore is the only tool that understands what you’re building. Encore uses static analysis to deeply understand the application you’re building. This enables a unique developer experience that helps you stay in the flow as you’re building. For instance, you don't need to bother with configuring and managing infrastructure, setting up environments and keeping them in sync, or writing documentation and drafting architecture diagrams. Encore does all of this automatically out of the box.

Unlike many tools that aim to only make cloud deployment easier, Encore is not a cloud hosting provider. With Encore, you can use your cloud account with AWS and GCP. This means you’re in control of your data and can maintain your trust relationship with your cloud provider. You can also use Encore's development cloud for free, with pretty generous "fair use" limits.

Why does Encore provide integrations with a cloud platform?

We've found that to meaningfully improve the developer experience, you have to operate across the full stack. Unless you understand how an application is deployed, there are a large number of things in the development process that you can't simplify. That's why so many other developer tools have such a limited impact. With Encore's more integrated approach, we're able to unlock a radically better experience for developers.

What if I want to migrate away from Encore?

Encore is designed to let you go outside of the Backend SDK when you want to, and easily drop down in abstraction level when you need to, so you never run into any dead-ends.

Should you want to migrate away, it's straightforward and does not require a big rewrite. 99% of your code is regular Go or TypeScript and the code specific to Encore is limited to using the Backend SDK.

Encore has support for self-hosting your application, by using the Open Source CLI to produce a standalone Docker image that can be deployed anywhere you'd like.

We believe that adopting Encore is a low-risk decision, given it needs no initial investment in foundational work. The ambition is to simply add a lot of value to your everyday development process, from day one.

Contributing to Encore and building from source

See CONTRIBUTING.md.

Directories

Path Synopsis
cli
cmd/git-remote-encore
Command git-remote-encore provides a gitremote helper for interacting with Encore's git hosting without SSH keys, by piggybacking on Encore's auth tokens.
Command git-remote-encore provides a gitremote helper for interacting with Encore's git hosting without SSH keys, by piggybacking on Encore's auth tokens.
daemon
Package daemon implements the Encore daemon gRPC server.
Package daemon implements the Encore daemon gRPC server.
daemon/dash
Package dash serves the Encore Developer Dashboard.
Package dash serves the Encore Developer Dashboard.
daemon/dash/dashproxy
Package dashproxy proxies requests to the dash server, caching them locally for offline access.
Package dashproxy proxies requests to the dash server, caching them locally for offline access.
daemon/internal/manifest
Package manifest reads and writes Encore app manifests.
Package manifest reads and writes Encore app manifests.
daemon/internal/sym
Package sym parses symbol tables from Go binaries.
Package sym parses symbol tables from Go binaries.
daemon/run
Package run starts and tracks running Encore applications.
Package run starts and tracks running Encore applications.
daemon/secret
Package secret fetches and caches development secrets for Encore apps.
Package secret fetches and caches development secrets for Encore apps.
daemon/sqldb/external
Package external implements a cluster driver for an external cluster.
Package external implements a cluster driver for an external cluster.
internal/browser
Package browser provides utilities for interacting with users' browsers.
Package browser provides utilities for interacting with users' browsers.
internal/gosym
Package gosym implements access to the Go symbol and line number tables embedded in Go binaries generated by the gc compilers.
Package gosym implements access to the Go symbol and line number tables embedded in Go binaries generated by the gc compilers.
internal/jsonrpc2
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
Package jsonrpc2 is a minimal implementation of the JSON RPC 2 spec.
internal/jsonrpc2/servertest
Package servertest provides utilities for running tests against a remote LSP server.
Package servertest provides utilities for running tests against a remote LSP server.
internal/login
Package login handles login and authentication with Encore's platform.
Package login handles login and authentication with Encore's platform.
internal
clientgen
Package clientgen generates code for use with Encore apps.
Package clientgen generates code for use with Encore apps.
conf
Package conf writes and reads the Encore configuration file for the user.
Package conf writes and reads the Encore configuration file for the user.
env
Package env answers where Encore tools and resources are located.
Package env answers where Encore tools and resources are located.
gocodegen
Package gocodegen contains shared code used for generating Go code by both the compilers code generator, and the CLI's client generator.
Package gocodegen contains shared code used for generating Go code by both the compilers code generator, and the CLI's client generator.
goldfish
Package goldfish provides a short-term cache of values.
Package goldfish provides a short-term cache of values.
parser
pkg
ansi
Package ansi provides helper functions for writing ANSI terminal escape codes.
Package ansi provides helper functions for writing ANSI terminal escape codes.
appfile
Package appfile reads and writes encore.app files.
Package appfile reads and writes encore.app files.
editors
Package editors is a Go Port of [GitHub Desktop's editor code](https://github.com/desktop/desktop/tree/development/app/src/lib/editors)
Package editors is a Go Port of [GitHub Desktop's editor code](https://github.com/desktop/desktop/tree/development/app/src/lib/editors)
eerror
Package eerror stands for Encore Error and is used to provide a little more information about the underlying error's metadata.
Package eerror stands for Encore Error and is used to provide a little more information about the underlying error's metadata.
fns
github
Package github provides utilities for interacting with GitHub repositories.
Package github provides utilities for interacting with GitHub repositories.
scrub/metascrub
Package metascrub computes scrub paths for a metadata type.
Package metascrub computes scrub paths for a metadata type.
svcproxy
Package svcproxy provides an HTTP proxy which allows the daemon to serve HTTP requests on behalf of services within the app and forward then to the appropriate process.
Package svcproxy provides an HTTP proxy which allows the daemon to serve HTTP requests on behalf of services within the app and forward then to the appropriate process.
vcs
vfs
Package vfs represents a virtual filesystem
Package vfs represents a virtual filesystem
xos
Package xos provides cross-platform helper functions.
Package xos provides cross-platform helper functions.
tools
v2
app
compiler/build
Package build supports building and testing Encore applications with codegen and rewrite overlays.
Package build supports building and testing Encore applications with codegen and rewrite overlays.
internals/perr
Package perr provides utilities for handling parse errors.
Package perr provides utilities for handling parse errors.
internals/resourcepaths
Package resourcepaths parses API and other resource paths.
Package resourcepaths parses API and other resource paths.
internals/schema
Package schema implements parsing of Go types into Encore's schema format.
Package schema implements parsing of Go types into Encore's schema format.
internals/schema/schematest
Package schematest provides utilities for writing tests that make assertions about schema types and declarations.
Package schematest provides utilities for writing tests that make assertions about schema types and declarations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL