Commit Graph

132 Commits

Author SHA1 Message Date
96fa0058c2 feat(zopk): Rozbudowa bazy wiedzy ZOPK
- Dodano skrypt cron do automatycznej ekstrakcji wiedzy (scripts/cron_extract_knowledge.py)
- Dodano panel deduplikacji faktów (/admin/zopk/knowledge/fact-duplicates)
- Dodano API i funkcje auto-weryfikacji encji i faktów
- Dodano panel Timeline ZOPK (/admin/zopk/timeline) z CRUD
- Rozszerzono dashboard bazy wiedzy o statystyki weryfikacji i przyciski auto-weryfikacji
- Dodano migrację 016_zopk_milestones.sql dla tabeli kamieni milowych
- Naprawiono duplikat modelu ZOPKMilestone w database.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 10:57:11 +01:00
b69882bbb2 perf(zopk): Cache dla grafu relacji (TTL 5 min)
- Dodano in-memory cache dla API /api/zopk/knowledge/graph/data
- Cache key oparty o parametry: entity_type, min_cooccurrence, limit
- TTL = 300 sekund (5 minut)
- Flaga 'cached' w odpowiedzi informuje czy dane z cache

Korzyść: Drugie i kolejne ładowania grafu są natychmiastowe.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:34:52 +01:00
85c3f75e9b feat(zopk): Graf relacji encji (Priorytet 5)
- Dodano endpoint /admin/zopk/knowledge/graph z wizualizacją D3.js
- Dodano API endpoint /api/zopk/knowledge/graph/data
- Graf współwystępowania encji z kolorami według typu
- Rozmiar węzłów proporcjonalny do liczby wzmianek
- Filtry: typ encji, minimalna liczba współwystąpień
- Tooltips z informacjami o encjach
- Zoom i drag-and-drop interakcje

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:14:30 +01:00
143f5c674a feat(zopk): Implementacja łączenia duplikatów encji (Priorytet 4)
Nowe funkcje w zopk_knowledge_service.py:
- find_duplicate_entities() - wyszukiwanie podobnych encji (pg_trgm)
- merge_entities() - łączenie encji z transferem relacji
- get_entity_merge_preview() - podgląd przed połączeniem

Nowe endpointy w app.py:
- GET /admin/zopk/knowledge/duplicates - panel zarządzania duplikatami
- POST /api/zopk/knowledge/duplicates/preview - podgląd merge
- POST /api/zopk/knowledge/duplicates/merge - wykonanie merge

Nowy szablon:
- templates/admin/zopk_knowledge_duplicates.html - UI z kartami encji

Dodatkowo:
- Aktualizacja CLAUDE.md z procedurą wdrażania
- Skrypt scripts/run_migration.py do uruchamiania migracji SQL

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 09:09:22 +01:00
d0dda10bd7 feat(zopk): Panel admina bazy wiedzy, poprawa odpowiedzi AI, timeline
Priorytet 1 - Panel admina bazy wiedzy ZOPK:
- /admin/zopk/knowledge - dashboard ze statystykami
- /admin/zopk/knowledge/chunks - lista chunks z filtrowaniem
- /admin/zopk/knowledge/facts - lista faktów z typami
- /admin/zopk/knowledge/entities - lista encji z mentions
- CRUD operacje: weryfikacja, usuwanie

Priorytet 2 - Poprawa jakości odpowiedzi NordaGPT:
- Linki markdown do źródeł w kontekście ZOPK
- Ulepszone formatowanie (bold, listy, nagłówki)
- Sekcja "Źródła" na końcu odpowiedzi
- Instrukcje w system prompt dla lepszej prezentacji

Priorytet 3 - Timeline ZOPK:
- Model ZOPKMilestone w database.py
- Migracja 016_zopk_milestones.sql z sample data
- Sekcja "Roadmapa ZOPK" na stronie /zopk
- Pionowa oś czasu z markerami lat
- Statusy: completed, in_progress, planned, delayed

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-17 08:56:55 +01:00
900a3b4ed9 fix(admin): Naprawiono błąd importu w SSE scraping endpoint
Problem: Podwójny import ZOPKContentScraper powodował błąd 'cannot access local variable'
Rozwiązanie: Przeniesiono import na początek funkcji generate()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 23:28:16 +01:00
37af8abc73 feat(admin): Paski postępu dla operacji AI w panelu ZOPK
Dodano Server-Sent Events (SSE) dla śledzenia postępu w czasie rzeczywistym:
- Scraping treści artykułów
- Ekstrakcja wiedzy przez Gemini AI
- Generowanie embeddingów

