For a typical 1x1 brick, the width is 8mm, while the height is 9.6mm (faceplates will be 9.6mm / 3 = 3.2mm). The diameter of each stud is 3.2mm, while its height is 1.6mm. More details can be found here.
Lego pieces are manufactured to great precision, with unofficial sources citing tolerances of anywhere between 0.01mm to 0.002mm. This type of precision is next to impossible to achieve with most consumer 3D printers. Even the best amongst them offer precision of up to 0.02mm.
The outer dimensions of the brick enclosures are designed with 0.2mm allowance on each side. This allows the enclosures to easily fit between actual Lego bricks with the least problem.
The brickbases are restricted to 2x1 or 3x1 pieces. So I can easily print out a batch of 10 pieces and discard the ones that are ill-fitting due to variances in output.
The modules themselves are typically designed as multiple parts to be assembled using small M2 self-tapping screws (5mm length):
Originally, I tried putting them together using super glue, but it was difficult to take the modules apart to make changes or repair. Using screws make this job far easier.
Brickbases are attached to the enclosure using super glue. Only a couple of tiny drops are required for each brickbase, and the resultant bond is very strong.
A small amount of hot glue is used to secure components or add strength to wires/joints where necessary. They are relatively easy to remove when disassembly is required.