# proobker/bnks architecture

> Architecture diagram of the GitHub repository proobker/bnks, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/proobker/bnks
- Repository: https://github.com/proobker/bnks

## Overview

#### Purpose and Runtime

EduFit is an education-oriented web application centered on student/teacher authentication, student assessments, personalized event recommendations, and dashboard views. The active architecture is Next.js App Router, with the root layout and route entry points in `src/app/layout.tsx` and `src/app/page.tsx`. The repository also retains parallel Vite/legacy React entry points (`src/main.tsx`, `src/App.tsx`), which create a material boundary and potential source-of-truth ambiguity.

#### Route Surface and UI Stages

Primary user-facing flows are implemented as App Router pages:
- Authentication: `src/app/(auth)/student-login/page.tsx`, `src/app/(auth)/teacher-login/page.tsx`, and OAuth completion at `src/app/(auth)/callback/page.tsx`.
- Student workflow: `src/app/student/page.tsx` and `src/app/assessment/page.tsx`.
- Recommendation output: `src/app/recommendations/page.tsx`.

The root layout (`src/app/layout.tsx`) supplies application-wide rendering concerns, while `src/app/globals.css` is the global styling boundary.

#### Authentication and Authorization

Authentication state is managed through React context, principally `src/context/AuthContext.tsx`, with Supabase client access in `src/lib/supabase.ts`. Login-specific UI separates student Google authentication (`src/components/auth/StudentGoogleButton.tsx`) from teacher credential entry (`src/components/auth/TeacherLoginForm.tsx`).

Route access is guarded by components including `src/components/RouteProtection.tsx` and `src/components/auth/ProtectedRoute.tsx`. The callback route is the handoff boundary where external OAuth identity returns to the application.

#### Assessment-to-Recommendation Pipeline

The core product flow is: authenticated student enters or completes assessment data → application scores/matches the student → matching events are rendered as recommendations.

Assessment orchestration begins at `src/app/assessment/page.tsx`. Domain calculations are isolated in `src/lib/scoring.ts`; AI-related enrichment or generation is bounded in `src/lib/ai.ts`. Recommendations are presented from `src/app/recommendations/page.tsx`, with matching logic in `src/lib/event-matching.ts` and event discovery UI in `src/components/events/EventFinder.tsx`.

#### Event Domain and Data Contracts

Event records and matching contracts are represented locally in `src/data/events.ts`, `src/lib/event-types.ts`, and shared types in `src/lib/types.ts`. This separates static/sample event catalog data from the recommendation algorithm. Matching should consume normalized assessment outputs and event types rather than page-local UI state.

#### Persistence and External Services

Supabase is the principal backend integration, configured through `src/lib/supabase.ts` (with an older JavaScript counterpart at `src/lib/supabase.js`). Database structure is declared in `supabase/schema.sql`; environment configuration is expected via `.env.example`. Supabase likely provides authentication and relational persistence, while Google is an external identity provider for the student login path. Next.js is deployable to Vercel per the project baseline.

#### Legacy/Duplicate Implementation Boundary

The tree contains overlapping JavaScript and TypeScript implementations: `src/contexts/AuthContext.tsx` versus `src/context/AuthContext.tsx`, plus legacy pages such as `src/pages/Dashboard.tsx` and `src/pages/Landing.tsx`. App Router paths under `src/app/` should be treated as the primary runtime surface because the repository is configured as Next.js (`next.config.ts`); Vite-era files (`vite.config.ts`, `src/main.tsx`) require deliberate consolidation or isolation before extending cross-cutting behavior.