Funkcje:
- Modal z paskiem postępu i statystykami
- Live log operacji z kolorowaniem statusów
- Podsumowanie na zakończenie (sukces/błędy/czas)
- Możliwość zamknięcia modalu po zakończeniu

Zmiany techniczne:
- 3 nowe SSE endpointy (/stream)
- ProgressUpdate dataclass w scraperze
- Callback pattern w batch_scrape, batch_extract, generate_chunk_embeddings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 23:23:05 +01:00
498f273aba fix(admin): Naprawiono strukturę danych w przyciskach ZOPK
- Naprawiono showKnowledgeStats - używa prawidłowej zagnieżdżonej struktury
- Naprawiono endpoint embeddings - renamed 'success' count to 'generated'
- Naprawiono endpoint extract - renamed 'success' count to 'processed'
- Unikamy nadpisywania flagi 'success: True' przez spread operator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:27:02 +01:00
1b4cd31c41 feat(zopk): Knowledge Base + NordaGPT integration (FAZY 0-3)
FAZA 0 - Web Scraping:
- Migracja 015: pola full_content, scrape_status w zopk_news
- zopk_content_scraper.py: scraper z rate limiting i selektorami

FAZA 1 - Knowledge Extraction:
- zopk_knowledge_service.py: chunking, facts, entities extraction
- Endpointy /admin/zopk/knowledge/extract

FAZA 2 - Embeddings:
- gemini_service.py: generate_embedding(), generate_embeddings_batch()
- Model text-embedding-004 (768 dimensions)

FAZA 3 - NordaGPT Integration:
- nordabiz_chat.py: _is_zopk_query(), _get_zopk_knowledge_context()
- System prompt z bazą wiedzy ZOPK
- Semantic search w kontekście chatu

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:15:30 +01:00
0f1cf6176a fix(health): Usunięcie nieistniejącego endpointu /admin/news
Endpoint /admin/news był planowany (dokumentacja CLAUDE.md) ale nigdy
nie zaimplementowany. Tylko /admin/zopk/news istnieje.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:31:10 +01:00
0a5f40879b fix(admin): Naprawa błędu 500 na /admin/fees + rozszerzenie health check
1. Context processor bug: datetime.now → datetime.now()
   - Szablon fees.html używa now.strftime(), potrzebuje wartości nie metody
   - Powodowało jinja2.UndefinedError na /admin/fees

2. Health check: dodano brakujące endpointy admina
   - /admin/fees (Składki/FIS)
   - /admin/news (News moderacja)
   - /admin/zopk/news (ZOPK News)
   - /admin/recommendations (Rekomendacje)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:27:18 +01:00
819192bdad feat(zopk): Rozszerzony widok aktualności ze statystykami czasowymi
- Dodano pasek statystyk newsów (łącznie, dzień, tydzień, miesiąc)
- Zwiększono limit wyświetlanych newsów z 10 do 25
- Usunięto przycisk "Zobacz wszystkie" - pełny widok od razu
- Przycisk "Starsze aktualności" pojawia się gdy jest więcej niż 25

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:56:00 +01:00
489f04d04d fix(zopk): Newsy auto_approved teraz widoczne na stronie publicznej
BUG: Strona publiczna pokazywała tylko status='approved',
     ale AI ustawia status='auto_approved' dla newsów 3+★.

Wynik: Newsy zatwierdzone przez AI NIE pojawiały się publicznie!

Naprawione miejsca:
- /zopk (strona główna ZOPK)
- /zopk/projekt/<slug> (szczegóły projektu)
- /zopk/aktualnosci (lista newsów)

