separate main into app/api components.