The amount of light energy required to grow plants properly is very large and hard to supply with artificial light sources. Fruiting plants, like tomatoes, have much higher requirements than leafy crops, like lettuce. Lamps are rather inefficient converting electricity into light.
A 1000 Watt metal halide or high-pressure Na lamp is barely adequate to cover a square meter (if the only light source). Calculate the energy cost of running it 16hr/day for a month and it gives new respect for Mother Nature.
Another headache is plant nutrition. Vegetables grow fast and suck nutrients out of their environment at an alarming rate. There are many systems but the short version is reusing nutrient fluids requires constant chemical monitoring to assure proper pH, mineral content. Automated equipment is out of the question, and a home farmer very likely won't have the knowledge and lab equipment to do it optimally by hand.
There are a whole bunch of other constraints, but the above is enough said. Doing experiments is fun, but apartment-scale production of edibles is definitely no more than a pipe dream.