Teraz wszystkie 3 miejsca pokazują obie wartości:
status IN ('approved', 'auto_approved')

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:50:35 +01:00
1193a2bf48 feat(zopk): Re-ewaluacja newsów z niską oceną zawierających kluczowe tematy
- Nowa funkcja reevaluate_low_score_news() szuka newsów z 1-2★
  zawierających Via Pomerania, NORDA, S6, Droga Czerwona, etc.
- Nowy endpoint POST /admin/zopk/news/reevaluate-low-scores
- Przycisk w UI "Re-ewaluuj niskie oceny" z szczegółowym raportem
- Automatyczne auto-approve jeśli nowa ocena >= 3★

Problem: Artykuły o Via Pomerania miały 1★ bo były ocenione
         przed dodaniem tego tematu do promptu AI.
Rozwiązanie: Re-ewaluacja nowym promptem podniesie ich oceny.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:38:20 +01:00
0cbdcaaad6 feat(zopk): Szczegółowe statystyki wyników wyszukiwania newsów
- Zamiana auto-odświeżania na przycisk OK
- Dodanie sekcji szczegółowych statystyk (12 metryk)
- Dodanie listy artykułów odrzuconych przez AI
- Śledzenie czasu przetwarzania
- API zwraca nowe pola: sent_to_ai, ai_rejected_articles, processing_time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:28:10 +01:00
db02d3660f feat(zopk): Improve AI scoring and auto-approve threshold
Changes:
- Lower auto-approve threshold from 4★ to 3★ (verified 2026-01-15)
- Add detailed progress bar for ZOPK search process
- Add auto-approved articles list with star ratings
- Document ZOPK topics (ZOP Kaszubia) in CLAUDE.md
- Add 8-second countdown before auto-refresh

Technical:
- zopk_news_service.py: Changed score threshold from >=4 to >=3
- Templates: New CSS for progress phases and results display
- CLAUDE.md: Added "ZOP Kaszubia News" section with topic guidelines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:05:41 +01:00
90da6b9c64 fix: Treat HTTP 429 as OK in health check
429 (Too Many Requests) means the endpoint is working correctly
and is protected by rate limiting - this is expected behavior
for /register endpoint.

- Add 429 to acceptable status codes (200, 302, 304, 429)
- Update legend to explain 429 means protection is working
- Apply to all health check endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:15:39 +01:00
3acbc53b87 fix: Health check - INPI, Waterm + 3 random companies
- Always check INPI and Waterm profiles (fixed)
- Add 3 random company profiles each refresh
- Total 5 company profiles tested for better coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:12:22 +01:00
54b3b94482 feat: Add graphical Health Check dashboard
- Add /admin/health route with visual status indicators
- Create health_dashboard.html with category-based endpoint cards
- Color-coded status: green (OK), yellow (warning), red (error)
- Show response times with color indicators (fast/medium/slow)
- Add HTTP status code legend
- Auto-refresh every 2 minutes
- Add link in admin navigation menu
- Categories: public pages, auth, API, admin panel, company profiles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:56:43 +01:00
23f109db2c fix: Update technology stack with verified versions only
- Verify all software versions via SSH (NORDABIZ-01, R11-REVPROXY-01, Proxmox)
- Remove Redis (not used), Gunicorn (app runs directly via python)
- Add PostgreSQL version dynamic fetch from database
- Add Docker version for R11-REVPROXY-01
- Update all package versions to verified values
- Handle unknown versions (Fortigate) with yellow "nieznana" badge
- Add comment with verification date (2026-01-14)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:48:21 +01:00
38682bf808 fix: Correct admin calendar path in health check (/admin/kalendarz)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:39:03 +01:00
03bd90f33b feat: Add system status dashboard with tech stack visualization
- Add /admin/status route with real-time system metrics (CPU, RAM, disk)
- Add /api/admin/status API endpoint for auto-refresh
- Add technology stack section showing all platform technologies
- Add auto-refresh (5 min) to GeoIP stats in security dashboard
- Add "Status systemu" link to admin navigation menu
- Fix /health/full endpoint list (remove non-existent endpoints)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:35:25 +01:00
8ed3724970 feat: Add extended health check endpoint /health/full
- Checks 14 critical endpoints (public + admin pages)
- Returns JSON with pass/fail status for each endpoint
- HTTP 200 if all OK, HTTP 503 if any failures
- Useful for deployment verification and monitoring

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:25:13 +01:00
6402ff7f0e docs: Update release notes and CLAUDE.md with security features
- Add GeoIP blocking, security panel, and stats to v1.16.0 release notes
- Add comprehensive security mechanisms table to CLAUDE.md
- Document GeoIP configuration and MaxMind setup
- List all 12 security mechanisms with star ratings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:20:32 +01:00
e9e37796c7 feat: Add security mechanisms list and GeoIP stats to admin dashboard
- New 'Mechanisms' tab listing all security features with star ratings (5★=critical)
- New 'GeoIP' tab with blocking statistics (daily/monthly/yearly/total)
- Country breakdown with flags for blocked connections
- Status indicators for each security mechanism

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:16:33 +01:00
cb574851cf feat: Add GeoIP blocking for high-risk countries (RU, CN, KP, IR, BY, SY, VE, CU)
- Update security_service.py with BLOCKED_COUNTRIES list
- Add check_geoip() middleware in app.py
- Log blocked attempts with security alerts
- Uses MaxMind GeoLite2-Country database

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:11:53 +01:00
0dba52e9c4 feat: Add security features - 2FA, audit log, alerting
Security enhancements:
- Two-Factor Authentication (TOTP) for all users
  - Enable/disable 2FA in settings
  - Backup codes for recovery
  - Login flow with 2FA verification
