Skip to main content

Microservices

Designing, testing, and deploying microservices is a huge undertaking involving infrastructure design, network security, complex CI pipelines, and more. But Architect makes all that easier with one simple feature - dependencies.

Every language and operating system on earth has tools for managing and injecting dependencies into applications, but developers lack similar tools for integrating microservices.

Developers can use Architect to declare their API and microservice dependencies, and every time they deploy Architect will guarantee their dependencies exist. If they don't, Architect will deploy them!

Designing a microservices app

To get an understanding of how microservices can use dependency management, let's create a few different Architect components.

  1. A payments component responsible for securing credit card details and processing payments
  2. An auth component responsible for user credentials and authentication
  3. A backend component that will be the primary API our webapp uses, and
  4. A frontend component that will be the website our users interact with

Be sure to look at the dependencies block for each component to see how they all relate to each other.

name: frontend

dependencies: backend: {} auth: {}

services: app: image: my-frontend-image:latest interfaces: main: port: 8080 environment:
BACKEND_ADDR:
${{ dependencies.backend.services.api.interfaces.main.url }} AUTH_URL:
${{ dependencies.auth.services.api.interfaces.main.url }}

Note that the frontend component only depends on the backend component, but if you were to deploy it you'd see that all 4 components would get deployed.

By analyzing the full dependency graph for you, Architect helps developers focus less on what they know about their own applications instead of having to learn the web of dependencies underneath them.

Registering components

Architect resolves dependencies by calling out to the Architect Cloud registry to find matching components and pull them into the target environment. That means that components need to be registered with Architect Cloud before they can be used as dependencies.

To show how the registration works, let's create and register components like the ones described earlier:

# Create and register the auth component
$ architect init auth
$ architect register ./auth --tag latest --account my-account

# Create and register the payments component
$ architect init payments
$ architect register ./payments --tag latest --account my-account

## Create and register the backend component
$ architect init backend
$ vim ./backend/architect.yml # Make sure to update the `dependencies` to include the `auth` and `payments` components
$ architect register ./backend --tag latest --account my-account

## Create and run the frontend
$ architect init frontend
$ vim ./frontend/architect.yml # Make sure to update the `dependencies` to include the `backend` component
$ architect dev ./frontend

Notice how we only registered 3 out of 4 of the components we designed earlier. We only need to register components that will be used as dependencies for others, so we don't need to register the frontend. When we run architect dev ./frontend, Architect will automatically identify the auth, payments, and backend components as required, pull them down, and run them alongside the frontend.

Learn more about dependencies