Skip to main content

Example monorepo

In the 101 course, we used aspect init to make a new empty project. That's good for product engineers, who prefer less cognitive load and can afford to focus on the single language they program in.

In the 201 course, we will use a full-featured "kitchen sink" monorepo: https://github.com/aspect-build/bazel-examples. Developer Infrastructure teams are usually tasked with productivity and maintenance of a big repo with many languages, so that's what we'll show you.

The repository has a primary (top-level) workspace, comprised of a Bazel Module in the root of the repository and various nested modules. There are also some additional nested workspaces, some with multiple modules, for code not part of the primary example workspace.

Exercise: Get the code

Clone the bazel-examples repository to your machine so you can follow along.

  • If you'd rather, you can pair up with someone near you.
  • Or, just follow along with the instructor who presents the content, and come back to clone the repo later.

If your training session has a teaching assistant, remember to reach out with questions in getting this repo functional.

Content of note in this repo

Here are the files that matter for all languages:

  • MODULE.bazel / MODULE.bazel.lock
  • WORKSPACE.bazel
  • .bazelversion
  • .bazeliskrc

Folders to know about:

  • .aspect/ has settings for Aspect CLI (Optional)
  • tools/ has repo-level setup
  • logger/ is a multi-language example application

There are also numerous other files that we'll ignore for now, relevant only to specific examples.

Running the Logger Demo

The initial demo project is in the logger directory, so start with cd logger if you want to follow along.

First, we startup the Go backend server,

bazel run backend:

Then we launch the Java client which produces log messages and sends them to the backend,

bazel run client:

Now we can run our Python CLI to see the messages so far:

Finally, we can run a TypeScript web frontend and see the messages there too,

bazel run frontend:

Here's what the app looks like in the browser after loading some messages:

Or we can boot up the iOS app and send/receive messages:

Aspect CLI Only

Reminder from the 101 course - most of the bazel commands we use are built in to core Bazel, while occasionally we use one added by the Aspect CLI.