Commit Graph

21 Commits

Author SHA1 Message Date
vakabunga
db4d5e4d00 fix: yield to event loop after each SSE write to flush socket
The for-await loop over OpenAI stream chunks runs synchronously when
data is buffered, causing res.write() calls to queue without flushing.
Add setImmediate yield after each progress event so the event loop
reaches its I/O phase and pushes data to the network immediately.
2026-03-14 19:59:22 +03:00
vakabunga
67fed57118 fix: disable gzip and pad SSE events to prevent proxy buffering
Add gzip off to Nginx import location — the global gzip on was
buffering text/event-stream responses. Pad each SSE event to 4 KB
with comment lines to push past any remaining proxy buffer threshold.
2026-03-14 19:45:33 +03:00
vakabunga
aaf8cacf75 fix: eliminate SSE buffering through Nginx proxy
Add 2 KB padding comment after headers to push past proxy buffer
threshold, enable TCP_NODELAY on the socket, and remove erroneous
chunked_transfer_encoding off from Nginx that caused full response
buffering.
2026-03-14 17:30:52 +03:00
vakabunga
e28d0f46d0 fix: reopen result modal from progress bar, faster progress, handle LLM context error
- Move import modal visibility into ImportContext so the Layout
  progress pill can reopen the result dialog after the modal was closed.
- Raise LLM progress cap from 85% to 98% and drop the intermediate
  -import 88%- SSE event to eliminate the visual stall after LLM finishes.
- Detect LLM context-length errors (n_keep >= n_ctx) and surface a
  clear message instead of generic -Временная ошибка конвертации-.
2026-03-14 17:05:55 +03:00
vakabunga
78c4730196 fix: adaptive LLM progress estimation and emit 85% on stream end
Hardcoded EXPECTED_CHARS (15k) caused progress to stall at ~20-25% for
short statements. Now expected size is derived from input text length.
Also emit an explicit 85% event when the LLM stream finishes, and
throttle SSE events to 300ms to reduce browser overhead.
2026-03-14 16:41:12 +03:00
vakabunga
1d7fbea9ef feat: stream PDF import progress via SSE with global progress bar
Replace the synchronous PDF import with Server-Sent Events streaming
between the backend (LLM) and the browser. The user can now close the
import modal and continue working while the conversion runs — a fixed
progress bar in the Layout shows real-time stage and percentage.
2026-03-14 16:18:31 +03:00
vakabunga
627706228b fix: remove response_format incompatible with LM Studio API 2026-03-14 15:23:33 +03:00
vakabunga
3e481d5a55 fix: lazy-load pdf-parse to prevent startup crash if module is missing 2026-03-14 14:18:25 +03:00
vakabunga
723df494ca fix: downgrade pdf-parse to 1.1.1 to eliminate native dependency
pdf-parse@2.4.5 depends on @napi-rs/canvas (native Skia binary compiled
with AVX instructions) which crashes with SIGILL on the Synology NAS CPU.
Version 1.1.1 is pure JavaScript and works on any architecture.
2026-03-14 14:03:14 +03:00
vakabunga
feb756cfe2 fix(docker): prevent backend crash loop caused by pdf-parse native deps
pdf-parse@2.4.5 pulls in @napi-rs/canvas (native Skia binary) which
crashes on import in Alpine containers. Moved to lazy require() so the
app starts normally and pdf-parse loads only when PDF conversion is
actually requested.
- Lazy-load pdf-parse in pdfToStatement to avoid startup crash
- Add libc6-compat, fontconfig, freetype to Alpine runner stage
- Increase npm fetch timeouts in both Dockerfiles for slow networks
- Add connectionTimeoutMillis to pg Pool for faster failure detection
2026-03-14 13:37:34 +03:00
vakabunga
b598216d24 feat(backend): настраиваемая LLM для конвертации PDF в JSON
- Добавлена переменная LLM_MODEL в конфиг
- Увеличен max_tokens до 32768 для крупных выписок
- Включен response_format: json_object
- Добавлен скрипт test:llm для проверки подключения к LLM-серверу
2026-03-13 23:12:52 +03:00
0638885812 Merge pull request 'feat: adds PDF import with conversion to JSON 1.0' (#1) from pdf2json-feat into main
Reviewed-on: #1
2026-03-13 10:40:03 +00:00
Anton
975f2c4fd2 feat: adds PDF import with conversion to JSON 1.0
- Accept only PDF and JSON files in import modal and API
- Convert PDF statements to JSON 1.0 via LLM (OpenAI-compatible)
- Use multipart/form-data for file upload (multer, 15 MB limit)
- Add LLM_API_KEY and LLM_API_BASE_URL for configurable LLM endpoint
- Update ImportModal to validate type and send FormData
- Add postFormData to API client for file upload
2026-03-13 13:38:02 +03:00
vakabunga
50154f304c chore: adds copy of migration file to prod 2026-03-12 22:25:52 +03:00
Anton
d1536b8872 feat: расширенные правила категоризации (миграция 004) 2026-03-12 14:50:02 +03:00
vakabunga
a895bb4b2f fix: 404 при обновлении, стрелки периода, фильтры в URL, авто-категории и очистка истории
- Nginx: проксирование /api на backend (единая точка входа)
- История: стрелки ← → для переключения недель/месяцев/годов
- История: сохранение фильтров и пагинации в URL при F5
- Импорт: миграция 003 — дефолтные правила категорий (PYATEROCHK, AUCHAN и др.)
- Настройки: вкладка «Данные» с кнопкой «Очистить историю»
- Backend: DELETE /api/transactions для удаления всех транзакций
- ClearHistoryModal: подтверждение чекбоксами и вводом «УДАЛИТЬ»
2026-03-10 06:53:56 +03:00
vakabunga
792b4ca4ad fix: fixes compose file 2026-03-02 23:32:40 +03:00
vakabunga
b990149bc3 chore: adds docker files 2026-03-02 23:22:40 +03:00
Anton
a50252d920 docs: specifies lang in tripple quotes 2026-03-02 11:36:16 +03:00
Anton
172246db0b fix: align docs and code with actual DB schema and format spec
- Rewrite db.md as canonical schema: add categories, sessions tables; add alias to accounts, is_category_confirmed/comment to transactions, FK references to categories(id); mark budgets as post-MVP

- Fix account masking to use fixed 6 asterisks (code + docs)

- Remove budgets from MVP requirements in agent_backend.md

- Add explicit 'not in MVP' note to analytics.md budgets section

- Fix test_Statement.json: convert amounts to kopecks (integers), remove fingerprint fields (computed by backend)

Made-with: Cursor
2026-03-02 11:34:00 +03:00
vakabunga
4d67636633 feat: creates backend for the project 2026-03-02 00:32:37 +03:00