Skip to content

Gimmyhat/efgi_xml2pdf

Repository files navigation

EFGI XML2PDF Service

Automated conversion of geological XML applications into signed PDF documents for Rosnedra

A web service that processes geological information about land plots, deposits, and licenses, converting XML declarations into professionally formatted and digitally signed PDF documents.

Quick Start

Fastest Way - One Command Deployment

# Deploy to test environment
make quick-test

# Deploy to production
make quick-prod

That's it! The system automatically handles versioning, Docker build, deployment, and verification.

Alternative PowerShell Commands

# Test environment
.\deploy.ps1 test test patch

# Production environment  
.\deploy.ps1 prod prod patch

What This Service Does

  1. XML Processing - Validates and parses geological XML applications
  2. PDF Generation - Creates professional documents using HTML/CSS templates
  3. Digital Signing - Adds cryptographic signatures using pyHanko
  4. Web Interface - Provides upload, file management, and monitoring pages
  5. Automatic Cleanup - Manages file retention and log rotation

System Architecture

Environment URL Port Purpose
Production http://172.27.239.6:30001/ 30001 Live system
Development http://172.27.239.23:30002/ 30002 Development testing
Test http://172.27.239.23:30003/ 30003 Integration testing

Main Features

  • XML to PDF Conversion - Geological data processing
  • Digital Signatures - PFX certificate integration
  • Web Interface - File upload and management
  • Automated Deployment - One-command deployment system
  • Automatic Cleanup - Configurable file retention
  • Authentication - HTTP Basic Auth protection
  • Kubernetes Ready - Production-grade deployment

Web Interface Pages

  • Main (/) - XML file upload interface
  • Files (/files/) - Download and manage generated PDFs
  • Logs (/logs/) - View system logs and errors
  • Cleanup (/cleanup/) - File management and cleanup controls

Technology Stack

  • Backend: FastAPI + Python 3.9+
  • PDF Generation: WeasyPrint + HTML/CSS templates
  • XML Processing: ElementTree + custom parsers
  • Digital Signing: pyHanko + PFX certificates
  • Deployment: Docker + Kubernetes
  • Authentication: HTTP Basic Auth

Development Workflow

Daily Development

# Make changes to code
# Deploy to test
make quick-test

# Check results
make check-test

Production Release

# Deploy to dev first
make quick-dev

# If all good, deploy to production
make quick-prod

Emergency Hotfix

# Fix critical issue
.\deploy.ps1 test test patch

# If works, push to production
.\deploy.ps1 prod prod patch

Available Commands

Command Description
make quick-test Deploy to test environment
make quick-dev Deploy to dev environment
make quick-prod Deploy to production
make check-test Verify test deployment
make versions Show current Docker versions
make help Show all available commands

Documentation

Essential Docs

Advanced Topics

Configuration

Key environment variables:

AUTO_CLEANUP_ENABLED=True        # Enable automatic file cleanup
FILE_RETENTION_DAYS=7            # File retention period
LOG_RETENTION_DAYS=30            # Log retention period
CLEANUP_INTERVAL_HOURS=6         # Cleanup check interval

Troubleshooting

Check System Status

kubectl get pods                  # Check pod status
kubectl logs -f deployment/...   # View logs
make versions                     # Check current versions

Common Issues

  • Service not responding - Check pod status and logs
  • Authentication errors - Verify HTTP Basic Auth credentials
  • File not found - Check cleanup settings and retention periods
  • Deployment failed - Verify Docker Hub access and Kubernetes connection

Rollback

kubectl rollout undo deployment/server-print-deployment-test

Project Structure

efgi-xml2pdf/
├── app/                     # Main application code
│   ├── main_app.py         # FastAPI application and routes
│   ├── xml_processor.py    # XML parsing and PDF generation
│   ├── cleanup_service.py  # Automatic cleanup service
│   └── templates/          # HTML templates for PDF generation
├── deploy.ps1              # PowerShell deployment script
├── Makefile                # Simple deployment commands
├── requirements.txt        # Python dependencies
├── Dockerfile              # Container configuration
└── server-print-*.yaml    # Kubernetes deployment manifests

Contributing

  1. Make changes to the code
  2. Test with make quick-test
  3. Deploy to dev with make quick-dev
  4. Create pull request
  5. Deploy to production with make quick-prod

Support

For issues or questions:

  • Check the troubleshooting section
  • Review system logs via web interface or kubectl
  • Consult additional documentation in this repository

Current Version: v1.189.1+ (automatically managed by deployment system)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published