Report generators are common tools, there are many open source and commercial software packages available, so I do not consider reinventing this wheel. See here some options.
Independent opinions/testimonies/reviews of any reporting tool for MongoDB or PostgreSQL are welcome via pull-requests or via Discussions section.
This is a powerful open source BI tool that can work with MongoDB and PostgreSQL. https://github.com/metabase/metabase
Free Grafana plugin to generate reports from dashboards. https://grafana.com/grafana/dashboards/11365
Grafana paid options (Enterprise or Cloud) can do reporting. https://grafana.com/docs/grafana/latest/enterprise/reporting/
An open-source tool for processing stream data using a spreadsheet-like interface. Supports MongoDB, MQTT and other data sources. https://github.com/eclipse/streamsheets
The Open Source Airtable alternative. Can connect to PostgreSQL. https://github.com/nocodb/nocodb
Budibase is an open-source low-code platform. Supports MongoDB, PostgreSQL and other data sources. https://github.com/Budibase/budibase
https://github.com/ToolJet/ToolJet Open-source extensible low-code platform. Supports MongoDB, PostgreSQL and other data sources.
Java-based BI tool. https://github.com/apache/superset
Python-based BI tool. https://github.com/getredash/redash
Ad hoc reporting tool for PostgreSQL, MySQL and SQL Server. https://github.com/d4software/QueryTree
This is supposed to work with MongoDB and PostgreSQL. I have encountered problems with MongoDB. https://github.com/widestage/widestage
This is a very poplar report solution. I have encountered problems with MongoDB Java JDBC driver. https://community.jaspersoft.com/community-download
This is a powerful tool for reporting and data analysis. I was not able to make it work with MongoDB 4.2/4.4. https://github.com/KnowageLabs/Knowage-Server
This is a Java-based tool for reporting and data analysis. https://helicalinsight.github.io/helicalinsight/#/quickstart
Data mining, ML and visualization tool. https://github.com/biolab/orange3
An open-source platform for designing and rendering various reports. https://github.com/jsreport/jsreport
This is a popular commercial (with some free tiers) BI Package that can work with PostgreSQL. It is not a report generator but can suit most needs. It can work with MongoDB using the MongoBD Connector for BI. https://docs.mongodb.com/bi-connector/master/connect/powerbi/
https://www.postgresql.org/download/products/5-reporting-tools/
A powerful PHP reporting tool. https://github.com/koolphp/koolreport
Another PHP reporting tool. https://www.reportico.org
Node.js/JSON reporting tool. https://github.com/Ideolys/carbone
Storybook is an open source tool for building UI components and pages in isolation. It streamlines UI development, testing, and documentation. https://storybook.js.org/
Open source Firebase alternative. Supports PostgreSQL. https://github.com/supabase/supabase