Electronic structure of nanosystems and crystals