Towards first-principles design of quantum devices