How aditya-singh2005/looply works
1. This is a Next.js App Router application for an OKR / performance-goals portal. The domain surface is centered on goals, quarterly check-ins, team management, admin reporting, and approval workflows.
2. The app is organized around route groups and role-specific areas rather than a single monolithic page tree. The main authenticated area lives under src/app/(portal), with sub-areas for admin, manager, dashboard, goals, and checkin. There is also a separate src/app/dashboard route family with role-specific pages for admin, manager, and employee.
3. The top-level layout structure is important for the UI architecture. src/app/layout.tsx and src/app/globals.css provide the global shell, while src/app/(portal)/layout.tsx and src/app/dashboard/layout.tsx likely provide authenticated app framing. Reusable chrome is split into AppShell, Sidebar, Topbar, RoleSwitcher, and TimeTravelWidget.
4. Authentication and authorization are cross-cutting concerns. src/lib/context/AuthContext.tsx, src/lib/hooks/useRole.ts, and src/middleware.ts indicate that route access is guarded centrally, with role-based rendering and navigation decisions happening both at the edge and in the client.
5. Supabase is the main backend dependency and persistence layer. The repo has separate client/server entry points in src/lib/supabase.ts, src/lib/supabase/client.ts, src/lib/supabase/server.ts, and src/lib/supabase-server.ts, plus domain-specific query helpers in src/lib/supabase/queries.ts and audit helpers in src/lib/supabase/audit.ts. This suggests the app uses Supabase for auth, database access, and probably audit/event storage.
6. The primary user workflows are goal-centric. Under src/app/(portal)/goals there are list, detail, and new-goal pages, backed by components such as MyGoalsPage, GoalDetailPage, GoalWizard, GoalRow, FilterPills, GoalStatusBadge, and WeightageBar. The data flow appears to be: page/component → goals hooks/queries → Supabase.
7. Check-ins are a separate workflow with their own presentation layer. src/app/(portal)/checkin/page.tsx and src/components/checkin/QuarterlyCheckinPage.tsx indicate a dedicated quarterly review flow, with ScorePill and shared score utilities in src/lib/utils/score.ts and src/components/shared/ProgressRing.tsx supporting scoring and progress visualization.
8. Manager-specific screens focus on team oversight. src/app/(portal)/manager/team and src/app/(portal)/manager/checkins pair with TeamGoalsView and TeamCheckinsView, which implies managers can review direct reports’ goals and check-in status rather than only their own data.
9. Admin functionality is split into operational subdomains: audit, cycles, shared goals, and reports. This is a strong indicator of a back-office control plane for configuration, governance, and analytics rather than just user-facing productivity screens.
10. API routes are used for server-side mutations and operational actions. The notable endpoints are src/app/api/goals/[id]/approve/route.ts for goal approval and src/app/api/seed/route.ts for bootstrapping sample data. These sit alongside the Supabase server helpers, so the architecture mixes client-side fetching with server-mediated mutations where appropriate.
11. The repo has a clear separation between domain logic and UI primitives. Utility modules like src/lib/utils/dates.ts, goal-format.ts, weightage.ts, and score.ts encapsulate business rules, while the src/components/ui folder contains reusable design-system primitives (largely consistent with shadcn/ui patterns).
12. Supporting infrastructure includes Tailwind/PostCSS for styling, TypeScript for type safety, and a small set of scripts for operational tasks. scripts/signup.js and scripts/run_qa.js suggest automated account setup and QA/bootstrap flows, which matters for understanding how the app is exercised outside the browser.
13. For an architecture diagram, the key boundaries are: authenticated portal vs public auth pages, role-based views vs shared domain components, client UI vs Supabase-backed data access, and user-driven flows vs admin/manager oversight flows. The most important external system is Supabase; the most important internal orchestration layer is the Next.js route/layout structure plus middleware-based access control.
Main entry points: queries.ts Queries · AppShell.tsx App shell UI · useGoals.ts Goal hooks · layout.tsx Root layout
Components 34
App shell
Global and authenticated route framing plus access control.
- Root layout · Global app shell and metadata entrypoint.
src/app/layout.tsx - Global styles · Application-wide styling foundation.
src/app/globals.css - Portal layout · Authenticated framing for the main portal routes.
src/app/(portal)/layout.tsx - Dashboard layout · Shared framing for the role-specific dashboard family.
src/app/dashboard/layout.tsx - Middleware · Edge-level route protection and role-aware access control.
src/middleware.ts - Auth context · Client-side authentication and session state.
src/lib/context/AuthContext.tsx - Role hook · Role detection used by navigation and rendering.
src/lib/hooks/useRole.ts
Portal areas
Primary authenticated OKR and performance-goals experience under the portal route group.
- Goals page · Personal goals list and entrypoint.
src/app/(portal)/goals/page.tsx - Goal detail · Single-goal inspection and management.
src/app/(portal)/goals/[id]/page.tsx - New goal · Goal creation flow.
src/app/(portal)/goals/new/page.tsx - Check-in page · Quarterly review and scoring workflow.
src/app/(portal)/checkin/page.tsx - Team goals · Manager view over direct reports' goals.
src/app/(portal)/manager/team/page.tsx - Team check-ins · Manager view over team check-in status.
src/app/(portal)/manager/checkins/page.tsx - Admin home · Back-office landing page for governance tasks.
src/app/(portal)/admin/page.tsx - Audit · Audit trail and oversight screen.
src/app/(portal)/admin/audit/page.tsx - Cycles · Quarter/goal cycle administration.
src/app/(portal)/admin/cycles/page.tsx - Reports · Operational and analytical reporting.
src/app/(portal)/admin/reports/page.tsx - Shared goals · Shared-goal configuration and governance.
src/app/(portal)/admin/shared-goals/page.tsx
Dashboard routes
Role-specific dashboard family with separate entry points.
- Admin dashboard · Admin-specific dashboard entrypoint.
src/app/dashboard/admin/page.tsx - Manager dashboard · Manager-specific dashboard entrypoint.
src/app/dashboard/manager/page.tsx - Employee dashboard · Employee-specific dashboard entrypoint.
src/app/dashboard/employee/page.tsx
Domain data
Supabase-backed access layer, mutations, and business-rule utilities.
- Goal hooks · Client-side goal loading and state orchestration.
src/lib/hooks/useGoals.ts - Queries · Domain queries and reads against Supabase.
src/lib/supabase/queries.ts - Audit helpers · Audit/event write helpers for governance flows.
src/lib/supabase/audit.ts - Supabase client · Client-side Supabase entrypoint.
src/lib/supabase/client.ts - Supabase server · Server-side Supabase entrypoint for authenticated requests.
src/lib/supabase/server.ts - Supabase core · Primary Supabase configuration bridge.
src/lib/supabase.ts - Server bridge · Additional server-side Supabase bridge.
src/lib/supabase-server.ts - Goal utils · Goal formatting and weightage calculations.
src/lib/utils/goal-format.ts
Shared UI
Reusable feature components and design-system primitives.
- App shell UI · Main authenticated shell composition.
src/components/layout/AppShell.tsx - Sidebar · Primary navigation rail.
src/components/layout/Sidebar.tsx - Topbar · Top-level app header and actions.
src/components/layout/Topbar.tsx - Role switcher · Role-aware navigation affordance.
src/components/layout/RoleSwitcher.tsx - Time travel · Temporal context selector for viewing other periods.
src/components/layout/TimeTravelWidget.tsx
Connections 36
- Root layout → Global styles: loads · Root shell applies global styling.
- Root layout → Portal layout: hosts · Authenticated route group hangs off the root app.
- Root layout → Dashboard layout: hosts · Role dashboards mount under the root app.
- Middleware → Auth context: guards · Route protection is coordinated with app auth state.
- Auth context → Role hook: feeds · Session state informs role-aware UI decisions.
- Portal layout → App shell UI: renders · Portal framing composes the shared shell.
- App shell UI → Sidebar: includes · Shell navigation uses the sidebar.
- App shell UI → Topbar: includes · Shell header uses the topbar.
- App shell UI → Role switcher: includes · Shell exposes role switching.
- App shell UI → Time travel: includes · Shell exposes temporal context control.
- Goals page → Goal hooks: loads · Goals list is backed by client goal state.
- Goal detail → Goal hooks: loads · Goal details reuse the same goal data layer.
- New goal → Goal hooks: creates · Goal creation flow shares the goal state layer.
- Check-in page → Goal utils: uses · Check-in scoring relies on shared business rules.
- Team goals → Queries: reads · Manager oversight screen pulls team goal data.
- Team check-ins → Queries: reads · Manager oversight screen pulls team check-in data.
- Audit → Audit helpers: reads · Audit view is backed by audit records.
- Cycles → Queries: reads · Cycle administration uses domain reads.
- Reports → Queries: reads · Reports are assembled from query helpers.
- Shared goals → Queries: reads · Shared-goal governance uses domain reads.
- Admin dashboard → Queries: reads · Admin dashboard summarizes operational data.
- Manager dashboard → Queries: reads · Manager dashboard summarizes team data.
- Employee dashboard → Goal hooks: reads · Employee dashboard is driven by personal goals.
- Goal hooks → Supabase client: uses · Client hooks query Supabase from the browser.
- Queries → Supabase server: uses · Server-side reads and mutations go through the server client.
- Supabase server → Supabase core: bridges · Server client is configured from the shared Supabase setup.
- Supabase client → Supabase core: bridges · Browser client is configured from the shared Supabase setup.
- Server bridge → Supabase core: bridges · Legacy server entrypoint connects to the shared Supabase setup.
- Audit helpers → Supabase server: writes · Audit helpers persist via server-side access.
- Queries → Supabase client: uses · Read helpers can also be used from client-side flows.
- Goal detail → Queries: reads · Goal detail page resolves goal data from queries.
- New goal → Queries: writes · Creation flow persists new goal records.
- Check-in page → Queries: writes · Check-in workflow submits quarterly updates.
- Middleware → Portal layout: protects · Middleware enforces portal access.
- Middleware → Dashboard layout: protects · Middleware enforces dashboard access.
- Dashboard layout → Role hook: adapts · Dashboard framing adapts to the current role.