Refactor database schema and build backend structure