How marveloussystem0-design/legalhub-deployment works
Purpose and entry points
Legalhub is a legal-services platform for advocates, clients, and administrators: case management, client collaboration, court/eCourts tracking, document drafting, legal knowledge, notifications, verification, and subscriptions. The primary production surface is the Next.js App Router application under web/src/app/page.tsx and web/src/app/dashboard/page.tsx. A separate Expo/React Native mobile client is rooted at mobile-app/app/_layout.tsx.
Web application shell and role portals
The web runtime is a TypeScript Next.js 14 application with server-rendered routes, server actions, and route handlers. Authentication flows enter through web/src/app/login/page.tsx, web/src/app/signup/page.tsx, and web/src/app/auth/callback/page.tsx; role-specific navigation separates advocate, client, and admin workspaces under web/src/app/dashboard/advocate/layout.tsx, web/src/app/dashboard/client/layout.tsx, and web/src/app/dashboard/admin/layout.tsx.
Supabase identity, persistence, and security boundary
Supabase is the system of record and provides PostgreSQL, Auth, Storage, and access enforcement. Web code uses distinct browser, server, middleware, and privileged service-role clients in web/src/lib/supabase/client.ts, web/src/lib/supabase/server.ts, and web/src/lib/supabase/service-role.ts. Database evolution is migration-driven under supabase/migrations/, including signup/profile triggers, RLS hardening, case relationships, notifications, subscriptions, and document sharing. RLS is therefore the principal boundary between user-facing data access and admin/background operations.
Case lifecycle and collaboration
Advocates create, browse, filter, import, update, and synchronize matters; case detail includes participants, documents, timeline, reminders, court links, and eCourts data. The core UI and mutations are concentrated in web/src/app/dashboard/advocate/cases/page.tsx, web/src/app/dashboard/advocate/cases/[id]/page.tsx, and web/src/app/actions/cases.ts. Invite-based client participation crosses into public/authenticated onboarding via web/src/app/api/cases/invite/route.ts and web/src/app/invite/[token]/page.tsx. Advocate/client message views provide the collaboration boundary in web/src/app/dashboard/advocate/messages/page.tsx and web/src/app/dashboard/client/messages/page.tsx.
Court-data ingestion and scheduling
eCourts integration is a server-side acquisition and normalization pipeline: API routes invoke search/sync endpoints, scraper/parser/processor code extracts and transforms court data, and case records consume synchronized hearings and metadata. Key boundaries are web/src/app/api/ecourts/sync/route.ts, web/src/lib/ecourts/scraper.ts, and web/src/lib/ecourts/processor.ts. The repository also contains Puppeteer-based scraping and CAPTCHA/session infrastructure under web/src/lib/scrapers/puppeteer-client.ts, web/src/lib/scrapers/tn-captcha-solver.ts, and web/src/lib/scrapers/advocate-scraper-session-manager.ts. Hearing/reminder automation is exposed as scheduled endpoints in web/src/app/api/cron/reminders/route.ts and web/src/app/api/scheduler/hearings/route.ts.
Legal content and drafting
The platform has two content paths: database-backed legal acts/judgments and application-provided reference datasets/templates. Knowledge-base APIs are in web/src/app/api/knowledge-base/acts/route.ts and web/src/app/api/knowledge-base/judgments/route.ts, backed by web/src/lib/db/legal-acts.ts. Drafting uses an editor and structured templates in web/src/app/dashboard/advocate/draft/page.tsx, web/src/components/editor/document-editor.tsx, and web/src/app/dashboard/advocate/draft/templates/index.ts. The large web/DRAFTS/ corpus is source content rather than application logic.
Monetization, notifications, and delivery
Razorpay-backed subscription and verification-badge payments are handled through API endpoints and billing services: web/src/app/api/billing/create-order/route.ts, web/src/app/api/billing/webhook/route.ts, and web/src/lib/billing/razorpay.ts. Notification dispatch is background-oriented through web/src/app/api/cron/process-notifications/route.ts and web/src/lib/services/notifications.ts. Deployment targets Vercel (web/vercel.json), while Docker support exists at web/Dockerfile and docker-compose.yml; CI/CD is defined in .github/workflows/deploy.yml.
Main entry points: server.ts Supabase · cases.ts Case management · layout.tsx Role portals · page.tsx Next.js web app
Components 17
Client runtimes
- Mobile client
mobile-app/app/_layout.tsx
Web platform
- Next.js web app · Primary server-rendered application and API runtime.
web/src/app/page.tsx - Authentication
web/src/app/login/page.tsx - Role portals · Separate advocate, client, and admin workspaces.
web/src/app/dashboard/advocate/layout.tsx - Case management · Matter lifecycle, participants, documents, and timelines.
web/src/app/actions/cases.ts - Client collaboration · Client participation is initiated by case invitations.
web/src/app/api/cases/invite/route.ts - Legal knowledge · Acts and judgments served from database-backed content.
web/src/app/api/knowledge-base/acts/route.ts - Document drafting · Structured legal drafting for advocates.
web/src/app/dashboard/advocate/draft/page.tsx
Server integrations
- eCourts sync API
web/src/app/api/ecourts/sync/route.ts - Court acquisition · Handles court extraction, CAPTCHA, and sessions.
web/src/lib/ecourts/scraper.ts - Court normalization · Transforms acquired court data for case records.
web/src/lib/ecourts/processor.ts - Subscriptions and payments · Orders, webhooks, subscriptions, and verification badges.
web/src/app/api/billing/create-order/route.ts
Data and security
- Supabase · System of record and identity provider.
web/src/lib/supabase/server.ts - RLS and migrations · Migration-driven schema, triggers, and access enforcement.
supabase/migrations/20260123_final_rls_lockdown.sql
Operations
- Hearing scheduler
web/src/app/api/scheduler/hearings/route.ts - Notification dispatch · Background-oriented notification processing.
web/src/app/api/cron/process-notifications/route.ts - Deployment pipeline
.github/workflows/deploy.yml
Connections 20
- Next.js web app → Authentication: serves
- Authentication → Supabase: uses Auth
- Next.js web app → Role portals: routes users to
- Role portals → Case management: advocate workflow
- Role portals → Client collaboration: message workspaces
- Case management → Client collaboration: invites clients
- Case management → eCourts sync API: syncs court data
- eCourts sync API → Court acquisition: acquires
- Court acquisition → Court normalization: raw court data
- Court normalization → Supabase: stores normalized data
- Hearing scheduler → Case management: updates hearings
- Case management → Supabase: persists matters
- Client collaboration → Supabase: persists access and messages
- Legal knowledge → Supabase: reads legal content
- Document drafting → Case management: uses case context
- Subscriptions and payments → Supabase: updates entitlements
- Notification dispatch → Supabase: reads and records notifications
- Supabase → RLS and migrations: enforced by
- Mobile client → Supabase: accesses platform data
- Deployment pipeline → Next.js web app: deploys