11 KiB
11 KiB
Route Map Next.js WhatsApp Inbox MVP
Dokumen ini memetakan semua screen ke struktur route Next.js App Router. Struktur ini dibuat agar:
- mudah dipahami tim frontend
- konsisten dengan role-based access
- mendukung multi-tenant SaaS
- memisahkan area
super admin,admin client, danagent
Catatan:
- route final bisa disederhanakan nanti
- nama segmen dalam tanda kurung adalah route groups
- tenant context diasumsikan berasal dari session + tenant scoping, bukan selalu dari slug di URL
1. Struktur Global
app/
(public)/
login/page.tsx
forgot-password/page.tsx
reset-password/page.tsx
invite/[token]/page.tsx
unauthorized/page.tsx
(app)/
layout.tsx
profile/page.tsx
profile/edit/page.tsx
profile/change-password/page.tsx
notifications/page.tsx
search/page.tsx
(super-admin)/
super-admin/
page.tsx
tenants/
page.tsx
new/page.tsx
[tenantId]/
page.tsx
edit/page.tsx
channels/new/page.tsx
channels/
page.tsx
[channelId]/page.tsx
billing/
plans/page.tsx
subscriptions/page.tsx
invoices/page.tsx
invoices/[invoiceId]/page.tsx
reports/page.tsx
audit-log/page.tsx
security-events/page.tsx
webhook-logs/page.tsx
alerts/page.tsx
settings/page.tsx
(tenant-admin)/
dashboard/page.tsx
inbox/page.tsx
contacts/
page.tsx
new/page.tsx
import/page.tsx
export/page.tsx
segments/page.tsx
segments/new/page.tsx
segments/[segmentId]/page.tsx
[contactId]/page.tsx
[contactId]/edit/page.tsx
templates/
page.tsx
new/page.tsx
[templateId]/page.tsx
[templateId]/edit/page.tsx
campaigns/
page.tsx
new/page.tsx
review/page.tsx
[campaignId]/page.tsx
[campaignId]/recipients/page.tsx
team/
page.tsx
new/page.tsx
[userId]/page.tsx
[userId]/edit/page.tsx
performance/page.tsx
reports/
page.tsx
response-time/page.tsx
resolution/page.tsx
agent-productivity/page.tsx
campaign-analytics/page.tsx
contact-growth/page.tsx
settings/
page.tsx
profile/page.tsx
business-hours/page.tsx
auto-assignment/page.tsx
tags/page.tsx
canned-responses/page.tsx
integrations/page.tsx
billing/
page.tsx
history/page.tsx
invoices/[invoiceId]/page.tsx
audit-log/page.tsx
(agent)/
agent/
page.tsx
inbox/page.tsx
inbox/unassigned/page.tsx
inbox/mentioned/page.tsx
inbox/resolved/page.tsx
contacts/page.tsx
contacts/[contactId]/page.tsx
quick-tools/page.tsx
performance/page.tsx
2. Public Routes
2.1 Auth
/login/forgot-password/reset-password/invite/[token]/unauthorized
3. Shared App Routes
3.1 Shared User Area
/profile/profile/edit/profile/change-password/notifications/search
4. Super Admin Routes
4.1 Dashboard
/super-admin
4.2 Tenants
/super-admin/tenants/super-admin/tenants/new/super-admin/tenants/[tenantId]/super-admin/tenants/[tenantId]/edit/super-admin/tenants/[tenantId]/channels/new
4.3 Channels
/super-admin/channels/super-admin/channels/[channelId]
4.4 Billing
/super-admin/billing/plans/super-admin/billing/subscriptions/super-admin/billing/invoices/super-admin/billing/invoices/[invoiceId]
4.5 Reports and Governance
/super-admin/reports/super-admin/audit-log/super-admin/security-events/super-admin/webhook-logs/super-admin/alerts/super-admin/settings
5. Admin Client Routes
5.1 Dashboard and Inbox
/dashboard/inbox
Catatan:
- inbox list dan conversation detail paling efisien dibuat dalam satu route dengan split layout
- selected conversation bisa disimpan di query param seperti
?conversationId=xxx
Alternatif kalau ingin route detail eksplisit:
/inbox/[conversationId]
5.2 Contacts
/contacts/contacts/new/contacts/import/contacts/export/contacts/segments/contacts/segments/new/contacts/segments/[segmentId]/contacts/[contactId]/contacts/[contactId]/edit
5.3 Templates
/templates/templates/new/templates/[templateId]/templates/[templateId]/edit
5.4 Campaigns
/campaigns/campaigns/new/campaigns/review/campaigns/[campaignId]/campaigns/[campaignId]/recipients
Catatan:
reviewjuga bisa jadi client-side step internal, tapi dedicated route memudahkan deep link dan QA
5.5 Team
/team/team/new/team/[userId]/team/[userId]/edit/team/performance
5.6 Reports
/reports/reports/response-time/reports/resolution/reports/agent-productivity/reports/campaign-analytics/reports/contact-growth
5.7 Settings
/settings/settings/profile/settings/business-hours/settings/auto-assignment/settings/tags/settings/canned-responses/settings/integrations
5.8 Billing and Audit
/billing/billing/history/billing/invoices/[invoiceId]/audit-log
6. Agent Routes
6.1 Dashboard
/agent
6.2 Inbox
/agent/inbox/agent/inbox/unassigned/agent/inbox/mentioned/agent/inbox/resolved
Catatan:
- seperti admin inbox, selected conversation bisa ditaruh pada query param atau nested segment
Alternatif eksplisit:
/agent/inbox/[conversationId]
6.3 Contacts
/agent/contacts/agent/contacts/[contactId]
6.4 Tools and Performance
/agent/quick-tools/agent/performance
7. Route-to-Screen Mapping
7.1 Public / Auth
Login->/loginForgot Password->/forgot-passwordReset Password->/reset-passwordInvitation Acceptance->/invite/[token]Unauthorized / Forbidden->/unauthorized
7.2 Shared User Area
My Profile->/profileEdit Profile->/profile/editChange Password->/profile/change-passwordNotification Center->/notificationsGlobal Search->/search
7.3 Super Admin
Super Admin Dashboard->/super-adminTenant List->/super-admin/tenantsCreate Tenant->/super-admin/tenants/newTenant Detail->/super-admin/tenants/[tenantId]Edit Tenant->/super-admin/tenants/[tenantId]/editConnect Channel->/super-admin/tenants/[tenantId]/channels/newChannel List->/super-admin/channelsChannel Detail->/super-admin/channels/[channelId]Subscription Plan Catalog->/super-admin/billing/plansTenant Subscription List->/super-admin/billing/subscriptionsInvoices List->/super-admin/billing/invoicesInvoice Detail->/super-admin/billing/invoices/[invoiceId]Platform Reports->/super-admin/reportsAudit Log->/super-admin/audit-logSecurity Events->/super-admin/security-eventsAPI / Webhook Logs->/super-admin/webhook-logsSystem Alerts->/super-admin/alertsPlatform Settings->/super-admin/settings
7.4 Admin Client
Admin Dashboard->/dashboardShared Inbox->/inboxContact List->/contactsCreate Contact->/contacts/newImport Contacts->/contacts/importExport Contacts->/contacts/exportSegments / Lists->/contacts/segmentsCreate Segment->/contacts/segments/newSegment Detail->/contacts/segments/[segmentId]Contact Detail->/contacts/[contactId]Edit Contact->/contacts/[contactId]/editTemplate List->/templatesCreate Template Request->/templates/newTemplate Detail->/templates/[templateId]Edit / Resubmit Template->/templates/[templateId]/editCampaign List->/campaignsCreate Campaign->/campaigns/newCampaign Review->/campaigns/reviewCampaign Detail->/campaigns/[campaignId]Campaign Recipients->/campaigns/[campaignId]/recipientsTeam / Users List->/teamCreate User->/team/newUser Detail->/team/[userId]Edit User->/team/[userId]/editTeam Performance->/team/performanceReports Overview->/reportsResponse Time Report->/reports/response-timeResolution Report->/reports/resolutionAgent Productivity Report->/reports/agent-productivityCampaign Analytics Report->/reports/campaign-analyticsContact Growth Report->/reports/contact-growthTenant Settings->/settingsTenant Profile Settings->/settings/profileBusiness Hours Settings->/settings/business-hoursAuto Assignment Rules->/settings/auto-assignmentChat Tags Management->/settings/tagsCanned Responses->/settings/canned-responsesWebhook / Integration Settings->/settings/integrationsBilling & Subscription->/billingBilling History->/billing/historyInvoice Detail->/billing/invoices/[invoiceId]Tenant Audit Log->/audit-log
7.5 Agent
Agent Dashboard->/agentMy Inbox->/agent/inboxUnassigned Queue->/agent/inbox/unassignedMentioned Conversations->/agent/inbox/mentionedResolved History->/agent/inbox/resolvedAgent Contact List->/agent/contactsAgent Contact Detail->/agent/contacts/[contactId]Quick Tools->/agent/quick-toolsMy Performance->/agent/performance
8. Query Params yang Disarankan
Untuk mengurangi jumlah route berlebihan, beberapa state lebih cocok di query params:
8.1 Inbox
/inbox?tab=unassigned/inbox?conversationId=conv_123/inbox?status=open&assigned=me
8.2 Reports
/reports/response-time?from=2026-04-01&to=2026-04-30/reports/agent-productivity?agentId=user_123
8.3 Campaign Recipients
/campaigns/[campaignId]/recipients?status=failed
9. Route Guards yang Diperlukan
9.1 Public Guard
- redirect logged-in user away from auth pages jika perlu
9.2 Auth Guard
- semua route di
(app)harus login
9.3 Role Guard
super_adminhanya boleh akses/super-admin/*admin_clienthanya boleh akses tenant admin areaagenthanya boleh akses agent area + profile routes
9.4 Tenant Guard
- semua query dan data di tenant area wajib tenant-scoped
10. Rekomendasi Layout Files
app/
(public)/layout.tsx
(app)/layout.tsx
(app)/(super-admin)/super-admin/layout.tsx
(app)/(tenant-admin)/layout.tsx
(app)/(agent)/agent/layout.tsx
Manfaat:
- sidebar/topbar bisa dibedakan per role
- akses kontrol lebih rapi
- shell UI tidak berulang