www/apps/book/app/learn/introduction/architecture/page.mdx
export const metadata = {
title: ${pageNumber} Medusa's Architecture,
}
In this chapter, you'll learn about the architectural layers in Medusa.
<Note title="Tip">Find the full architectural diagram at the end of this chapter.
</Note>Medusa is a headless commerce platform. So, storefronts, admin dashboards, and other clients consume Medusa's functionalities through its API routes.
In a common Medusa application, requests go through four layers in the stack. In order of entry, those are:
These layers of stack can be implemented within plugins.
</Note>The Medusa application injects into each module, including your custom modules, a connection to the configured PostgreSQL database. Modules use that connection to read and write data to the database.
Medusa only supports PostgreSQL as the underlying database. You can also integrate other databases in a custom module. For example, the Loader chapter shows how to connect to a MongoDB database through a custom module.
<Note>Modules can be implemented within plugins.
</Note>Third-party services and systems are integrated through Medusa's Commerce and Infrastructure Modules. You also create custom third-party integrations through a custom module.
<Note>Modules can be implemented within plugins.
</Note>Commerce Modules integrate third-party services relevant for commerce or user-facing features. For example, you can integrate Stripe through a Payment Module Provider, or ShipStation through a Fulfillment Module Provider.
You can also integrate third-party services for custom functionalities. For example, you can integrate Sanity for rich CMS capabilities, or Odoo to sync your Medusa application with your ERP system.
You can replace any of the third-party services mentioned above to build your preferred commerce ecosystem.
Infrastructure Modules integrate third-party services and systems that customize Medusa's infrastructure. Medusa has the following Infrastructure Modules:
All of the third-party services mentioned above can be replaced to help you build your preferred architecture and ecosystem.
<Note>The Caching Module was introduced in Medusa v2.11.0 to replace the deprecated Cache Module.
</Note>The following diagram illustrates Medusa's architecture including all its layers.