This is the industry reference that everyone more or less agrees on: http://edrm.net/
Essentially one side can request any and all data concerning people/places/events in the case, though they have to specify (loosely) what they want and why, and what format they want it delivered in - some want native files, some PDFs, some TIFF images, some even want paper.
Typically attorneys of both the plaintiff and defendant work through the terms of a court order, then the defendant's lawyers do a big data collection with the aid of forensic specialists, possibly supervised by the plaintiff's attorneys. This can be as disruptive as an IRS audit, but across the entire company - engineering, sales, business development, finance, executive suite, you name it. Assume everything will be collected, and I do mean everything: the idea is to get a snapshot of all relevant data that was available on the date the court granted the motion. Many firms are now moving towards just archiving everything ahead of time to avoid disrupting operations. Also, that makes it much easier to manage as a rolling process for both sides later. As well as the original files, there's a giant database of all textual content (including transcriptions of audio/video) and case-specific legal metadata referencing the source material.
The plaintiff isn't entitled to see all of this stuff, but is entitled to know it has been preserved as evidence whose completeness can be verified legally, so everything's numbdered and tracked from here on. Then the defendant's lawyers go through looking for a) anything that could fall within the scope of the court order, b) what they think the Plaintiff is going to use against them in particular, and c) what the defendant is entitled to keep from them (eg the communications between the CEO and company counsel, or material which is just not relevant to the plaintiff's case).
They build (a) by doing wide-ranging database searches for each legal issue in the case, of which there can be many. Then a team of review attorneys looks at every document individually to see if it's responsive (relevant) to the issue and/or privileged (legally private), maybe adding a short description that will go into a list of evidence. In a big case like Google v. Oracle there can be over 100 attorneys doing this for months on end, factory style. They're usually contractors, not employees. 5 years ago this paid $60-75/hour or more; now it typically pays half that, and some companies pay as little as $15/hour. The job is so basic that only minimal qualifications are required, so now a lot of material is sent to India; because a bunch of law schools got certified in the years before the financial crisis and many more exaggerated hiring stats for their grads, there's a huge surplus of JDs and far fewer jobs; a lot of law firms went bust in the crisis, and a lot more complain schools graduate too many theorists unprepared to actually practice law; and most of these grads are $1-200k in non-dischargeable debt for their student loans. Hence debt-ridden attorneys being offered $15/hour.
Naturally they aren't happy, and everyone is waiting to see if (more like when) a class action lawsuit gets filed against the whole legal education establishment. In the meantime, most law schools still charge at least $30k/year in tuition.
After the review team has classified everything to legal standards, the defendant's attorneys - the ones earning real money this time - then go through double and triple checking what's responsive, redact any information that might be privileged, and approving each document required for production to the plaintiff, they're all given another set of numbers and converted to the agreed-upon output format. They also (typically) approve lots more documents which look responsive but aren't and are safe to give away, so as to bury the plaintiff's attorneys in as much irrelevant data as they possibly can - because the plaintiff's lawyers don't get access to this trove of metadata, just the bare document in digital or occasionally printed form.
Then the other side puts all those into a big database of their own, hires a smaller bunch of review attorneys, and does essentially the same thing. Often the defendant has launched a countersuit against them in the meantime, and requests discovery of the original plaintiff's documents...this process sometimes takes a few years before the trial proper starts.
There are huge profits to be had, but lots of competition; also most law firms are conservative about technology. So it's not a fast buck.