Files
NetForge/.planning/STATE.md
kevin-asprec cf790c3257 docs(01-02): complete authentication plan
Tasks completed: 2/2
- Task 1: NextAuth.js configuration with credentials provider and JWT
- Task 2: Login page UI, logout flow, seed script, and auth unit tests

SUMMARY: .planning/phases/01-foundation/01-02-SUMMARY.md
2026-03-04 18:44:29 +08:00

3.5 KiB

Project State

Project Reference

See: .planning/PROJECT.md (updated 2026-03-04)

Core value: ISP owners can see exactly where their money is — who owes what, what's been collected, what's been spent, and what the business actually looks like financially — in real time. Current focus: Phase 1 - Foundation

Current Position

Phase: 1 of 5 (Foundation) Plan: 2 of 5 in current phase Status: In progress Last activity: 2026-03-04 — Completed 01-02-PLAN.md (NextAuth credentials auth, JWT sessions, login UI, middleware)

Progress: [██░░░░░░░░] 10% (2/20 plans across all phases)

Performance Metrics

Velocity:

  • Total plans completed: 2
  • Average duration: 9.5 min
  • Total execution time: 19 min

By Phase:

Phase Plans Total Avg/Plan
01-foundation 2/5 complete 19 min 9.5 min

Recent Trend:

  • Last 5 plans: 01-01 (11 min), 01-02 (8 min)
  • Trend: accelerating

Updated after each plan completion

Accumulated Context

Decisions

Decisions are logged in PROJECT.md Key Decisions table. Recent decisions affecting current work:

  • [Roadmap]: Accounting COA and JournalEntryService built in Phase 2 before first invoice — cannot be retrofitted
  • [Roadmap]: Inventory modeled as event-ledger (immutable movements) from Phase 4 — mutable quantity columns explicitly rejected
  • [Roadmap]: Collector balances derived from transaction log, never stored as mutable fields
  • [Roadmap]: PORT-05 (online payment) scaffolded in Phase 5 but payment gateway integration deferred to v2 per project out-of-scope decision
  • [01-01]: DATABASE_URL uses Docker service name db (for app container); DATABASE_URL_LOCAL uses localhost:5432 (for host Prisma CLI)
  • [01-01]: tenantId is nullable on User — super-admins have no tenant scope, avoiding a separate SuperAdmin model
  • [01-01]: Email uniqueness is @@unique([email, tenantId]) — same email can exist across different tenants (realistic for ISP domain)
  • [01-01]: Grace period fields (suspendedAt, gracePeriodEndsAt) included on Tenant at schema creation — cannot be retrofit later
  • [01-02]: NextAuth v4 chosen over v5/Auth.js beta — credentials provider stability priority
  • [01-02]: JWT carries tenantId + roles directly — no DB lookup on each request, stateless multi-tenancy
  • [01-02]: Super-admin authorize uses OR [isSuperAdmin, tenant.status=ACTIVE] — one Prisma query handles both user types
  • [01-02]: Seed uses findFirst+create for super-admin (null tenantId) — PostgreSQL NULL != NULL in unique constraints, upsert would create duplicates
  • [01-02]: SessionProvider wrapped at root layout via Providers component — enables useSession() in all client components

Pending Todos

None.

Blockers/Concerns

  • [Phase 1 research flag]: MikroTik RouterOS Node.js client library maintenance status is LOW confidence — verify node-routeros vs mikronode before implementing router integration (MikroTik integration is v2, but adapter interface should be planned)
  • [Phase 3 research flag]: Semaphore SMS API pricing/stability for 2026 is MEDIUM confidence — verify before any SMS work (SMS is v2, but abstraction layer design is relevant)
  • [01-02 note]: prisma-tenant.ts (from parallel plan 01-03) has TypeScript errors in type checking — auth files are clean. When 01-03 commits, it should fix those errors.

Session Continuity

Last session: 2026-03-04T10:42:58Z Stopped at: Completed 01-02-PLAN.md (NextAuth auth + login UI + middleware + seed) Resume file: None