Adds a layer structure and separate the db functionality