This Python Reporting API was created as a test to see if Python and Quarto could handle the static "predefined" reporting for the IT Expense Management (ITAM) and Telecom Expense Management (TEM) SaaS platform I am building. It is intended to enable accurate reporting and auditing of complex organizational data, including insights into asset lifecycles, location, associations, and other useful financial metrics. I was mildly happy with the outcome, and may use a similar setup, and fully develop it in the future. The only downside was the effort required to create report templates for different file types, and data types, however this is somewhat typical.
- Direct interacting with Data API sources, for gathering Expenses, Assets, and other insightful data points.
- Flexible support for generating reports in PDF, Excel, and Word and Jason Value formats.
- Integration with Quarto for modern reporting capabilities.
- Modular design for scalability and maintainability.
- Framework: Python 3.11
- Reporting Tools: Quarto for PDF, Excel, and Word generation; ReportLab for detailed PDF layouts. GPT for AI.
- Database: SQL Server with SQLAlchemy as the ORM.
- API Architecture: FastAPI with automatic Swagger UI generation.
- Dependency Injection: SQLAlchemy session integration with FastAPI.
- Tests: Pytest and htmlCov, basic testing added thus far.
- Containerization: Docker support for running the microservice in Kubernetes (TODO!).
- CI/CD: GitLab CI/CD pipelines for automated deployment (TODO!).
- Python 3.11
- Docker (if running containerised, can run in localhost too)
- Kubernetes (if running in MiniKube or Azure Kubernetes Service)
- Quarto (Install from Quarto's website)
-
Clone the repository:
git clone https://github.com/GeorgeBPrice/PythonReportingAPI.git cd api-report-microservice -
Install Python dependencies (this will install globally, run this step in venv otherwise):
pip install -r requirements.txt
-
Start Python environment, Run the application:
source venv/bin/activate # For Linux/macOS \venv\Scripts\activate # For Windows
uvicorn app.main:app --reload
-
Access the Swagger UI:
Navigate to http://127.0.0.1:8000/docs
-
Testing:
-
Run Pytest Tests, in a new Terminal.
-
(only basic tests implemented)
pytest -v
-
Run Coverage Tests.
pytest --cov=app --cov-report html
-
Open the HTML Coverage Reports.
xdg-open htmlcov/index.html # For Linux/macOS start htmlcov/index.html # For Windows
-
-
(Optional) Render reports using Quarto:
-
Install Quarto and ensure it is added to your system's PATH.
-
Run a sample report:
quarto render reports/asset_report.qmd --to pdf
-
All endpoints are documented and accessible through Swagger UI, allowing developers to interact and test the APIs seamlessly.
Only approved collaborators can submit issues or pull requests, sorry!