nordabiz/docs/REFACTORING_STATUS.md
Maciej Pienczyn 50a549c3ff docs: Plan refaktoryzacji - Modularny Monolit (10 faz)
- Szczegółowy plan wydzielenia 235 routes do ~25 blueprintów
- Kategoryzacja routes według modułów
- Harmonogram 10 faz (~33h pracy)
- Docelowa struktura katalogów
- Zasady refaktoryzacji i procedury wdrożenia

Cel: Redukcja app.py z 15,570 → ~500 linii

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 06:40:49 +01:00

3.8 KiB

Status Refaktoringu app.py

Ostatnia aktualizacja: 2026-01-31 Autor sesji: Claude Opus 4.5

Stan obecny

Faza 1 - WDROŻONA NA PRODUKCJĘ

Commit: 66856a6 Data wdrożenia: 2026-01-28

Blueprint URL Prefix Routes Status
reports /raporty 4 Przetestowane
contacts /kontakty 6 Przetestowane
classifieds /tablica 4 Przetestowane
calendar /kalendarz 3 Przetestowane

Nowa struktura plików:

nordabiz/
├── blueprints/
│   ├── __init__.py          # register_blueprints()
│   ├── reports/
│   │   ├── __init__.py
│   │   └── routes.py
│   └── community/
│       ├── __init__.py
│       ├── contacts/
│       ├── classifieds/
│       └── calendar/
├── utils/
│   ├── decorators.py        # admin_required, etc.
│   ├── helpers.py           # sanitize_input, etc.
│   ├── notifications.py
│   ├── analytics.py
│   ├── middleware.py
│   ├── context_processors.py
│   └── error_handlers.py
├── extensions.py            # csrf, login_manager, limiter
└── config.py               # Dev/Prod configurations

Redukcja app.py: ~14,455 → ~13,699 linii (~5.2%)


Harmonogram

Szczegółowy plan: docs/MODULAR_MONOLITH_PLAN.md

Podsumowanie faz

Faza Zakres Routes Status
1 reports, community, education 19 WDROŻONA
2 auth, account ~20 🔜 Następna
3 public, forum ~25
4 messages, notifications ~10
5 chat ~8
6 admin (8 modułów) ~60
7 audits (6 modułów) ~35
8 zopk (5 modułów) ~32
9 api misc, honeypot ~25
10 utils extraction -

Cel: Redukcja app.py z 15,570 → ~500 linii


Weryfikacja wdrożenia Fazy 1

# Sprawdzenie czy blueprinty działają na produkcji
curl -sI https://nordabiznes.pl/health        # → 200 OK
curl -sI https://nordabiznes.pl/raporty/      # → 302 (wymaga logowania)
curl -sI https://nordabiznes.pl/kontakty/     # → 302 (wymaga logowania)
curl -sI https://nordabiznes.pl/tablica/      # → 302 (wymaga logowania)
curl -sI https://nordabiznes.pl/kalendarz/    # → 302 (wymaga logowania)

Zweryfikowano: 2026-01-31 - wszystkie endpointy działają poprawnie.


Naprawione błędy podczas testów DEV

Plik Problem Rozwiązanie
blueprints/reports/routes.py url_for('report_*') url_for('.report_*')
templates/contacts/detail.html contact_delete contacts.contact_delete
templates/contacts/list.html contacts_list (3x) contacts.contacts_list
templates/classifieds/index.html classifieds_index (6x) classifieds.classifieds_index
templates/classifieds/view.html classifieds_close, classifieds_index Dodano prefix classifieds.
templates/calendar/event.html calendar_rsvp calendar.calendar_rsvp

Lekcje na przyszłość

  1. url_for w blueprintach:

    • Wewnątrz blueprintu: url_for('.endpoint') (z kropką)
    • W szablonach: url_for('blueprint.endpoint') (pełna nazwa)
  2. Testowanie po migracji:

    • Sprawdź WSZYSTKIE szablony używające url_for()
    • Użyj grep: grep -r "url_for\(" templates/
  3. Restart serwera:

    • Flask cachuje szablony - wymaga pełnego restartu
    • Zabij proces i uruchom od nowa

Kontakt

W razie problemów z wdrożeniem sprawdź:

  • Logi: /var/log/nordabiznes/
  • Health check: curl https://nordabiznes.pl/health
  • Rollback: git revert HEAD && git push