100 Commits
Author SHA1 Message Date
thomas 58404ac8dc Enhance sorting functionality for additional fields in SQLiteFileRepository and update emission_date to be sortable in the frontend 2026-10-20 23:20:02 +02:00
thomas 6a47e6ad56 Add configurable document columns and allow bulk metadata editing (#14) 2026-10-19 18:15:03 +02:00
thomas 0748584b22 Add local ML models and document suggestions (#13) 2026-10-19 16:20:34 +02:00
thomas f21cef5377 Added end-to-end tests 2026-10-17 12:45:53 +02:00
thomas 502336f02f Add epics and stories / Make specifications consistent 2026-10-16 22:29:47 +02:00
thomas d917d8a49f Corrected a slow request 2026-10-15 23:01:53 +02:00
thomas 34271f3bfa feat: enhance PDF text extraction and add maintenance features
- Refactor text extraction functions to extract text from all pages instead of just the first page.
- Implement logging for better debugging during file operations.
- Add a new maintenance page with options to rebuild the database and run consistency checks.
- Update styles for maintenance actions and improve UI elements.
- Remove obsolete rebuild database functionality from the main interface.
2026-10-13 22:01:36 +02:00
thomas ab232a276f docs(automatic-pdf-renamer): add BMAD v6 epics and stories 2026-10-13 09:18:35 +02:00
thomas 8e677df762 Reduced the number of builds 2026-10-11 18:45:58 +02:00
thomas d275a14e20 Add automatic-pdf-renamer to repository matrix 2026-10-11 18:37:13 +02:00
thomas 028de6afd1 Change default branch from 'main' to 'master' 2026-10-10 22:46:16 +02:00
thomas 6ba115059b Multiple corrections 2026-10-10 22:35:32 +02:00
thomas b8a8efcfd6 First version of the web UI 2026-10-07 22:14:47 +02:00
911ed1c027 feat: implement paperless import with config auto-update and new mapping structure (#10)
* Add mapping-based configuration for document processing

- Create new config structure with company-type mappings
- Add date extraction regex patterns to config
- Update config.py to support new mapping-based configuration
- Create pipeline.py with full document processing workflow
- Enforce strict validation: unknown companies/types route to review
- Period rules now come from (company, type) mappings, not templates
- Remove document_family field from templates as requested

Implements workflow:
1. Extract first page text
2. Find emission date using regex from config
3. Find company/type using ML, validated against config lists
4. Look up (company, type) in mappings for template + period rule
5. If no mapping found -> route to review
6. Apply period rule to calculate period
7. Apply template key_pattern to generate filename

Closes #config-review

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add field_groups support for additional fields in configuration

- Add field_groups section to templates.yaml with predefined lists:
  - bank_accounts: for bank statements
  - properties: for building-related documents
  - contract_references: for contracts and invoices
  - customer_numbers: for customer identification
- Add field_groups to CompanyTypeMapping dataclass
- Add get_field_groups(), get_field_group_values(), get_field_groups_for_mapping() methods
- Update pipeline to extract additional field values from predefined lists using ML
- Additional fields are extracted for each field_group in the mapping
- If field values cannot be determined -> route to review

Implements workflow:
1. Extract first page text
2. Find emission date using regex patterns from config
3. Find company and document_type using ML, validated against config lists
4. Look up (company, document_type) in mappings for template, period rule, and field groups
5. For each field group, find value using ML from predefined list
6. If no mapping found or field values cannot be determined -> route to review
7. Apply period rule to calculate period from emission date
8. Apply template key_pattern to generate filename with all fields

Closes #field-groups-review

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Update documentation and configuration for new structure

- Move configuration from config/templates.yaml to config.jsonc at root
- Rename field_groups to additional_fields throughout
- Update PRD section 4.1 to reference new period format configuration
- Update PRD FR4.1 and FR4.2 to reference JSONC and additional_fields
- Update Arch.md to reference JSONC configuration file
- Update module layout comments to reference JSONC
- Update processing pipeline diagram to reference companies list and additional fields
- Update configuration section to describe new JSONC structure

The new config.jsonc includes:
- companies: predefined list of valid companies
- document_types: predefined list of valid document types
- additional_fields: predefined value groups (bank_accounts, properties, etc.)
- date_extraction: regex patterns for finding emission date
- period_formats: customizable period formats with granularity, format template, and offset
- mappings: (company, document_type) -> template + period_format + additional_fields
- templates: template definitions with key patterns

Closes #config-review

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* feat: implement JSONC config with wildcard mappings and period formats

- Add JSONC configuration file at root (config.jsonc)
- Support simplified date_extraction as ordered list of regex strings
- Implement wildcard mappings (company OR document_type can be None)
- Add period_formats with granularity, custom format templates, and offsets
- Rename field_groups to additional_fields
- Update config.py: JSONC loading, PeriodFormatConfig, CompanyTypeMapping with optional fields
- Update period.py: format_period_from_emission_date with custom template support
- Update pipeline.py: use new config structure with strict validation

Closes #10

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* feat: implement new mapping structure with match/set rules

- New mapping structure: each rule has 'match' (criteria) and 'set' (actions)
- match: can contain company, document_type, both, or neither (empty = matches all)
- set: can contain template, period_format, additional_fields
- Rules processed in order, later matches override earlier ones
- Added default rule that applies to all documents
- Added MappingRule, MappingMatch, MappingSet dataclasses
- Updated resolve_mapping() to process all rules and apply overrides
- Added 'default' template for fallback

Closes #10

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* feat: implement paperless import with config auto-update and new mapping structure

- New mapping structure with match/set sections
- Auto-update config.jsonc with missing companies, document_types, additional_fields
- Tag-to-field matching with strict validation (unmatched/ambiguous tags route to pending)
- Route documents to pending/{paperless_id} when validation fails
- Save config at end of run if changes detected
- Use created_date from Paperless as emission_date
- Write sidecars with errors for pending documents
- Clear files/ and pending/ at start of each run

Closes #10

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Various corrections following real life tests

* Various corrections following real life tests

---------

Co-authored-by: Vibe Nuage Agent <vibe@mistral.ai>
Co-authored-by: napnap75 <napnap75@users.noreply.github.com>
2026-10-04 22:06:01 +02:00
72f8254e10 US0: Paperless-ngx Initial Import - Reusable Components + Import Script (#9)
* Add sidecar.py module for User Story 0 (Paperless-ngx import)

Implements the sidecar data model, schema validation, atomic writes,
and I/O helpers per PRD section 7.

- Sidecar and SidecarEvent dataclasses with full PRD schema
- SidecarStatus and EventType enums
- build_sidecar(), serialize(), deserialize() functions
- validate_sidecar() with type and required field checking
- get_sidecar_key() for .meta.json suffix generation
- write_atomic() for crash-safe temp-key + copy + delete pattern
- read_sidecar(), sidecar_exists(), matching_sha256() for storage I/O

This is a reusable component for both the import script and main service.

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add storage/ module with S3 and File backends

Implements the storage layer abstraction for User Story 0.

- StorageBackend ABC: defines interface for all storage implementations
- S3Storage: boto3-based backend for Garage S3 (production)
- FileStorage: filesystem-based backend for testing
- get_storage_backend() factory function
- Atomic operations: put, get, delete, copy, exists, list, head

Both backends implement the same interface, allowing seamless
switching between production S3 and local testing.

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add period.py, extractor.py, and config.py reusable modules

- period.py: Period parsing from filenames and computation from dates
  - parse_period_from_filename(): Extracts month-year, quarter, year, date patterns
  - compute_period_from_date(): Computes period per template rules (granularity + offset)
  - get_period(): Main entry point with filename fallback to rule-based computation
  - validate_period_consistency(): Checks period vs emission_date + rule
  - Supports French month names (août, janvier, etc.)

- extractor.py: PDF text extraction using PyMuPDF
  - extract_first_page_text(): Extracts text from first PDF page
  - extract_and_validate(): Extracts and checks minimum text length
  - TextExtractor class for dependency injection and mocking

- config.py: Configuration management
  - S3Config, PaperlessConfig, PollerConfig, ClassifierConfig dataclasses
  - AppConfig: Main application configuration from env vars
  - TemplateRegistry: Loads and manages template YAML configurations
  - load_config(), load_templates() helper functions

All modules are reusable by both import script and main service.

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add import_paperless.py script for User Story 0

Implements the standalone import script that:
- Connects to Paperless-ngx REST API (PAPERLESS_URL + token from env)
- Connects to Garage S3 bucket via boto3 (S3_ENDPOINT_URL, credentials, bucket)
- Lists all documents from Paperless via paginated /api/documents/
- Fetches document metadata and maps to sidecar fields:
  - template: first path segment of storage_path
  - emission_date: document created field
  - emitting_company: correspondent name
  - document_type: document type name
  - period: parsed from filename tail, fallback to month-year from emission_date
  - extracted_text: first page text via PyMuPDF
  - optional_fields: from Paperless labels
- Downloads PDF via /api/documents/{id}/download/
- Stores PDF at files/{template}/{original filename}
- Writes sidecar {key}.meta.json with atomic temp-key + copy pattern
- Supports resumability (skip if PDF + sidecar exist with matching SHA256)
- Dry-run flag for testing
- Limit flag for trial runs
- Summary reporting at end
- Exit code: 0 if all succeed, 1 if any failures

Dependencies: requests, boto3, pymupdf, python-dateutil

Usage: python scripts/import_paperless.py [--dry-run] [--limit N] [--verbose]
Environment: PAPERLESS_URL, PAPERLESS_TOKEN, S3_ENDPOINT_URL, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_BUCKET_NAME

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add requirements.txt for import script dependencies

Lists all Python dependencies needed to run scripts/import_paperless.py:
- requests: Paperless-ngx API client
- boto3: Garage S3 client
- pymupdf: PDF text extraction
- python-dateutil: Date parsing
- PyYAML: YAML config parsing (optional)

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Update import script: add storage backend selection (s3/file)

- Added --storage-backend argument (choices: s3, file, default: s3)
- Added --file-base-dir argument for file storage
- Storage backend validation based on selection
- Updated help text and epilog with backend-specific env vars
- Importer class now accepts storage_backend and file_base_dir params
- _init_storage() method handles backend initialization
- Summary now shows which storage backend was used

Usage examples:
  # S3 storage (default)
  python scripts/import_paperless.py

  # File storage for testing
  python scripts/import_paperless.py --storage-backend file --file-base-dir ./test_storage

  # Explicit S3
  python scripts/import_paperless.py --storage-backend s3 --s3-endpoint ... --s3-bucket ...

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Add README.md for scripts directory

Comprehensive documentation for import_paperless.py script:
- Overview and features
- Requirements and installation
- Usage examples (env vars + CLI args)
- Storage backends (S3 vs file)
- Metadata mapping table
- Output structure
- Resumability notes
- Exit codes
- Example output
- Troubleshooting guide
- Development/testing notes
- Architecture overview

Helps users understand how to use the import script for User Story 0.

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Fix Paperless API field mapping

The Paperless-ngx API returns IDs for correspondent, document_type, and tags,
not the actual string values. This commit fixes the import script to:

- Use 'archived_file_name' instead of 'filename' for the actual filename
- Fetch correspondent name from /api/correspondents/{id}/ endpoint
- Fetch document type name from /api/document_types/{id}/ endpoint
- Fetch tag names from /api/tags/{id}/ endpoint
- Add caching for fetched entities to avoid duplicate API requests

This ensures the sidecar metadata contains actual human-readable strings
instead of numeric IDs.

Changes:
- PaperlessClient: Added get_correspondent_name(), get_document_type_name(), get_tag_name()
- PaperlessClient: Added caches for fetched entities
- get_all_documents(): Now resolves IDs to names for all fields
- Updated module docstring to document this behavior

Co-authored-by: napnap75 <napnap75@users.noreply.github.com>

* Refactor PaperlessClient: change labels to list, add storage path caching, and improve document fetching logic

---------

Co-authored-by: Vibe Nuage Agent <vibe@mistral.ai>
Co-authored-by: napnap75 <napnap75@users.noreply.github.com>
2026-10-03 10:05:49 +02:00
thomas 2d26876bf5 Add architecture document and user story for paperless-ngx import 2026-10-01 22:54:42 +02:00
thomas 36df49048c Manually corrected the brief and prd 2026-10-01 19:11:56 +02:00
thomas b704403a8a New version to use s3 as the source of truth 2026-10-01 15:04:27 +02:00
thomas 112c3be824 Add project brief and requirements in MD format (#8) 2026-10-01 15:01:48 +02:00
thomas 732ba6de0a Initial project specifications for PDF renamer (#7) 2026-10-01 14:14:00 +02:00
thomas c3a3ac922e Update CI workflow triggers for main branch 2026-10-01 14:03:57 +02:00
thomas 34b63e938d Added the procps package to make the healthchecks work 2026-09-26 14:02:55 +02:00
thomas 35aa32389a fix: Simplify timestamp parsing by removing timezone and format configuration 2026-09-08 23:41:10 +02:00
thomas 701b5b077f Split configuration to manage different time format 2026-09-08 23:27:48 +02:00
thomas f4c2628e0c fix: Improve log fetching by filtering timestamps 2026-09-06 13:11:31 +02:00
thomas a3402c85d6 Removed duplicate notification of logs that are outside the specified time range. 2026-08-31 22:23:04 +02:00
thomas a5337c3d29 feat: Refactor log-alert application into modular structure
- Introduced alerters package with base Alerter class and implementations for LogAlerter and GotifyAlerter.
- Created fetchers package with abstract LogFetcher class and implementations for FileLogFetcher, LokiLogFetcher, and ParseableLogFetcher.
- Added filters package with base Filter class and implementations for RegexpFilter and GeolocationFilter.
- Implemented rules package with base AlertRule class and SimpleAlertRule for alerting logic.
- Enhanced configuration handling with utilities for loading and validating JSON configuration.
- Updated logging setup for better logging management.
- Modified main application logic to utilize the new modular structure, improving maintainability and readability.
- Updated config.json and config.schema.json to reflect changes in alerting and fetching configurations.
- Added python-dateutil to requirements for date parsing functionality.
2026-08-30 23:22:38 +02:00
thomas b7f1b97434 Use RESTIC_HOST for notifications instead of HOSTNAME 2026-08-22 23:22:35 +02:00
thomas c9892bfd81 Updated rsync-server 2026-08-21 13:56:06 +02:00
thomas 8e1dee24d4 Remove quiet mode from restic backup commands 2026-06-24 20:54:52 +02:00
thomas 1ebe65fc80 Allow the use of templates for the alert title 2026-05-10 12:26:02 +02:00
thomas 0fee65bc93 Update Dockerfile to use latest Golang Alpine image 2026-05-01 19:19:02 +02:00
thomas 2d62c94031 Allow restic to be run from outside 2026-04-19 23:12:19 +02:00
thomas c7d46d7186 Reduced the output 2026-03-29 13:03:47 +02:00
thomas e1d9f968a9 Refactor error logging to use fmt.Println for consistency 2026-01-23 22:56:26 +01:00
thomas 1bb341b14e Enhance recipe4reader: Add image handling and improve Markdown conversion 2026-01-11 23:11:43 +01:00
thomas e81a5ff3cc Added recipe4reader 2026-01-11 18:27:59 +01:00
thomas 285aa5be0c Added the ability to backup inside the restic container 2025-12-18 23:02:51 +01:00
thomas 89bc68631a Improve WhatsApp connection handling 2025-10-18 23:53:57 +02:00
thomas b2d515a460 New simplified version 2025-10-18 18:08:21 +02:00
thomas 06ca841919 New simplified version 2025-10-18 18:03:49 +02:00
thomas 227f1d48e1 Added the geolocation filter and improved the config file format 2025-10-18 15:43:33 +02:00
thomas b06a39df3a Improved logging 2025-10-17 23:32:11 +02:00
thomas 7de812d002 Add jsonschema validation (#6)
* Add JSON Schema validation for log-alert config and require jsonschema

* Add jsonschema dependency to requirements

* Enhance config loading with schema validation

Added JSON schema validation for configuration and improved error handling.

* Simplify token assignment and config loading

Refactor token retrieval and configuration loading.
2025-10-16 21:02:28 +02:00
thomas c67b2b54c8 Upgraded version 2025-10-16 00:03:31 +02:00
thomas 0b5559be69 First version of log-alert 2025-10-15 22:32:51 +02:00
thomas 8385c5fb1d First version of log-alert 2025-10-15 22:30:08 +02:00
thomas 2f34fbac5f Removed ssh-chrooted 2025-08-31 22:11:05 +02:00
thomas 08cc0db5ec Revert to alpine 3.21 2025-08-17 14:54:46 +03:00
thomas a659f3c084 Revert to Alpine 3.21 2025-08-17 14:40:30 +03:00
thomas 83240a5bc4 Added a check not to backup the root directory 2025-07-06 13:07:31 +02:00
thomas be38f711b7 Refactored the code 2025-06-20 23:16:32 +02:00
thomas 7ea5713bf5 Updated GO version to correct the build 2025-06-19 23:05:06 +02:00
thomas c8f24c08ec Corrrected the script 2025-06-19 21:32:13 +02:00
thomas 99c016dba9 Corrected the script 2025-06-17 00:06:45 +02:00
thomas 6299e4e01a Update GO version 2025-06-16 20:17:54 +02:00
thomas fe23e93e4a Ouputs logs to stdout 2024-10-21 22:51:40 +02:00
thomas 0cd3523438 Simplified the script by adding Runitor 2024-10-11 22:07:15 +02:00
thomas 163ae5a8bf Simplified the script by adding Runitor 2024-10-11 22:05:11 +02:00
thomas 56037ebe0f Delete immich-souvenirs/README.md 2024-10-10 09:06:52 +02:00
thomas aa87ef2969 Added runitor to handle HC pings 2024-10-06 15:20:35 +02:00
thomas 3ec4250f24 Removed the unused images 2024-10-02 18:02:22 +02:00
thomas dafa972661 Updated the GO version 2024-10-02 08:20:20 +02:00
thomas d4926240ab Now send the logs to a file 2024-09-25 17:45:43 +02:00
thomas 14fd8a359b Corrected the build 2024-09-25 10:17:48 +02:00
thomas dbeeefab86 Added a chrooted sshd server 2024-09-24 23:20:02 +02:00
thomas 9322b554a4 Corrected the multiple send 2024-09-09 22:39:25 +02:00
thomas 73d7ad868d Now able to change the time to run and retries in case of error 2024-08-31 14:01:21 +02:00
thomas 6957da86a8 Removed piwigo-souvenirs 2024-06-30 18:43:42 +02:00
thomas 91d572fb1a Moved the parameters to env variable + Added healthchecks 2024-06-16 18:36:16 +02:00
thomas 28bc2b92bc Updated to immich 1.106 2024-06-15 12:11:34 +02:00
thomas 07c387ddbb Added immich-souvenirs 2024-06-08 15:05:37 +02:00
thomas c671fd408f Updated to Node20 actions 2024-05-24 23:39:48 +02:00
thomas 1666327364 Updated to the new version of the WhatsApp library 2024-05-24 23:19:01 +02:00
thomas a51e2e9cce Corrected the OVH updater 2023-10-19 21:37:55 +02:00
thomas 64d7f96571 Added the DNS updater for OVH DNS 2023-09-11 22:17:31 +02:00
thomas 7e1fb9c370 Update build.yml
Removed unused containers
2023-08-27 17:55:42 +02:00
thomas d3099dc275 Corrected error following new docker client version 2023-06-11 15:46:33 +02:00
thomas 141551571f Added the ability to exclude containers in restic-auto 2023-06-11 14:51:06 +02:00
thomas 3750d767f4 Allow to config chroot to remove permission errors 2023-04-23 15:29:58 +02:00
thomas 1d2ac725f6 Allow multiple shares 2023-04-23 14:07:50 +02:00
thomas cb50c08680 Allow multiple shares 2023-04-23 13:58:25 +02:00
thomas 52216f7e33 Added the rsync-server 2023-04-15 12:30:33 +02:00
thomas 3e036c8af5 Downgrading to Alpine 3.16 to correct build errors 2023-01-28 15:20:12 +01:00
thomas ac049dffbc Corrected the build following a change in the SendMessage function 2023-01-28 14:30:21 +01:00
thomas 9d6a5045a9 Corrected the build of sshd by removing arm/v6 build 2023-01-28 13:34:57 +01:00
thomas 847fb61b6d Removed the armv6 builds and upgraded the github actions 2022-12-23 17:18:58 +01:00
thomas 2891fd0016 Corrected the missing borgbackup package in alpine:edge images 2022-09-18 12:55:16 +02:00
thomas dd238452c3 Added Gotify notification 2022-09-18 12:46:51 +02:00
thomas 9b0ddbf80f Added the Gotify notifications 2022-09-17 13:00:37 +02:00
thomas 12de8a7954 Crontab could now be defined by env variables 2022-08-19 08:49:44 +02:00
thomas 6748b23024 Tried to improve the preview on iOS 2022-08-09 23:06:16 +02:00
thomas d7c163cf4e Updated the app following WhatsApp connexion changes 2022-05-15 23:31:38 +02:00
thomas 902c3babc2 Corrected the http-tunnel build 2022-05-08 12:42:47 +02:00
thomas 041bbcc27e Added the ability to exclude files 2022-04-30 18:55:18 +02:00
thomas 9987110d40 Merge branch 'master' of github.com:napnap75/multiarch-docker-images 2022-04-11 22:59:23 +02:00
thomas 6bfcf4486e Corrected the startup script since S6 update 2022-04-11 22:59:06 +02:00
thomas a0004f4ccf Corrected the startup script since S6 update 2022-04-10 23:12:08 +02:00
thomas f0c56a0abe Corrected the missing /init error 2022-04-10 16:59:15 +02:00
thomas 79e0d52326 Corrected the build problem on amd64 servers 2022-04-10 13:01:55 +02:00