# App Directories

# Directory Structure

The Expresswebjs directory structure may feel overwhelming at first glance since there are a handful of pre-configured directories.

Gradually you’ll understand the benefit of separating your entities into multiple directories, keeping your code maintainable and easy to search.

A standard Expresswebjs installation looks something like so:


├── App/
    ├── Config/
    ├── Console/
    ├── Http/
    ├── Model/
    ├── Events/
    ├── Listeners/
    ├── Providers/
    ├── Repository/
    ├── Service/
├── Database
    ├── Migrations
    ├── Seeds
├── Routes
    ├── api.js
    ├── sockets.js
├── app.js
├── .env
└── package.json

The app directory is the home of your application logic. Inside the app directory, you will see the config directory.

The config directory is used to define the configuration of your application. Expresswebjs ships with a number of config files.

# app/Http/Controller

The app/Http/Controller directory is used to store all your Http and WebSocket controllers. This directory is automatically created when you run: for http controller: expresswebcli make-controller [CONTROLLER_NAME] [--r]

for websocket controller:

expresswebcli make-ws-controller [CONTROLLER_NAME]

# app/Events

The app/Events directory is used to store all event. This directory is automatically created when you run

expresswebcli make-event [EVENT_NAME]

# app/Listeners

The app/Listeners directory is used to store all event listeners. This directory is automatically created when you run

expresswebcli make-listener [LISTENER_NAME]

# app/Model

The app/Model directory is used to store all your models. This directory is automatically created when you run

expresswebcli make-nosql-model [MODEL_NAME]

OR expresswebcli make-sql-model [MODEL_NAME] [--m]

where –m or –migration is for creating a migration file with make-sql-model

Expresswebjs provides a beautiful, simple ActiveRecord implementation for working with your sql database. Each database table has a corresponding “Model” which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.

Before getting started, be sure to configure a database connection in .env file.