# Domains

Domains are being used for "big" entities or business logic to have them in their own dedicated namespace, "isolated" from other parts.

There's no specific role on what should live in its own domain and what can be mixed together with other parts of the application. Depending on use case and how complex the entity or business logic is, it can live in its own domain.

Generally you can think of domains as first party route entities. For example, if endpoint is example.com/events or example.com/users here both Event and User should live in its own domain. Endpoint like example.com/users/auth should live under User domain.

# Naming convention

All domains should live in app/Domain folder with capital and singular form of entity name.

Bad: app/Domain/user or app/Domain/Events

Good: app/Domain/User or app/Domain/Event

# Contents

Domain folder should follow same folder structure as default Laravel app directory. This means, depending on domain's usage it can have folders like Http, Models, Exceptions, Providers, routes etc.

# Providers

Each domain can have its own service providers located in domain's Providers folders. Depending on the use-case domain can have service providers like EventServiceProvider, RouteServiceProvider, AuthServiceProvider, etc.

Domain's each service provider should be manually registered in config/app.php file, at the end of providers array, grouped by domain.

# Routes

Depending on use-case domain can have its own routes. Again, depending on use-case domain can have different route types, like web.phpm api.php, etc. Generally, domain's route files should be using same naming convention as default Laravel routes, unless route files for domain getting big, and they need be to split up.

Obviously, domain's routes should be related to domain and they must be register in domain's RouteServiceProvider