Main entry points: [`src/lib/event-matching.ts`](https://github.com/proobker/bnks/blob/main/src/lib/event-matching.ts) (Event matching), [`src/lib/scoring.ts`](https://github.com/proobker/bnks/blob/main/src/lib/scoring.ts) (Scoring), [`src/lib/supabase.ts`](https://github.com/proobker/bnks/blob/main/src/lib/supabase.ts) (Supabase), [`src/app/student/page.tsx`](https://github.com/proobker/bnks/blob/main/src/app/student/page.tsx) (Student dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Next.js App Router"]
  node_layout["Root layout<br/>Next.js layout<br/>[layout.tsx]"]
  node_home["Route entry<br/>Next.js page<br/>[page.tsx]"]
  node_student_dashboard["Student dashboard<br/>Next.js page<br/>[page.tsx]"]
end

subgraph group_auth["Authentication"]
  node_auth_pages["Login routes<br/>Next.js pages<br/>[page.tsx]"]
  node_oauth_callback["OAuth callback<br/>Next.js page<br/>[page.tsx]"]
  node_auth_context["Auth state<br/>React context<br/>[AuthContext.tsx]"]
  node_login_ui["Login UI<br/>Auth components"]
  node_route_guards["Route guards<br/>Protection components"]
end

subgraph group_pipeline["Assessment &amp; Recommendations"]
  node_assessment["Assessment<br/>Next.js page<br/>[page.tsx]"]
  node_scoring["Scoring<br/>Domain logic<br/>[scoring.ts]"]
  node_ai{{"AI enrichment<br/>AI boundary<br/>[ai.ts]"}}
  node_matching["Event matching<br/>Recommendation logic<br/>[event-matching.ts]"]
  node_recommendations["Recommendations<br/>Next.js page<br/>[page.tsx]"]
  node_event_finder["Event finder<br/>UI component<br/>[EventFinder.tsx]"]
end

subgraph group_data["Data &amp; Services"]
  node_event_catalog["Event catalog<br/>Static data<br/>[events.ts]"]
  node_contracts["Event contracts<br/>Shared types<br/>[event-types.ts]"]
  node_supabase[("Supabase<br/>Backend integration<br/>[supabase.ts]")]
  node_schema["Database schema<br/>SQL schema<br/>[schema.sql]"]
end

subgraph group_legacy["Legacy Runtime"]
  node_legacy_runtime["Vite legacy entry<br/>Legacy React runtime<br/>[main.tsx]"]
  node_legacy_auth["Duplicate auth context<br/>Legacy React context<br/>[AuthContext.tsx]"]
end

node_layout -->|"wraps"| node_home
node_home -->|"student flow"| node_student_dashboard
node_auth_pages -->|"uses"| node_login_ui
node_login_ui -->|"authenticates"| node_supabase
node_supabase -->|"returns OAuth session"| node_oauth_callback
node_oauth_callback -->|"establishes session"| node_auth_context
node_auth_context -->|"authorizes"| node_route_guards
node_route_guards -->|"guards"| node_student_dashboard
node_student_dashboard -->|"starts assessment"| node_assessment
node_assessment -->|"submits inputs"| node_scoring
node_scoring -->|"enriches"| node_ai
node_scoring -->|"normalized results"| node_matching
node_ai -.->|"optional enrichment"| node_matching
node_matching -->|"matches against"| node_event_catalog
node_contracts -->|"defines inputs"| node_matching
node_matching -->|"produces recommendations"| node_recommendations
node_recommendations -->|"renders with"| node_event_finder
node_supabase -->|"persisted by"| node_schema
node_legacy_runtime -->|"uses"| node_legacy_auth
node_legacy_runtime -.->|"parallel to primary runtime"| node_layout

click node_layout "https://github.com/proobker/bnks/blob/main/src/app/layout.tsx"
click node_home "https://github.com/proobker/bnks/blob/main/src/app/page.tsx"
click node_student_dashboard "https://github.com/proobker/bnks/blob/main/src/app/student/page.tsx"
click node_auth_pages "https://github.com/proobker/bnks/blob/main/src/app/(auth)/student-login/page.tsx"
click node_oauth_callback "https://github.com/proobker/bnks/blob/main/src/app/(auth)/callback/page.tsx"
click node_auth_context "https://github.com/proobker/bnks/blob/main/src/context/AuthContext.tsx"
click node_login_ui "https://github.com/proobker/bnks/blob/main/src/components/auth/StudentGoogleButton.tsx"
click node_route_guards "https://github.com/proobker/bnks/blob/main/src/components/RouteProtection.tsx"
click node_assessment "https://github.com/proobker/bnks/blob/main/src/app/assessment/page.tsx"
click node_scoring "https://github.com/proobker/bnks/blob/main/src/lib/scoring.ts"
click node_ai "https://github.com/proobker/bnks/blob/main/src/lib/ai.ts"
click node_matching "https://github.com/proobker/bnks/blob/main/src/lib/event-matching.ts"
click node_recommendations "https://github.com/proobker/bnks/blob/main/src/app/recommendations/page.tsx"
click node_event_finder "https://github.com/proobker/bnks/blob/main/src/components/events/EventFinder.tsx"
click node_event_catalog "https://github.com/proobker/bnks/blob/main/src/data/events.ts"
click node_contracts "https://github.com/proobker/bnks/blob/main/src/lib/event-types.ts"
click node_supabase "https://github.com/proobker/bnks/blob/main/src/lib/supabase.ts"
click node_schema "https://github.com/proobker/bnks/blob/main/supabase/schema.sql"
click node_legacy_runtime "https://github.com/proobker/bnks/blob/main/src/main.tsx"
click node_legacy_auth "https://github.com/proobker/bnks/blob/main/src/contexts/AuthContext.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_layout,node_home,node_student_dashboard toneBlue
class node_auth_pages,node_oauth_callback,node_auth_context,node_login_ui,node_route_guards toneAmber
class node_assessment,node_scoring,node_ai,node_matching,node_recommendations,node_event_finder toneMint
class node_event_catalog,node_contracts,node_supabase,node_schema toneRose
class node_legacy_runtime,node_legacy_auth toneIndigo
```

## Components

### Next.js App Router

Primary runtime surface.

- [Root layout](https://github.com/proobker/bnks/blob/main/src/app/layout.tsx): Next.js layout · Supplies application-wide rendering concerns. · `src/app/layout.tsx`
- [Route entry](https://github.com/proobker/bnks/blob/main/src/app/page.tsx): Next.js page · `src/app/page.tsx`
- [Student dashboard](https://github.com/proobker/bnks/blob/main/src/app/student/page.tsx): Next.js page · `src/app/student/page.tsx`

### Authentication

- [Login routes](https://github.com/proobker/bnks/blob/main/src/app/(auth)/student-login/page.tsx): Next.js pages · Student and teacher login entry points. · `src/app/(auth)/student-login/page.tsx`
- [OAuth callback](https://github.com/proobker/bnks/blob/main/src/app/(auth)/callback/page.tsx): Next.js page · External identity handoff boundary. · `src/app/(auth)/callback/page.tsx`
- [Auth state](https://github.com/proobker/bnks/blob/main/src/context/AuthContext.tsx): React context · `src/context/AuthContext.tsx`
- [Login UI](https://github.com/proobker/bnks/blob/main/src/components/auth/StudentGoogleButton.tsx): Auth components · Google student sign-in and teacher credential form. · `src/components/auth/StudentGoogleButton.tsx`
- [Route guards](https://github.com/proobker/bnks/blob/main/src/components/RouteProtection.tsx): Protection components · `src/components/RouteProtection.tsx`

### Assessment & Recommendations

- [Assessment](https://github.com/proobker/bnks/blob/main/src/app/assessment/page.tsx): Next.js page · Collects and orchestrates student assessment input. · `src/app/assessment/page.tsx`
- [Scoring](https://github.com/proobker/bnks/blob/main/src/lib/scoring.ts): Domain logic · Normalizes and scores assessment outputs. · `src/lib/scoring.ts`
- [AI enrichment](https://github.com/proobker/bnks/blob/main/src/lib/ai.ts): AI boundary · `src/lib/ai.ts`
- [Event matching](https://github.com/proobker/bnks/blob/main/src/lib/event-matching.ts): Recommendation logic · `src/lib/event-matching.ts`
- [Recommendations](https://github.com/proobker/bnks/blob/main/src/app/recommendations/page.tsx): Next.js page · `src/app/recommendations/page.tsx`
- [Event finder](https://github.com/proobker/bnks/blob/main/src/components/events/EventFinder.tsx): UI component · Renders event discovery output. · `src/components/events/EventFinder.tsx`

### Data & Services

- [Event catalog](https://github.com/proobker/bnks/blob/main/src/data/events.ts): Static data · `src/data/events.ts`
- [Event contracts](https://github.com/proobker/bnks/blob/main/src/lib/event-types.ts): Shared types · Event and shared domain types. · `src/lib/event-types.ts`
- [Supabase](https://github.com/proobker/bnks/blob/main/src/lib/supabase.ts): Backend integration · Provides authentication and relational persistence. · `src/lib/supabase.ts`
- [Database schema](https://github.com/proobker/bnks/blob/main/supabase/schema.sql): SQL schema · `supabase/schema.sql`

### Legacy Runtime

Parallel Vite-era implementation boundary.

- [Vite legacy entry](https://github.com/proobker/bnks/blob/main/src/main.tsx): Legacy React runtime · Parallel implementation requiring isolation or consolidation. · `src/main.tsx`
- [Duplicate auth context](https://github.com/proobker/bnks/blob/main/src/contexts/AuthContext.tsx): Legacy React context · `src/contexts/AuthContext.tsx`

## Connections

- Root layout → Route entry: wraps
- Route entry → Student dashboard: student flow
- Login routes → Login UI: uses
- Login UI → Supabase: authenticates
- Supabase → OAuth callback: returns OAuth session
- OAuth callback → Auth state: establishes session
- Auth state → Route guards: authorizes
- Route guards → Student dashboard: guards
- Student dashboard → Assessment: starts assessment
- Assessment → Scoring: submits inputs
- Scoring → AI enrichment: enriches
- Scoring → Event matching: normalized results
- AI enrichment → Event matching: optional enrichment
- Event matching → Event catalog: matches against
- Event contracts → Event matching: defines inputs
- Event matching → Recommendations: produces recommendations
- Recommendations → Event finder: renders with
- Supabase → Database schema: persisted by
- Vite legacy entry → Duplicate auth context: uses
- Vite legacy entry → Root layout: parallel to primary runtime
