A document processing, templating, and rule engine system for Hungarian grant/funding call packages.
- Document Import: Import PDF, DOCX, TXT, MD, and email files; convert to normalized Markdown
- Hierarchy Editor: Validate and approve heading structure (H1-H6) before chunking
- Semantic Comparison: Compare documents using embeddings to identify fixed vs variable sections
- Template System: Create templates with inheritance (7 actions: inherit, override, hide, extend, prepend, append, merge)
- Clause Library: Reusable text blocks with variables
- Parameter System: Typed parameters (12+ types) with validation rules
- Rule Engine: 3-layer rule system (dependencies, conditionals, formulas) using Python-like expressions
- Document Generation: Generate packages with Jinja2 templating and Hungarian formatting
- Version Control: Branch, tag, diff, and rollback for templates
| Component | Technology |
|---|---|
| Backend | FastAPI + Python 3.11 |
| Frontend | Next.js 14 + TypeScript + Tailwind |
| Database | PostgreSQL 15 + pgvector |
| Cache | Redis |
| Task Queue | Celery |
| PDF Processing | pdfplumber, PyMuPDF |
| OCR | Tesseract (Hungarian) |
| DOCX | python-docx |
| Embeddings | sentence-transformers |
| Rule Engine | rule-engine (Python) |
| Templates | Jinja2 |
- Docker & Docker Compose
- Node.js 20+ (for frontend development)
- Python 3.11+ (for backend development)
# Start all services
docker-compose up -d
# Access:
# - Frontend: http://localhost:3000
# - Backend API: http://localhost:8001
# - API Docs: http://localhost:8001/docs# Backend
cd backend
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt
cp .env.example .env
# Start PostgreSQL and Redis (Docker)
docker-compose up -d db redis
# Run migrations
alembic upgrade head
# Start backend
uvicorn app.main:app --reload --port 8000
# Frontend (in new terminal)
cd frontend
npm install
npm run devPFG/
├── backend/
│ ├── app/
│ │ ├── api/endpoints/ # REST endpoints
│ │ ├── core/ # Config, database
│ │ ├── models/ # SQLAlchemy models
│ │ ├── schemas/ # Pydantic schemas
│ │ ├── services/ # Business logic
│ │ └── tasks/ # Celery tasks
│ ├── alembic/ # Migrations
│ └── tests/
├── frontend/
│ ├── src/
│ │ ├── app/ # Next.js pages
│ │ ├── components/ # React components
│ │ ├── hooks/ # Custom hooks
│ │ ├── lib/api/ # API clients
│ │ ├── stores/ # Zustand stores
│ │ └── types/ # TypeScript types
│ └── public/
├── docker-compose.yml
└── README.md
| Endpoint | Description |
|---|---|
POST /api/v1/packages |
Create call package |
GET /api/v1/packages |
List packages |
POST /api/v1/documents/import |
Import document |
POST /api/v1/documents/{id}/approve |
Approve hierarchy |
GET /api/v1/templates |
List templates |
POST /api/v1/generate |
Generate package |
See full API documentation at http://localhost:8000/docs
DATABASE_URL=postgresql+asyncpg://pfg:pfg@localhost:5432/pfg
REDIS_URL=redis://localhost:6379/0
EMBEDDING_MODEL=intfloat/multilingual-e5-base
TESSERACT_LANG=hunNEXT_PUBLIC_API_URL=http://localhost:8000Rules use Python-like expression syntax:
rules:
- name: "Előleg garancia szabály"
condition: 'eloleg_kerheto == true and eloleg_osszeg > 100000000'
then_actions:
- action: "set_required"
target: "garancia_tipus"
- action: "set_visible"
target: "section:felhivas.4.3.garancia"Jinja2 filters for Hungarian text:
{{ amount | penz }}→ "50 000 000 Ft"{{ date | datum }}→ "2026. január 15."{{ value | szazalek }}→ "50%"{{ items | felsorolas }}→ "a), b), c)"
MIT