Use ReproZip to capture the backend assets. This requires a Linux operating system setup and for the web app you want to archive to work/run as expected.
Execute ReproZip at the same time that you run the dynamic web app. ReproZip uses ptrace, an internal Unix system utility that lets one process (ReproZip) observe and control the execution of another process (the web app). ReproZip notes down everything that the web app touches as it executes into a SQLite database that is then used to create a configuration .yaml file with lots of administrative and technical metadata about what happened during the web app’s execution. ReproZip will trace and record what version of which software was used, what operating system was used, any input and output files, and provenance of what runs in what order (in case multiple commands are used to get the app running).
You can edit the config file before the package is created, but that is generally discouraged because it can affect how the app runs later down the line.
After tracing, use ReproZip again to pack the web app and all its dependencies into the .rpz file.