- Audit log for admin actions
  - Track all sensitive operations
  - IP address and user agent logging
- Security alerts system
  - Alert types: brute_force, honeypot_hit, account_locked, geo_blocked
  - Email notifications for high/critical alerts
  - Dashboard for alert management
- Admin security dashboard (/admin/security)
  - View/acknowledge/resolve alerts
  - Unlock locked accounts
  - 2FA status overview

New files:
- security_service.py: Security utilities
- templates/auth/verify_2fa.html
- templates/auth/2fa_settings.html
- templates/auth/2fa_setup.html
- templates/auth/2fa_backup_codes.html
- templates/admin/security_dashboard.html

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:23:27 +01:00
7226e098f6 feat: Honeypot endpoints for malicious bot detection
- Trap URLs: /wp-admin, /phpmyadmin, /.env, /.git/config, etc.
- Log to security.log for fail2ban integration
- Instant 24h ban via fail2ban after 1 hit
2026-01-14 21:13:05 +01:00
10dcbde7a8 feat: Account lockout after 5 failed login attempts
- Lock account for 30 minutes after 5 failed attempts
- Reset counter on successful login
- Log ACCOUNT_LOCKED events to security log
2026-01-14 21:11:33 +01:00
2efad9ba82 feat: Use Redis for rate limiter storage (persistent limits) 2026-01-14 21:08:48 +01:00
b6c58c9312 feat: Add security logger for fail2ban integration
- Security events logged to /var/log/nordabiznes/security.log
- Failed login attempts include IP address
- Format compatible with fail2ban filter
2026-01-14 21:07:09 +01:00
af3ba43c89 feat: Dynamic stats in release notes (companies, categories from DB) 2026-01-14 17:31:10 +01:00
1147e7e27c chore: Merge duplicate release notes (11 Jan, 10 Jan)
- v1.12.0 + v1.13.0 → v1.13.0 (11 stycznia 2026)
- v1.10.0 + v1.11.0 → v1.11.0 (10 stycznia 2026)

One version per day rule applied.
2026-01-14 15:10:53 +01:00
0b1dc49298 chore: Merge release notes from Jan 14 into single v1.16.0 entry
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 15:07:39 +01:00
22e73e4f80 feat: Email DKIM/SPF/DMARC config + year_established data fill
- Added release notes v1.19.0 with today's changes
- Email: DKIM, SPF, DMARC configured for nordabiznes.pl
- Data: year_established filled for 71/111 companies (64%)
- Script: fix_year_established.py for KRS date migration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 15:01:01 +01:00
749abfa018 fix: Use category_id instead of category relationship in report
- Company.category is a relationship, not a column
- Use Company.category_id for grouping and filtering
- Load category names via separate query to Category table

