# Files structure

{% tabs %}
{% tab title="/" %}
The root of your Cherrycake App directory. Can be placed anywhere in your server, a usual choice would be `/var/www/AppName`

In its most basic form, it contains at least one important file:

* **composer.json**
  * Cherrycake uses [composer](https://getcomposer.org/) to manage dependencies. Modify this file to add your own dependencies if needed. To make your Cherrycake application work, the dependency `tin-cat/cherrycake-engine` is required.
    {% endtab %}

{% tab title="/src" %}
Contains your [modules](https://cherrycake.tin.cat/version-1.x-beta/architecture/modules), each one in a subdirectory named in the syntax:

`/src/<ModuleName>/<ModuleName>.php`

Also contains your [classes](https://cherrycake.tin.cat/version-1.x-beta/architecture/classes), each in one file named in the syntax:

`/src/<ClassName>.php`

It is recommended that modules follow the naming [conventions](https://cherrycake.tin.cat/version-1.x-beta/conventions). For example, the following module:

```php
namespace CherrycakeApp\Home;

class Home extends \Cherrycake\Module {
    [...]
}
```

Must be saved in a file here:

`/src/Home/Home.php`

And the following class:

```php
namespace CherrycakeApp;

class User extends \Cherrycake\Item {
    [...]
}
```

Must be saved in a file here:

`/src/User.php`
{% endtab %}

{% tab title="/config" %}
Contains the configuration files for your modules, if they need one. The syntax of this files is:

`/config/<ModuleName>.config.php`

For example, the configuration file for the module *Home m*ust be saved in a file here:

`/config/Home.config.php`

> Check the [Module config files](https://cherrycake.tin.cat/version-1.x-beta/guide/modules-guide#modules-config-file) documentation for more information

This directory also holds the configuration files for [Janitor Tasks](https://cherrycake.tin.cat/version-1.x-beta/guide/janitor-guide/janitor-tasks-configuration-files).
{% endtab %}

{% tab title="/patterns" %}
Contains the HTML files to be used by the [Patterns](https://cherrycake.tin.cat/version-1.x-beta/reference/core-modules/patterns) module. This directory can be set to anything else by changing the `directory` config key of the [Patterns](https://cherrycake.tin.cat/version-1.x-beta/reference/core-modules/patterns) module.
{% endtab %}

{% tab title="/public" %}
This is the directory that gets exposed publicly by an HTTP server like NGINX. It must have at least an `index.php` file to load the Cherrycake engine and attend requests.

Check out the [Getting started](https://cherrycake.tin.cat/version-1.x-beta/guide/getting-started) section to learn how to build this index file, or use the readily provided with the [Skeleton](https://cherrycake.tin.cat/version-1.x-beta/guide/getting-started/skeleton) or [Docker](https://cherrycake.tin.cat/version-1.x-beta/guide/getting-started/docker) methods.
{% endtab %}
{% endtabs %}

### Other files and directories

There are some other non-required files and directories in a typical Cherrycake app, you'll find some of them there if you create your Cherrycake App using a boilerplate like the [Cherrycake Skeleton](https://cherrycake.tin.cat/version-1.x-beta/guide/getting-started/skeleton).

{% tabs %}
{% tab title="/" %}
If you've used the [Cherrycake Skeleton](https://cherrycake.tin.cat/version-1.x-beta/guide/getting-started/skeleton) to start your app, you'll also find this files in your app's root directory:

* **cherrycake**
  * An executable script that allows you to perform a [cli](https://cherrycake.tin.cat/version-1.x-beta/guide/cli) call to the Cherrycake application from the server command line.
* **LICENSE\_Cherrycake**
  * This contains the license disclaimer for the Cherrycake engine, please keep this file untouched in all your Cherrycake projects.
* **cli.php**
  * A PHP script to launch a [cli](https://cherrycake.tin.cat/version-1.x-beta/guide/cli) request to the Cherrycake application. This PHP file is used by  the `cherrycake` script.
* **load.php**
  * A convenience loader for the Cherrycake engine, used by any other scripts that need to run the Cherrycake engine, like `cli.php`, or `public/index.php`
    {% endtab %}

{% tab title="/usr" %}
Usually, this directory is used to store files uploaded by the users of an app. For example: If your app allows your users to upload their profile images, this is where you could be saving them using the [Image](https://cherrycake.tin.cat/version-1.x-beta/reference/core-classes/image) core class.
{% endtab %}

{% tab title="/errors" %}
This directory holds the HTML files the [Errors](https://cherrycake.tin.cat/version-1.x-beta/reference/core-modules/errors) shows to the browser when errors occur. You change this to a different directory by setting the `patternNames` key in the [Errors](https://cherrycake.tin.cat/version-1.x-beta/reference/core-modules/errors) module configuration file.
{% endtab %}

{% tab title="/install" %}
Some Cherrycake modules make use of the database. This directory contains the SQL files needed to create the database tables needed for those Cherrycake modules.

For example, if you plan to use the [Session](https://cherrycake.tin.cat/version-1.x-beta/reference/core-modules/session) module to manage your web app user sessions, you'll need to create the `cherrycake_session` table in your database by using the script `session.sql` you'll find in this directory.
{% endtab %}

{% tab title="/vendor" %}
This is the usual directory managed by [Composer](https://getcomposer.org/) to hold all the dependency libraries, including the Cherrycake engine itself.
{% endtab %}
{% endtabs %}
