clqms-be/docs/V2_ROUTES_MIGRATION.md
mahdahar eb883cf059 feat: Add V2 UI with JWT auth, DaisyUI 5, and theme system
- Implement JWT authentication with HTTP-only cookies
- Create /v2/* namespace to avoid conflicts with existing frontend
- Upgrade to DaisyUI 5 + Tailwind CSS 4
- Add light/dark theme toggle with smooth transitions
- Build login page, dashboard, and patient list UI
- Protect V2 routes with auth middleware
- Add comprehensive documentation

No breaking changes - all new features under /v2/* namespace
2025-12-30 08:48:13 +07:00

3.6 KiB

V2 Routes Migration Summary

Date: 2025-12-30

Overview

All new UI views have been moved to the /v2/ prefix to avoid conflicts with existing frontend engineer's work.


Route Changes

Before (Conflicting with existing work)

/                    → Dashboard
/login               → Login page
/patients            → Patients list
/requests            → Lab requests
/settings            → Settings

After (V2 namespace - No conflicts)

/v2/                 → Dashboard
/v2/login            → Login page
/v2/patients         → Patients list
/v2/requests         → Lab requests
/v2/settings         → Settings

Files Modified

1. Routes Configuration

File: app/Config/Routes.php

// Public Routes
$routes->get('/v2/login', 'PagesController::login');

// Protected Page Routes - V2
$routes->group('v2', ['filter' => 'auth'], function ($routes) {
    $routes->get('/', 'PagesController::dashboard');
    $routes->get('dashboard', 'PagesController::dashboard');
    $routes->get('patients', 'PagesController::patients');
    $routes->get('requests', 'PagesController::requests');
    $routes->get('settings', 'PagesController::settings');
});

2. Auth Filter

File: app/Filters/AuthFilter.php

  • Redirects to /v2/login when unauthorized

3. Login Page

File: app/Views/auth/login.php

  • Redirects to /v2/ after successful login

4. Main Layout

File: app/Views/layout/main_layout.php

  • All navigation links updated to /v2/*
  • Logout redirects to /v2/login

5. Dashboard

File: app/Views/dashboard/dashboard_index.php

  • Quick action links updated to /v2/*

URL Mapping

Feature URL Auth Required
Login /v2/login No
Dashboard /v2/ or /v2/dashboard Yes
Patients /v2/patients Yes
Lab Requests /v2/requests Yes
Settings /v2/settings Yes

API Endpoints (Unchanged)

API routes remain the same - no /v2/ prefix needed:

POST   /api/auth/login
POST   /api/auth/register
GET    /api/auth/check
POST   /api/auth/logout
GET    /api/patient
POST   /api/patient
...etc

Testing URLs

Development Server

Login:      http://localhost:8080/v2/login
Dashboard:  http://localhost:8080/v2/
Patients:   http://localhost:8080/v2/patients
Requests:   http://localhost:8080/v2/requests
Settings:   http://localhost:8080/v2/settings

Frontend Engineer's Work

Protected: All existing routes remain untouched

  • Root / is available for frontend engineer
  • /patients, /requests, etc. are available
  • No conflicts with new V2 UI

Migration Checklist

  • Updated routes to use /v2/ prefix
  • Updated AuthFilter redirects
  • Updated login page redirect
  • Updated main layout navigation links
  • Updated dashboard quick action links
  • Updated logout redirect
  • API routes remain unchanged
  • Documentation created

Notes for Team

  1. New UI is at /v2/ - Share this URL with testers
  2. Old routes are free - Frontend engineer can use root paths
  3. API unchanged - Both UIs can use the same API endpoints
  4. Auth works for both - JWT authentication applies to both V1 and V2

Future Considerations

When ready to migrate fully to V2:

  1. Remove /v2/ prefix from routes
  2. Archive or remove old frontend files
  3. Update documentation
  4. Update any bookmarks/links

Or keep both versions running side-by-side if needed.


Status: Complete - No conflicts with existing work