Fixes 500 error on /raporty/struktura-branzowa

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:30:35 +01:00
14e969bc6d fix: Fix AttributeError in report_categories
- Add .label('category') to SQLAlchemy query for proper Row attribute access
- Change filter_by to filter() for better NULL handling

Fixes 500 error on /raporty/struktura-branzowa

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:29:00 +01:00
c06df1f69a feat: Upgrade NordaGPT to Gemini 2.5 Flash-Lite + add model info modal
- Changed AI model from Gemini 2.0 Flash to Gemini 2.5 Flash-Lite
- Added info button next to model badge in chat header
- Created modal with technical specs and development history timeline
- Benefits: 8x longer responses (65k tokens), 4x daily limit (1000 RPD)
- Model remains FREE (Free Tier)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 08:09:04 +01:00
c16fe79724 fix: Dodano @csrf.exempt do API endpointów chatu
Endpointy /api/chat/start i /api/chat/{id}/message
wymagały tokenu CSRF, co blokowało żądania z JavaScript.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 07:55:36 +01:00
26e17ba1e3 fix: Naprawiono błąd w API konwersacji (started_at zamiast created_at)
Model AIChatConversation używa started_at, nie created_at.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 07:42:19 +01:00
80c0b0005c feat: Historia konwersacji NordaGPT z sidebare'em
- Dodano API /api/chat/conversations (lista konwersacji użytkownika)
- Dodano API DELETE /api/chat/<id>/delete (usuwanie konwersacji)
- Przebudowano chat.html z sidebarem historii (styl ChatGPT)
- Sidebar z listą konwersacji, przyciski "Nowa rozmowa" i usuwania
- Responsywny design dla mobile (toggle sidebar)
- Integracja ze stylem NordaGPT (purple gradient header)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 07:39:36 +01:00
1b6e698d87 feat: Nowa sekcja Raporty w menu głównym
- Dodano link Raporty w menu nawigacyjnym (dla zalogowanych)
- Utworzono 3 raporty generowane w czasie rzeczywistym:
  - Staż członkostwa w Izbie NORDA
  - Pokrycie Social Media (6 platform)
  - Struktura branżowa (kategorie firm)
- Dodano dokumentację strategii monetyzacji 3-tier pricing
- Release notes v1.18.0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 07:25:57 +01:00
8f1a7d6706 feat: Add release notes v1.17.0 for member_since feature
- Data przystąpienia do Izby NORDA (member_since)
- Karta "Członek Izby NORDA od" z datą i stażem w latach
- Import 57 firm z historią od 1997 roku

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 06:59:52 +01:00
3221740502 feat: Dodanie daty przystąpienia do Izby NORDA na profilu firmy
- Nowa kolumna member_since w tabeli companies
- Karta "Członek Izby NORDA od" na profilu firmy (niebieski kolor #3b82f6)
- Wyświetlanie liczby lat w Izbie
- Import 57 dat przystąpienia z pliku Excel od Artura
- Skrypt import_member_since.py do importu dat

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 06:57:00 +01:00
c1e770f806 fix: Rozdzielenie release notes na v1.15.0 (13.01) i v1.16.0 (14.01) 2026-01-14 06:38:48 +01:00
95b7aedcf3 fix: Poprawiono wyświetlanie pełnych nazw użytkowników w Analytics (word-wrap) 2026-01-14 06:26:04 +01:00
d82dc0caec feat: Add user edit functionality in admin panel
- Add /admin/users/<id>/update endpoint to update name, email, phone
- Add edit button with pencil icon to users table
- Add edit modal with form fields
- Add JavaScript functions for edit modal handling
2026-01-13 21:17:34 +01:00
f3433d28f5 fix: Add CSRF exempt for analytics API endpoints 2026-01-13 19:46:29 +01:00
986fa457cc fix: Correct redirect endpoint in analytics error handler 2026-01-13 19:43:26 +01:00
a148d464af feat: Add user analytics panel (/admin/analytics)
- Track user sessions, page views, clicks
- Measure engagement score and session duration
- Device breakdown (desktop/mobile/tablet)
- User rankings by activity
- Popular pages statistics
- Recent sessions feed
- SQL migration for analytics tables
- JavaScript tracker for frontend events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 19:40:37 +01:00