After creating a record, you create a default .tex file with the following content:
\documentclass{article}
\begin{document}
% Write your latex code here
\end{document}
Then the code editor will display the content in the .tex file. When you write stuff in the editor and you compile, the system shall save the new .tex file, and display that in the preview. When you download the pdf, the system shall compile the .tex file and download the pdf.