# Lifecycle Diagram

This diagram outlines the flow from the initial strapi start to the end of a request.

You can click on any of the diamond shapes for more information

# Register

see: Register (opens new window)

This is the very first thing that happens when a strapi app is starting. This happens before any setup process and you wont have any access to db, routes, policies etc.

# Bootstrap

see: Bootstrap (opens new window)

This happens before the server boots but after Strapi has setup meaning you have access to anything that you would usually have in the Strapi object

Tip: you can run yarn strapi console and interact with the strapi object

# Policies

Policies are binary middlewares. They are mainly used to handle authentication and will either allow a request to go through or deny it.

# Middlewares

Middlewares allow you to look at any incoming request and modify the ctx payload however you need to call the next() to pass it over to the controller, but any logic after next() will have the response from the controller

# Controllers

Controllers are code that always get executed when a request is made and contain the core logic of any request. The core controllers tend to contain the logic to grab data from the database.

# Destroy

see: Destroy (opens new window)

Code executed when Strapi is stopping

# Routes

The routes in strapi is what determines how Koa will route each request this is where you attach policies and middlewares