Polylith – the last architecture you will ever need by Joakim Tengstrand and Furkan Bayraktar

December 9, 2020

In the presentation Polylith – the last architecture you will ever need, Joakim Tengstrand and Furkan Bayraktar introduce Polylith, a software architecture described as the last one you will ever need. Polylith is a visualization of a codebase as a city, with each building representing a class and packages acting as neighborhoods. The speakers discuss the challenges of managing code duplication and development experience in monolithic architectures and introduce Polylith as a solution. Polylith is based on small, easy-to-combine building blocks called pallets, which help keep the codebase consistent, are flexible and extendable, and can be replaced like Lego bricks. Polylith also allows developers to work with all their code from one place, making it productive and efficient. The speakers share their experience implementing Polylith in their project, Scrintel, and highlight its benefits, such as focusing on product and business logic, reducing the need for architectural meetings, and enabling quick pivots and component replacement. Polylith simplifies software development and collaboration by organizing code into components, each with its own directory, and allowing teams to share components between services and projects. Polylith encourages running tests frequently due to its fast feedback loop and allows developers to work on the code without being affected by production changes.

Polylith – the last architecture you will ever need: A comprehensive overview

What Is Polylith?

Polylith is an architecture designed to solve common problems associated with large, complex systems — namely code duplication, slow feedback loops, and difficult collaboration between teams. In the traditional monolith or microservices approaches, managing separate services often leads to disjointed codebases and inconsistent development practices. Polylith aims to change this by organizing your code into reusable building blocks, referred to as “components.”

Each component in Polylith is a self-contained unit, complete with its interface and implementation. These components are flexible, easily extended, and can be replaced or combined like Lego bricks. They are designed to be shared across projects, ensuring that developers only work in one place but with a broader view of how the entire system operates.

 

Addressing common development challenges

In the early sections of the presentation, Tengstrand and Bayraktar dive into some key challenges developers face in monolithic or microservices architectures. Codebases become inconsistent, development slows down, and the need to sync various services creates inefficiencies. Polylith’s solution is a consistent architecture that optimizes productivity during development while meeting non-functional requirements in production.

One of the architecture’s core ideas is to separate the development process from deployment. In Polylith, components are organized in a way that facilitates easier collaboration and testing while keeping development independent from production complexities. Developers can make changes locally and test them quickly, without being affected by changes or issues in the production environment.

 

Components, Bases, and Projects: The building blocks of Polylith

Polylith is composed of three primary concepts: components, bases, and projects.

  • Components are blocks of code that serve specific purposes, each living in its directory and exposing functionality through interfaces. These components are highly modular and reusable across different projects.
  • Bases represent the public-facing aspects of the application. They are thin layers that expose a public API (like REST APIs or Lambda functions) and delegate logic to the underlying components. Bases are essential for allowing external systems to interact with the internal logic of the application.
  • Projects are collections of components and bases that come together to create the final deployable product. Projects in Polylith allow for flexible and modular assembly of various components, depending on the needs of the deployment.

Polylith components are interchangeable, making it easy to replace one without breaking the rest of the system, resulting in faster development cycles, enhanced collaboration, and simplified project management.

 

Real-world application: Polylith at Scrintal

A powerful example of Polylith in action comes from the speakers’ experience at their startup, Scrintal. This data analysis platform is built using a single-page React application with a backend powered by AWS Lambda and Google Firebase. Polylith played a crucial role in enabling the team to validate their ideas, test different cloud services, and simulate functionality locally before deployment.

In the early stages of the project, the team used Polylith to pull their workspace into a functional backend service, exposed via Amazon’s API Gateway. As the system grew, they extracted various functions into standalone Lambda services, all while maintaining focus on the business logic, thanks to the flexibility of Polylith components.

Polylith allowed the team to seamlessly scale their operations, reducing the time spent on architectural meetings and facilitating rapid pivots in business direction.

 

Simplifying collaboration and deployment

One of the standout benefits of Polylith is its ability to simplify both collaboration and deployment. By organizing code into reusable components, it becomes easier for new developers to understand the codebase. In Polylith, the entire system is visible and accessible from a single place, allowing teams to share components between services and projects with no restrictions.

Polylith also enhances the testing process. Since all the building blocks are self-contained, developers can run tests frequently and receive fast feedback, even in production environments. This fast feedback loop improves code quality and reduces the time it takes to ship new features.

Another key advantage is that Polylith separates the code organization for development from the structure needed for production. Developers can focus on writing and testing their code without being hampered by the complexities of production infrastructure.

 

The future of software development with Polylith

In closing, Tengstrand and Bayraktar emphasize that Polylith’s Lego-like architecture provides an unprecedented level of flexibility, making it ideal for teams working in fast-moving environments. Whether for a startup or a larger organization, Polylith enables teams to build quickly, test confidently, and deploy efficiently — all while minimizing the risks associated with scaling.

For those considering Polylith, the architecture promises to streamline the development process by reducing complexity, improving collaboration, and fostering reusable components. In their view, Polylith may indeed be “the last architecture you will ever need.”

 

Conclusion: Is Polylith right for you?

Polylith offers a fresh take on software architecture, focusing on productivity, modularity, and ease of collaboration. With real-world applications proving its value, it’s an architecture that startups and established companies alike can benefit from, particularly if they’re looking to simplify development and deployment.

Whether or not Polylith becomes “the last architecture you’ll ever need,” it certainly provides a compelling blueprint for more efficient and scalable software development.

 

Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.