> For the complete documentation index, see [llms.txt](https://muradkarakas.gitbook.io/sodium_documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://muradkarakas.gitbook.io/sodium_documentation/language-reference/program-structure/controller-file.md).

# Controller File

**What**\
&#x20;Controller file is actually a [Code Behind File](/sodium_documentation/language-reference/program-structure/code-behind-file.md) with a special name "controller.sqlx". Controller file will be automatically loaded just after the user session creation but before the first [Form File](/sodium_documentation/language-reference/program-structure/form-file.md) request is processed. All Sodium projects must have one controller file in the same folder even if it is empty.

**Why**\
&#x20;Controller file term is used to provide developers with a standard application design. With a well-known controller file, developers can find implementation of the business logic. Controller files consist of global variables/functions which are available from the beginning of the Sodium application to the end of the user session.

In another word, Controller file is used for;

* Business rule implementation.
* Shared functions and/or variables.
* Session-wide triggers (Ex: ["user\_session\_end" trigger](/sodium_documentation/language-reference/built-in-triggers/user_session_end-trigger.md))


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://muradkarakas.gitbook.io/sodium_documentation/language-reference/program-structure/controller-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
