# Lifecycle

We'll first go through a simplified version of the lifecycle of a request, assuming we're building a website application and our client is a web browser.

When a Cherrycake application receives a request, it first loads some initial modules like [Output](/reference/core-modules/output.md), [Errors](/reference/core-modules/errors.md) and [Actions](/reference/core-modules/actions-1/actions.md). These are the modules that Cherrycake needs to determine what to do next:

![](/files/-M4tFkH9Hx4qJrI-UTnc)

Cherrycake now asks the [Actions](/reference/core-modules/actions-1/actions.md) module to attend the received request:

![](/files/-M4tFmqfDblyjsG0DiYA)

To do so, [Actions](/reference/core-modules/actions-1/actions.md) checks the requested route to see which modules have mapped an action. If it founds a  mapped action that matches the current request, loads and runs the module who mapped it.

Let's say the browser requested the home of our website by requesting the `/` route, and that this route has been mapped by a module we called *Home*. Cherrycake loads this module and runs it:

![](/files/-M4tFpKC9HXSFJxnqbyy)

*Home* is an app module (as opposed to a core module), and is in charge of showing the home page of the website. To do so, *Home* uses the [Patterns](/reference/core-modules/patterns.md) core module to load an HTML file from disk and then send it to the browser. Since the [Patterns](/architecture/patterns.md) module has not been loaded yet, Cherrycake loads it automatically:

![](/files/-M4tFsUD3O4DOko20OEU)

Since all output is handled by the [Output](/reference/core-modules/output.md) core module, [Patterns](/reference/core-modules/patterns.md) reads the requested HTML file and uses [Output](/reference/core-modules/output.md) to send back the response to the Browser, and the request lifecycle concludes.

![](/files/-M4tGJeQo1neqRGv84KB)

Now let's take a deeper look at how all this happens with some code, in the [Deep lifecycle](/architecture/lifecycle/deep-lifecycle.md) section.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cherrycake.tin.cat/architecture/lifecycle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
