# Architecture overview

UI Bakery self-hosted version is a set of services, some of which are optional. The same core principles apply whether you deploy it using Docker Compose or Kubernetes.

Below is a diagram illustrating *UI Bakery containers* and the *relationships* between them. Arrows indicate the direction of requests between containers/services.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FDFXAaneMDoNaptrStz6r%2Fui_bakery_self_hosted_.jpg?alt=media&#x26;token=60637577-501f-410a-8d36-8735bfd5f9d1" alt=""><figcaption><p>UI Bakery overview</p></figcaption></figure>

All UI Bakery containers are stateless. Certain containers are optional and can be safely removed if their functionality is not required. Check out what these containers stand for:

* **bakery-gateway** acts as an NGINX-based gateway and reverse proxy. Routes incoming client requests to the appropriate internal services.
* **bakery-front** is an NGINX server hosting static files (HTML/CSS/JS) for the main UI Bakery interface.
* **workbench-front** is another NGINX server dedicated to hosting static files for the “workbench” front-end. The workbench is rendered within an iframe inside the main UI, providing a secure sandboxed environment for end-user apps.
* **bakery-back** is a Java-based API service serving as the main backend. Handles authentication, authorization, user management, storage of application models, and other central logic. May initiate outbound connections if SSO or other external integrations are enabled.
* **datasource** is a Node.js service responsible for executing queries against connected data sources.
* **db** is a MySQL database that stores internal UI Bakery entities such as users, apps, and permissions. [Recommended](https://docs.uibakery.io/on-premise/install-and-update/recommendations/running-a-standalone-database-instance) to replace with a managed, external MySQL database in production. Can be removed if you are using an external database solution.
* **automation** is a Node.js service that executes [UI Bakery automations](https://docs.uibakery.io/extras/automations). Invoked by bakery-back, it can perform datasource queries as part of these automations. Can be removed if automations are not used.
* **python-runtime** is a Node.js-based environment for running [Backend Python code](https://docs.uibakery.io/reference/working-with-actions/python-backend-code) actions within UI Bakery. Can be removed if Python-based actions are not required.
* **bakery-db** is a PostgreSQL database that can be connected as a data source within UI Bakery. Used for the [UI Bakery Database](https://docs.uibakery.io/extras/ui-bakery-postgres) feature. Can be removed if database is not used.
