How mrkat303/hiveyoung-app works
1. Top-level architecture
This is a Next.js App Router application with a fairly rich client-side UI, a small set of server API routes, and a Supabase-backed data layer. The repository is organized by product area rather than by technical layer, which makes each domain easy to identify: profile, members/teams, ecosystem/contacts/schools/universities, calendar, workflows, assistant, onboarding, settings, and login.
2. Primary runtime boundary
The app/ directory is the main execution surface. Route segments such as app/(app)/profile, members, ecosystem, assistant, and workflows each own their page entrypoints and feature-specific UI. Shared layout behavior lives in app/layout.tsx and app/(app)/layout.tsx, while global styling is split across app/globals.css and feature CSS files. This suggests a mostly client-rendered interactive dashboard with route-level composition.
3. Domain-driven UI subsystems
Each major feature area has its own component cluster:
• Profile: profile editing, radar/skills, social links, sections for experience/education/certificates/volunteering.
• Members / Teams: team listing and team detail views.
• Ecosystem: contact management plus schools and universities, including detail pages and create/edit modals.
• Assistant: chat UI, wizard cards, previews, and artifact panels.
• Workflows: workflow diagram visualization.
• Calendar: event-focused page.
• Onboarding / Settings / Login: lifecycle and account configuration surfaces.
These areas are isolated enough that an architecture diagram should treat them as separate feature domains fed by shared infrastructure.
4. Shared application shell
The app shell is composed from reusable UI and navigation utilities in app/(app)/_components/Shared, including sidebar, topbar, mobile nav, notifications drawer, onboarding guard, and floating assistant entry point. These components define the cross-cutting frame around the feature pages and likely mediate global state such as notifications, routing, and access/onboarding gating.
5. State management and client hooks
Feature state is abstracted into React contexts and hooks rather than a centralized store. contexts/ includes notification, profile, and toast providers. hooks/ contains domain hooks for calendar events, contacts, kanban, profile, schools, universities, and toast. This points to a pattern where pages and modals consume data through hook-based queries/mutations, while contexts provide app-wide UI state and feedback.
6. Supabase as the system of record
The supabase/schema directory is a major architectural boundary. It contains table definitions for profiles, teams, team membership, tasks, comments, dependencies, subtasks, notifications, contacts, schools, universities, calendar events, system settings, and AI workflows. The schema also includes row-level security policies, realtime configuration, functions, and triggers, indicating that business rules are enforced both in the application and in the database.
7. Database-driven business logic
Several database functions and triggers encode core behavior:
• user onboarding and welcome handling
• school update notifications
• task assignment, comment, status, and subtask notifications
• task progress recalculation and timestamp updates
• permission checks such as admin/director/executive/participant and team management predicates
This means the backend architecture is not just CRUD; it pushes authorization, notifications, and derived state into PostgreSQL/Supabase.
8. AI subsystem
The utils/ai tree is a distinct subsystem with its own orchestration, agents, tools, prompts, permissions, and provider abstractions. There are specialized agents for assistant, planner, scout, editor, comms, member-scout, notion-writer, and an orchestrator layer coordinating them. This is the most service-like part of the repo and should be diagrammed as a separate intelligent workflow engine rather than embedded UI logic.
9. AI-facing API routes
The app/api/ecosystem/ai endpoints bridge the UI and the AI/data backends. They include generic AI handling plus dedicated routes for publishing to Notion, sending email, and returning ecosystem data. There is also a app/api/radar/search route for search-related functionality. These routes are the server boundary where browser requests are converted into tool-using AI actions or search responses.
10. Tooling layer for AI and integrations
utils/ai/tools exposes structured capabilities used by agents: DB access, ecosystem operations, editor actions, communications, Notion integration, schemas, and handlers. This makes the AI subsystem operate through controlled tools rather than direct UI coupling. The architecture likely routes model outputs through tool contracts and permission checks before mutating data or calling external services.
11. External service boundaries
The repo materially depends on:
• Supabase for auth, database, realtime, and server/client access
• Notion for publishing content/workflow artifacts
• Email delivery for notifications or outreach
• Potentially OpenAI or another model provider through the AI provider abstraction
These integrations are concentrated in the AI tool and API route layers, keeping the rest of the app mostly domain/UI focused.
12. Authentication and request mediation
middleware.ts and utils/supabase/middleware.ts indicate request-time auth/session handling at the edge or middleware layer. Combined with utils/supabase/server.ts and utils/supabase/client.ts, the app distinguishes server-side, client-side, and middleware Supabase access paths. That separation is important for the diagram because it defines how authenticated state reaches pages, APIs, and protected routes.
13. UI composition model
The repository uses many modal and panel components for editing entity data in place: profile modals, school/contact modals, task detail modals, team modals, and assistant artifact cards. This suggests the core UX is a single-page dashboard with nested dialogs and side panels layered over route pages, rather than full page transitions for every edit flow.
14. What to emphasize in an architecture diagram
The cleanest diagram would show:
• browser/UI routes in Next.js App Router
• shared shell and feature pages
• React hooks/contexts as the client state and data access layer
• Supabase/Postgres as the authoritative backend with RLS, triggers, and realtime
• a distinct AI orchestration subsystem with tools and specialized agents
• external integrations for Notion and email reached through API routes and tools
That captures the real boundaries and data flow in this repo without over-describing implementation details.
Main entry points: layout.tsx Dashboard shell · useProfile.ts Domain hooks · index.ts AI tools · server.ts Supabase client
Components 25
Next.js app
Route-driven UI, shared shell, and API entrypoints.
- App Router · Main browser-facing application surface built with Next.js App Router.
app/layout.tsx - Dashboard shell · Authenticated app frame with sidebar, topbar, mobile nav, onboarding guard, and notifications.
app/(app)/layout.tsx - Profile · Profile editing, radar, social links, and member profile detail views.
app/(app)/profile/page.tsx - Members · Team listing and team detail pages for member organization.
app/(app)/members/page.tsx - Ecosystem · Contacts, schools, and universities management surfaces.
app/(app)/ecosystem/page.tsx - Assistant UI · Chat-driven assistant experience with artifacts, previews, and wizard cards.
app/(app)/assistant/page.tsx - Workflows · Workflow visualization and diagramming surface.
app/(app)/workflows/page.tsx - Calendar · Event-focused calendar page.
app/(app)/calendar/page.tsx - Onboarding · User onboarding and setup flow.
app/(app)/onboarding/page.tsx - Settings · Application and account configuration surface.
app/(app)/settings/page.tsx - Login · Authentication entry page.
app/login/page.tsx - AI API · API boundary for ecosystem AI requests and orchestration.
app/api/ecosystem/ai/route.ts - AI data · AI-facing data endpoint for ecosystem context and retrieval.
app/api/ecosystem/ai/data/route.ts - Notion publish · Server route for publishing AI-generated content to Notion.
app/api/ecosystem/ai/notion-publish/route.ts - Email send · Server route for sending emails from AI-assisted flows.
app/api/ecosystem/ai/send-email/route.ts - Radar search · Search endpoint used by radar-related UI.
app/api/radar/search/route.ts
AI subsystem
Agents, tools, and request handlers for AI-assisted workflows.
- AI orchestrator · Coordinates specialized agents and execution flow.
utils/ai/orchestrator.ts - Specialist agents · Assistant, planner, scout, editor, comms, member-scout, notion-writer agents.
utils/ai/agents/orchestrator.ts - AI tools · Controlled capabilities for DB, ecosystem, editor, comms, schemas, and handlers.
utils/ai/tools/index.ts - AI permissions · Permission and capability checks for AI actions.
utils/ai/permissions.ts
Supabase schema
Postgres tables, functions, triggers, and policies.
- Database schema · Tables, policies, realtime, functions, and triggers defining system behavior.
supabase/schema/policies.sql
Client infra
Auth/session mediation and shared data-access utilities.
- Supabase client · Browser, server, and middleware Supabase access paths.
utils/supabase/server.ts - Auth middleware · Edge and request-time session handling for protected routes.
middleware.ts - Domain hooks · React hooks for calendar, contacts, kanban, profile, schools, universities, and toast.
hooks/useProfile.ts - App contexts · Notification, profile, and toast providers for shared client state.
contexts/NotificationContext.tsx
Connections 31
- App Router → Dashboard shell: wraps · Root layout composes the authenticated application shell.
- App Router → Login: routes to · Unauthenticated access reaches the login surface.
- Dashboard shell → Profile: navigates · Shared shell frames the profile domain.
- Dashboard shell → Members: navigates · Shared shell frames the members domain.
- Dashboard shell → Ecosystem: navigates · Shared shell frames the ecosystem domain.
- Dashboard shell → Assistant UI: navigates · Shared shell frames the assistant domain.
- Dashboard shell → Workflows: navigates · Shared shell frames the workflows domain.
- Dashboard shell → Calendar: navigates · Shared shell frames the calendar domain.
- Dashboard shell → Onboarding: gates · Onboarding guard can redirect users into setup flows.
- Dashboard shell → Settings: navigates · Shared shell frames settings.
- Dashboard shell → App contexts: consumes · Shell-level UI state comes from shared contexts.
- Profile → Domain hooks: reads · Profile pages use domain hooks for data and mutations.
- Members → Domain hooks: reads · Members and team pages use shared hooks for data access.
- Ecosystem → Domain hooks: reads · Contacts and school views rely on domain hooks.
- Calendar → Domain hooks: reads · Calendar data is fetched through hook abstractions.
- AI API → AI orchestrator: invokes · AI API routes hand off work to the orchestration layer.
- AI API → AI tools: uses · API handlers expose controlled tool execution.
- AI data → AI tools: serves · Data endpoint supplies AI-compatible ecosystem context.
- Notion publish → AI tools: publishes via · Notion publishing is mediated through AI tools.
- Email send → AI tools: sends via · Email delivery is mediated through AI tools.
- Radar search → Domain hooks: supports · Search endpoint backs radar-related client behavior.
- AI orchestrator → Specialist agents: coordinates · Orchestrator delegates to specialized agents.
- AI orchestrator → AI permissions: checks · Orchestration is constrained by AI permissions.
- Specialist agents → AI tools: calls · Agents act through structured tools rather than direct access.
- AI tools → Supabase client: queries · Tools read and mutate repository data through Supabase.
- AI tools → Database schema: targets · Tools operate against schema-defined entities and functions.
- Supabase client → Database schema: backed by · Client and server access paths connect to the Supabase schema.
- Auth middleware → Supabase client: initializes · Middleware handles session/auth plumbing for Supabase.
- Domain hooks → Supabase client: fetches from · Domain hooks use Supabase for client-side data operations.
- App contexts → Domain hooks: pairs with · Shared contexts complement hook-driven data flows and feedback.
- Database schema → Domain hooks: feeds · Tables, triggers, and policies shape what the client can observe.