How nabdcm/iada works
1. This is a Next.js application using the App Router and TypeScript. The architecture is split between UI routes under src/app, reusable UI in components, and server-side helpers in src/lib.
2. The main runtime boundary is the Next.js app itself: page components render the user-facing screens, while src/app/api/*/route.ts files expose HTTP endpoints for backend actions. That gives the repo a clear frontend + API split inside a single codebase.
3. The backend data layer appears to be Supabase. src/lib/supabase.ts is the central integration point, and src/lib/auth.ts likely contains authentication/session logic used across protected pages and middleware.
4. Authentication and access control are enforced at the edge with middleware.ts. That suggests route gating before requests reach pages, likely protecting dashboard/admin/patient-management areas and redirecting unauthenticated or blocked users.
5. The core product domain looks like a clinic management system. The API routes under src/app/api/ support clinic lifecycle operations: create, update, delete, freeze, cancel, and list clinics. These routes define the main server-side business boundary.
6. The UI is organized around operational workflows rather than generic navigation. Key screens include dashboard, appointments, patients, payments, prescriptions, and patient-tracking, which likely consume shared clinic/patient data from Supabase through the API or direct server access.
7. There is a public booking flow under src/app/book/[clinicId], indicating a clinic-specific appointment booking page. This is a separate entry path from the internal dashboard, and it likely uses the clinic ID as the primary lookup key.
8. There is also a tokenized daily-log/[token] route, which looks like a shareable or access-controlled workflow distinct from normal authenticated users. That implies a second access model alongside the standard login-protected app.
9. src/app/login and src/app/blocked suggest explicit auth-state outcomes: successful sign-in, and a blocked/denied state for accounts or clinics that are suspended/frozen. The freeze/cancel clinic APIs line up with that lifecycle.
10. components/ClinicProfileSetup.tsx is the notable reusable feature component. It likely supports onboarding or clinic configuration and sits between the admin/management pages and the underlying clinic records.
11. The src/app/api/*/page.tsx files are unusual because they are page routes nested under api. In architecture terms, they behave as UI pages rather than HTTP handlers, so they should be treated as part of the app’s screen structure, not the backend API surface.
12. Overall, the repository centers on one bounded domain: managing clinics, their staff/patients/appointments/payments, and access-controlled operational views. The main data flow is: user or public visitor enters a page → middleware/auth decides access → page loads data from Supabase or calls a route handler → UI updates clinic records and related workflows.
Main entry points: supabase.ts Supabase · middleware.ts Middleware · auth.ts Auth · route.ts Create clinic
Components 27
App routes
User-facing screens and route-driven workflows
- App shell · Root app layout and global providers
src/app/layout.tsx - Landing · Public entry page
src/app/page.tsx - Login · Sign-in screen
src/app/login/page.tsx - Blocked · Denied or suspended account state
src/app/blocked/page.tsx - Dashboard · Main authenticated overview
src/app/dashboard/page.tsx - Admin · Administrative control screen
src/app/admin/page.tsx - Appointments · Appointment management screen
src/app/appointments/page.tsx - Patients · Patient management screen
src/app/patients/page.tsx - Payments · Billing and payment screen
src/app/payments/page.tsx - Prescriptions · Prescription workflow screen
src/app/prescriptions/page.tsx - Tracking · Patient tracking screen
src/app/patient-tracking/page.tsx - Book visit · Clinic-specific public booking flow
src/app/book/[clinicId]/page.tsx - Daily log · Shareable tokenized daily-log workflow
src/app/daily-log/[token]/page.tsx
API backend
HTTP handlers and API-hosted screens
- API dashboard · Dashboard-like UI nested under api
src/app/api/dashboard/page.tsx - API appointments · Appointments UI nested under api
src/app/api/appointments/page.tsx - API patients · Patients UI nested under api
src/app/api/patients/page.tsx - API payments · Payments UI nested under api
src/app/api/payments/page.tsx - Create clinic · Clinic creation endpoint
src/app/api/create-clinic/route.ts - Update clinic · Clinic update endpoint
src/app/api/update-clinic/route.ts - Freeze clinic · Clinic suspension endpoint
src/app/api/freeze-clinic/route.ts - Cancel clinic · Clinic cancellation endpoint
src/app/api/cancel-clinic/route.ts - Delete clinic · Clinic deletion endpoint
src/app/api/delete-clinic/route.ts - List clinics · Clinic listing endpoint
src/app/api/get-clinics/route.ts
Shared code
Cross-cutting auth, data access, and reusable UI
- Middleware · Route gating and access control before rendering
middleware.ts - Auth · Session and access logic
src/lib/auth.ts - Supabase · Primary database and backend integration
src/lib/supabase.ts - Clinic setup · Reusable clinic profile onboarding/configuration UI
components/ClinicProfileSetup.tsx
Connections 38
- App shell → Landing: wraps · Root layout frames the application
- Middleware → Auth: uses · Edge checks rely on auth/session state
- Middleware → Login: permits · Login remains reachable without gating
- Middleware → Blocked: redirects · Blocked access routes to denied state
- Middleware → Dashboard: guards · Protects internal operational pages
- Middleware → Admin: guards · Protects administrative pages
- Middleware → Appointments: guards · Protects workflow pages
- Middleware → Patients: guards · Protects workflow pages
- Middleware → Payments: guards · Protects workflow pages
- Middleware → Prescriptions: guards · Protects workflow pages
- Middleware → Tracking: guards · Protects workflow pages
- Dashboard → Supabase: reads · Dashboard loads clinic data
- Appointments → Supabase: reads · Appointments screen consumes clinic data
- Patients → Supabase: reads · Patients screen consumes records
- Payments → Supabase: reads · Payments screen consumes billing data
- Prescriptions → Supabase: reads · Prescription workflow uses backend data
- Tracking → Supabase: reads · Tracking screen uses patient state
- Book visit → Supabase: reads · Public booking looks up clinic by id
- Daily log → Supabase: reads · Token workflow resolves log data
- API dashboard → Supabase: reads · API-hosted dashboard accesses data
- API appointments → Supabase: reads · API-hosted appointments accesses data
- API patients → Supabase: reads · API-hosted patients accesses data
- API payments → Supabase: reads · API-hosted payments accesses data
- Create clinic → Supabase: writes · Creates clinic records
- Update clinic → Supabase: writes · Updates clinic records
- Freeze clinic → Supabase: writes · Freezes clinic state
- Cancel clinic → Supabase: writes · Cancels clinic state
- Delete clinic → Supabase: writes · Deletes clinic records
- List clinics → Supabase: reads · Lists clinics from storage
- Create clinic → Auth: verifies · Mutation routes likely enforce identity
- Update clinic → Auth: verifies · Mutation routes likely enforce identity
- Freeze clinic → Auth: verifies · Mutation routes likely enforce identity
- Cancel clinic → Auth: verifies · Mutation routes likely enforce identity
- Delete clinic → Auth: verifies · Mutation routes likely enforce identity
- List clinics → Auth: verifies · Listing route may enforce access
- Admin → Clinic setup: uses · Admin/management flows reuse clinic setup UI
- Dashboard → Clinic setup: uses · Operational setup can surface here
- Create clinic → Clinic setup: supports · Creation flow pairs with setup component