We construct an algebraic model for the rational homotopy type of Baut(X), the classifying space of fibrations with fiber X, for arbitrary simply connected CW-complexes X. As an application, we express the rational cohomology ring of Baut(X) in terms of cohomology of arithmetic groups and dg Lie algebras. In special cases, this leads to connections to modular forms and to graph complexes in the sense of Kontsevich. Another corollary is an algebraicity result for the representations of the homotopy mapping class group of X in the higher rational homotopy groups of Baut(X), which extends a classical result of Sullivan and Wilkerson. This is joint work with Tomas Zeman.