refactor mvc & add db support