In a 40g you could easily fit 6-8 cories. For shrimp, the general ruleof thumb is 10 adult dwarf shrimp per gallon (for bioload purposes). If you are going with a species of shrimp that will multiply readily in the home aquaria (like cherry shrimp or other neocaridina) leave plenty of room for their growth. Glass shrimp should multiply, though some species of glass/ghost shrimp require brackish conditions for their larvae to develop. Another important thing when housing shrimp is to make sure your filter intake is covered with a prefilter (sponge, media bag, nylons) to protect any small or young shrimp from being sucked into the filter. Shrimp are omnivorous so will eat any prepared fish foods readily. The cories will love the worms, but you could also feed a sinking wafer (i like Ken's catfish pellets and Hikari sinking wafers for bottom feeders). The cories will love sand, shrimp are not particular about their substrate, though for the colored species I like a dark color as it helps to showcase their coloration. As for plants, that is determined by your lighting. Low light plants like java fern, java moss, crypts, anubias, some hygros, etc can do well in 1-2 watts per gallon (divide the total watts of your light fixture by the amount in gallons). The plants I named do not typically need ferts or co2 injection so are a nice place to start. Hope this helps!
edit: If housing inverts with fish its always best to quarantine the fish for a month first as inverts are very sensitive to most medications. You might choose to get the fish first and then a month later put your inverts in the tank. Best of luck!