# ikhfri/reweave architecture

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

- Interactive diagram: https://gitdiagram.com/ikhfri/reweave
- Repository: https://github.com/ikhfri/reweave

## Overview

Reweave is a bilingual mental-wellness application for recording check-ins and diary reflections, receiving AI-generated reflections, and reviewing emotional patterns and coping activities. Users enter through the localized web experience; protected features rely on session authentication and API routes, with Prisma-backed records. The graph preserves the documented check-in, diary, AI, insights, activities, privacy, and language capabilities. Relationship evidence is limited to the README and indexed imports or shown excerpts; unsampled UI-to-API links are omitted rather than inferred.

Main entry points: [`src/lib/prisma.ts`](https://github.com/ikhfri/reweave/blob/main/src/lib/prisma.ts) (Application database), [`src/lib/auth.ts`](https://github.com/ikhfri/reweave/blob/main/src/lib/auth.ts) (Session authentication), [`src/app/api/check-ins/route.ts`](https://github.com/ikhfri/reweave/blob/main/src/app/api/check-ins/route.ts) (Check-in API), [`src/app/api/ai/analyze/route.ts`](https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/analyze/route.ts) (Check-in analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_localized["Localized pages"]
  node_checkin_ui["Check-in flow"]
  node_diary_ui["Diary"]
  node_dashboard_ui["Dashboard shell"]
end

subgraph group_reflection["Reflection and analysis"]
  node_checkin_api["Check-in API<br/>[route.ts]"]
  node_diary_api["Diary API<br/>[route.ts]"]
  node_ai_checkin["Check-in analysis<br/>[route.ts]"]
  node_ai_diary["Diary analysis<br/>[route.ts]"]
  node_ai_result["Analysis presentation"]
  node_gemini["AI client<br/>[gemini.ts]"]
  node_weekly_ai["Weekly summary<br/>[route.ts]"]
end

subgraph group_insights["Insights and activities"]
  node_dashboard_api["Dashboard data<br/>[route.ts]"]
  node_weekly_insights["Weekly insights<br/>[route.ts]"]
  node_calendar_api["Mood calendar data<br/>[route.ts]"]
  node_calendar_ui["Mood calendar<br/>[mood-calendar.tsx]"]
  node_activities["Coping activities"]
end

subgraph group_identity["Identity and preferences"]
  node_auth_routes["Authentication routes"]
  node_otp["OTP verification<br/>[otp.ts]"]
  node_session["Session authentication<br/>[auth.ts]"]
  node_settings["User preferences<br/>[route.ts]"]
  node_privacy["Privacy controls<br/>[route.ts]"]
end

subgraph group_platform["Shared services"]
  node_database[("Application database<br/>[prisma.ts]")]
  node_timezone["Timezone utilities<br/>[timezone.ts]"]
  node_i18n["Locale configuration<br/>[config.ts]"]
  node_reminders["Check-in reminders<br/>[daily-checkin.ts]"]
  node_mailer["Email delivery<br/>[mailer.ts]"]
end

node_user(("User"))
node_provider(("AI provider"))

node_user -->|"uses"| node_localized
node_localized -->|"supports languages"| node_i18n
node_user -->|"records emotions"| node_checkin_ui
node_user -->|"writes reflections"| node_diary_ui
node_user -->|"reviews progress"| node_dashboard_ui
node_checkin_api -->|"authenticates"| node_session
node_checkin_api -->|"gets local day"| node_timezone
node_checkin_api -->|"reads and writes"| node_database
node_diary_api -->|"authenticates"| node_session
node_diary_api -->|"reads and writes"| node_database
node_ai_checkin -->|"authenticates"| node_session
node_ai_checkin -->|"loads and saves"| node_database
node_ai_checkin -->|"requests analysis"| node_gemini
node_ai_diary -->|"authenticates"| node_session
node_ai_diary -->|"loads and saves"| node_database
node_ai_diary -->|"requests analysis"| node_gemini
node_user -->|"reviews reflections"| node_ai_result
node_weekly_ai -->|"authenticates"| node_session
node_weekly_ai -->|"loads and saves"| node_database
node_gemini -.->|"calls provider"| node_provider
node_dashboard_api -->|"authenticates"| node_session
node_dashboard_api -->|"loads dashboard data"| node_database
node_dashboard_api -->|"gets local day"| node_timezone
node_weekly_insights -->|"reads trends"| node_database
node_calendar_api -->|"reads calendar data"| node_database
node_user -->|"reviews patterns"| node_calendar_ui
node_activities -->|"reads activity data"| node_database
node_auth_routes -->|"creates sessions"| node_session
node_auth_routes -->|"manages verification"| node_otp
node_otp -->|"stores codes"| node_database
node_session -->|"stores sessions"| node_database
node_settings -->|"authenticates"| node_session
node_settings -->|"reads and updates"| node_database
node_privacy -->|"authenticates"| node_session
node_privacy -->|"loads user records"| node_database
node_reminders -->|"reads reminder settings"| node_database
node_reminders -->|"sends reminders"| node_mailer

click node_localized "https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D"
click node_checkin_ui "https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D/(protected)/moodlog"
click node_diary_ui "https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D/(protected)/diary"
click node_dashboard_ui "https://github.com/ikhfri/reweave/blob/main/src/components/dashboard/dashboard-shell.tsx"
click node_checkin_api "https://github.com/ikhfri/reweave/blob/main/src/app/api/check-ins/route.ts"
click node_diary_api "https://github.com/ikhfri/reweave/blob/main/src/app/api/diary/route.ts"
click node_ai_checkin "https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/analyze/route.ts"
click node_ai_diary "https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/analyze-diary/route.ts"
click node_ai_result "https://github.com/ikhfri/reweave/blob/main/src/components/ai-analysis-result.tsx"
click node_gemini "https://github.com/ikhfri/reweave/blob/main/src/lib/gemini.ts"
click node_weekly_ai "https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/weekly-summary/route.ts"
click node_dashboard_api "https://github.com/ikhfri/reweave/blob/main/src/app/api/dashboard/route.ts"
click node_weekly_insights "https://github.com/ikhfri/reweave/blob/main/src/app/api/insights/weekly/route.ts"
click node_calendar_api "https://github.com/ikhfri/reweave/blob/main/src/app/api/insights/calendar/route.ts"
click node_calendar_ui "https://github.com/ikhfri/reweave/blob/main/src/components/insights/mood-calendar.tsx"
click node_activities "https://github.com/ikhfri/reweave/tree/main/src/app/api/activities"
click node_auth_routes "https://github.com/ikhfri/reweave/tree/main/src/app/api/auth"
click node_otp "https://github.com/ikhfri/reweave/blob/main/src/lib/auth/otp.ts"
click node_session "https://github.com/ikhfri/reweave/blob/main/src/lib/auth.ts"
click node_settings "https://github.com/ikhfri/reweave/blob/main/src/app/api/settings/route.ts"
click node_privacy "https://github.com/ikhfri/reweave/blob/main/src/app/api/privacy/export/route.ts"
click node_database "https://github.com/ikhfri/reweave/blob/main/src/lib/prisma.ts"
click node_timezone "https://github.com/ikhfri/reweave/blob/main/src/lib/date/timezone.ts"
click node_i18n "https://github.com/ikhfri/reweave/blob/main/src/i18n/config.ts"
click node_reminders "https://github.com/ikhfri/reweave/blob/main/src/lib/reminders/daily-checkin.ts"
click node_mailer "https://github.com/ikhfri/reweave/blob/main/src/lib/email/mailer.ts"

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_localized,node_checkin_ui,node_diary_ui,node_dashboard_ui,node_user toneBlue
class node_checkin_api,node_diary_api,node_ai_checkin,node_ai_diary,node_ai_result,node_gemini,node_weekly_ai toneAmber
class node_dashboard_api,node_weekly_insights,node_calendar_api,node_calendar_ui,node_activities toneMint
class node_auth_routes,node_otp,node_session,node_settings,node_privacy toneRose
class node_database,node_timezone,node_i18n,node_reminders,node_mailer,node_provider toneIndigo
```

## Components

### Web experience

- [Localized pages](https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D): `src/app/[locale]`
- [Check-in flow](https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D/(protected)/moodlog): `src/app/[locale]/(protected)/moodlog`
- [Diary](https://github.com/ikhfri/reweave/tree/main/src/app/%5Blocale%5D/(protected)/diary): `src/app/[locale]/(protected)/diary`
- [Dashboard shell](https://github.com/ikhfri/reweave/blob/main/src/components/dashboard/dashboard-shell.tsx): `src/components/dashboard/dashboard-shell.tsx`

### Reflection and analysis

- [Check-in API](https://github.com/ikhfri/reweave/blob/main/src/app/api/check-ins/route.ts): `src/app/api/check-ins/route.ts`
- [Diary API](https://github.com/ikhfri/reweave/blob/main/src/app/api/diary/route.ts): `src/app/api/diary/route.ts`
- [Check-in analysis](https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/analyze/route.ts): `src/app/api/ai/analyze/route.ts`
- [Diary analysis](https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/analyze-diary/route.ts): `src/app/api/ai/analyze-diary/route.ts`
- [Analysis presentation](https://github.com/ikhfri/reweave/blob/main/src/components/ai-analysis-result.tsx): `src/components/ai-analysis-result.tsx`
- [AI client](https://github.com/ikhfri/reweave/blob/main/src/lib/gemini.ts): `src/lib/gemini.ts`
- [Weekly summary](https://github.com/ikhfri/reweave/blob/main/src/app/api/ai/weekly-summary/route.ts): `src/app/api/ai/weekly-summary/route.ts`

### Insights and activities

- [Dashboard data](https://github.com/ikhfri/reweave/blob/main/src/app/api/dashboard/route.ts): `src/app/api/dashboard/route.ts`
- [Weekly insights](https://github.com/ikhfri/reweave/blob/main/src/app/api/insights/weekly/route.ts): `src/app/api/insights/weekly/route.ts`
- [Mood calendar data](https://github.com/ikhfri/reweave/blob/main/src/app/api/insights/calendar/route.ts): `src/app/api/insights/calendar/route.ts`
- [Mood calendar](https://github.com/ikhfri/reweave/blob/main/src/components/insights/mood-calendar.tsx): `src/components/insights/mood-calendar.tsx`
- [Coping activities](https://github.com/ikhfri/reweave/tree/main/src/app/api/activities): `src/app/api/activities`

### Identity and preferences

- [Authentication routes](https://github.com/ikhfri/reweave/tree/main/src/app/api/auth): `src/app/api/auth`
- [OTP verification](https://github.com/ikhfri/reweave/blob/main/src/lib/auth/otp.ts): `src/lib/auth/otp.ts`
- [Session authentication](https://github.com/ikhfri/reweave/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [User preferences](https://github.com/ikhfri/reweave/blob/main/src/app/api/settings/route.ts): `src/app/api/settings/route.ts`
- [Privacy controls](https://github.com/ikhfri/reweave/blob/main/src/app/api/privacy/export/route.ts): `src/app/api/privacy/export/route.ts`

### Shared services

- [Application database](https://github.com/ikhfri/reweave/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Timezone utilities](https://github.com/ikhfri/reweave/blob/main/src/lib/date/timezone.ts): `src/lib/date/timezone.ts`
- [Locale configuration](https://github.com/ikhfri/reweave/blob/main/src/i18n/config.ts): `src/i18n/config.ts`
- [Check-in reminders](https://github.com/ikhfri/reweave/blob/main/src/lib/reminders/daily-checkin.ts): `src/lib/reminders/daily-checkin.ts`
- [Email delivery](https://github.com/ikhfri/reweave/blob/main/src/lib/email/mailer.ts): `src/lib/email/mailer.ts`

### Other components

- **User**
- **AI provider**

## Connections

- User → Localized pages: uses (evidence: `README.md`)
- Localized pages → Locale configuration: supports languages
- User → Check-in flow: records emotions (evidence: `README.md`)
- User → Diary: writes reflections (evidence: `README.md`)
- User → Dashboard shell: reviews progress (evidence: `README.md`)
- Check-in API → Session authentication: authenticates (evidence: `src/app/api/check-ins/route.ts`)
- Check-in API → Timezone utilities: gets local day (evidence: `src/app/api/check-ins/route.ts`)
- Check-in API → Application database: reads and writes (evidence: `src/app/api/check-ins/route.ts`)
- Diary API → Session authentication: authenticates (evidence: `src/app/api/diary/route.ts`)
- Diary API → Application database: reads and writes (evidence: `src/app/api/diary/route.ts`)
- Check-in analysis → Session authentication: authenticates (evidence: `src/app/api/ai/analyze/route.ts`)
- Check-in analysis → Application database: loads and saves (evidence: `src/app/api/ai/analyze/route.ts`)
- Check-in analysis → AI client: requests analysis (evidence: `src/app/api/ai/analyze/route.ts`)
- Diary analysis → Session authentication: authenticates (evidence: `src/app/api/ai/analyze-diary/route.ts`)
- Diary analysis → Application database: loads and saves (evidence: `src/app/api/ai/analyze-diary/route.ts`)
- Diary analysis → AI client: requests analysis (evidence: `src/app/api/ai/analyze-diary/route.ts`)
- User → Analysis presentation: reviews reflections (evidence: `README.md`)
- Weekly summary → Session authentication: authenticates (evidence: `src/app/api/ai/weekly-summary/route.ts`)
- Weekly summary → Application database: loads and saves (evidence: `src/app/api/ai/weekly-summary/route.ts`)
- AI client → AI provider: calls provider (evidence: `README.md`)
- Dashboard data → Session authentication: authenticates (evidence: `src/app/api/dashboard/route.ts`)
- Dashboard data → Application database: loads dashboard data (evidence: `src/app/api/dashboard/route.ts`)
- Dashboard data → Timezone utilities: gets local day (evidence: `src/app/api/dashboard/route.ts`)
- Weekly insights → Application database: reads trends (evidence: `src/app/api/insights/weekly/route.ts`)
- Mood calendar data → Application database: reads calendar data (evidence: `src/app/api/insights/calendar/route.ts`)
- User → Mood calendar: reviews patterns (evidence: `README.md`)
- Coping activities → Application database: reads activity data (evidence: `src/app/api/activities/recommended/route.ts`)
- Authentication routes → Session authentication: creates sessions (evidence: `src/app/api/auth/register/route.ts`)
- Authentication routes → OTP verification: manages verification (evidence: `src/app/api/auth/register/route.ts`)
- OTP verification → Application database: stores codes (evidence: `src/lib/auth/otp.ts`)
- Session authentication → Application database: stores sessions (evidence: `src/lib/auth.ts`)
- User preferences → Session authentication: authenticates (evidence: `src/app/api/settings/route.ts`)
- User preferences → Application database: reads and updates (evidence: `src/app/api/settings/route.ts`)
- Privacy controls → Session authentication: authenticates (evidence: `src/app/api/privacy/export/route.ts`)
- Privacy controls → Application database: loads user records (evidence: `src/app/api/privacy/export/route.ts`)
- Check-in reminders → Application database: reads reminder settings (evidence: `src/lib/reminders/daily-checkin.ts`)
- Check-in reminders → Email delivery: sends reminders (evidence: `src/lib/reminders/daily-checkin.ts`)
