# chaitanya-361/velvet-streak architecture

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

- Interactive diagram: https://gitdiagram.com/chaitanya-361/velvet-streak
- Repository: https://github.com/chaitanya-361/velvet-streak

## Overview

Velvet Streak is a full-stack habit-tracking app: users authenticate, create scheduled habits, record check-ins, and see streaks, XP, badges, and analytics. The React client also supports task management, profile/settings, and a focus timer; the Express API applies domain logic and persists records in MongoDB. The graph preserves the README’s major product branches. Several controllers and page implementations were not sampled, so some documented feature links are intentionally shown only at the client/API boundary.

Main entry points: [`client/src/App.tsx`](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/App.tsx) (App routes), [`server/src/app.ts`](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/app.ts) (Express app), [`server/src/controllers/checkin.controller.ts`](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/checkin.controller.ts) (Check-in workflow), [`server/src/services/gamification.service.ts`](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/services/gamification.service.ts) (XP and badges)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App routes<br/>[App.tsx]"]
  node_auth["Auth context<br/>[AuthContext.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_habit_wizard["Habit wizard"]
  node_home["Habit dashboard<br/>[HomePage.tsx]"]
  node_habit_detail["Habit detail"]
  node_todos_ui["Task manager<br/>[TodoPage.tsx]"]
  node_stats_ui["Analytics view<br/>[StatsPage.tsx]"]
  node_zen_ui["Focus timer<br/>[ZenModePage.tsx]"]
  node_profile_ui["Profile<br/>[ProfilePage.tsx]"]
  node_settings_ui["Settings<br/>[SettingsPage.tsx]"]
  node_login_ui["Login and register<br/>[LoginPage.tsx]"]
  node_habit_api["Habit API<br/>[habits.ts]"]
  node_todo_api["Task API<br/>[todos.ts]"]
  node_stats_api["Stats API<br/>[stats.ts]"]
  node_zen_api["Focus API<br/>[zen.ts]"]
end

subgraph group_api["API and domain"]
  node_server["Express app<br/>[app.ts]"]
  node_auth_controller["Authentication<br/>[auth.controller.ts]"]
  node_habit_controller["Habit management"]
  node_checkin_controller["Check-in workflow"]
  node_gamification["XP and badges"]
  node_day_schedule["Date scheduling"]
  node_todo_controller["Task management<br/>[todo.controller.ts]"]
  node_stats_controller["Analytics"]
  node_zen_controller["Focus sessions<br/>[zen.controller.ts]"]
  node_user_controller["User settings<br/>[user.controller.ts]"]
  node_auth_middleware["Request authentication<br/>[auth.ts]"]
end

subgraph group_data["Persistent records"]
  node_db[("MongoDB<br/>[db.ts]")]
  node_users[("User records<br/>[User.ts]")]
  node_habits[("Habit records<br/>[Habit.ts]")]
  node_checkins[("Check-in records<br/>[CheckIn.ts]")]
  node_todos[("Task records<br/>[Todo.ts]")]
  node_badges[("Badge records<br/>[Badge.ts]")]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"checks session"| node_auth
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_habit_wizard
node_app -->|"routes to"| node_habit_detail
node_app -->|"routes to"| node_todos_ui
node_app -->|"routes to"| node_stats_ui
node_app -->|"routes to"| node_zen_ui
node_app -->|"routes to"| node_profile_ui
node_app -->|"routes to"| node_settings_ui
node_app -->|"routes to"| node_login_ui
node_auth -->|"calls"| node_api_client
node_login_ui -.->|"authenticates via"| node_auth
node_habit_wizard -.->|"submits habit"| node_habit_api
node_home -.->|"loads habits"| node_habit_api
node_habit_detail -.->|"loads detail"| node_habit_api
node_todos_ui -.->|"manages tasks"| node_todo_api
node_stats_ui -.->|"loads analytics"| node_stats_api
node_zen_ui -->|"saves and loads"| node_zen_api
node_profile_ui -.->|"loads profile"| node_api_client
node_settings_ui -.->|"updates preferences"| node_api_client
node_api_client -->|"HTTP requests"| node_server
node_server -->|"mounts auth routes"| node_auth_controller
node_server -->|"mounts habit routes"| node_habit_controller
node_server -->|"mounts check-in routes"| node_checkin_controller
node_server -->|"mounts task routes"| node_todo_controller
node_server -->|"mounts stats routes"| node_stats_controller
node_server -->|"mounts focus routes"| node_zen_controller
node_server -->|"mounts user routes"| node_user_controller
node_habit_controller -->|"protected by"| node_auth_middleware
node_auth_controller -->|"reads and writes"| node_users
node_checkin_controller -->|"reads user"| node_users
node_checkin_controller -->|"reads and updates"| node_habits
node_checkin_controller -->|"creates and queries"| node_checkins
node_checkin_controller -->|"computes date"| node_day_schedule
node_checkin_controller -->|"awards XP and badges"| node_gamification
node_gamification -->|"updates XP"| node_users
node_gamification -->|"checks streaks"| node_habits
node_gamification -->|"counts check-ins"| node_checkins
node_gamification -->|"counts completed"| node_todos
node_gamification -->|"evaluates achievements"| node_badges
node_server -->|"connects on startup"| node_db
node_db -.->|"persists models"| node_users
node_db -.->|"persists models"| node_habits
node_db -.->|"persists models"| node_checkins
node_db -.->|"persists models"| node_todos
node_db -.->|"persists models"| node_badges

click node_app "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/App.tsx"
click node_auth "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/context/AuthContext.tsx"
click node_api_client "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/client.ts"
click node_habit_wizard "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HabitWizardPage.tsx"
click node_home "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HomePage.tsx"
click node_habit_detail "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HabitDetailPage.tsx"
click node_todos_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/TodoPage.tsx"
click node_stats_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/StatsPage.tsx"
click node_zen_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/ZenModePage.tsx"
click node_profile_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/ProfilePage.tsx"
click node_settings_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/SettingsPage.tsx"
click node_login_ui "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/LoginPage.tsx"
click node_habit_api "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/habits.ts"
click node_todo_api "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/todos.ts"
click node_stats_api "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/stats.ts"
click node_zen_api "https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/zen.ts"
click node_server "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/app.ts"
click node_auth_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/auth.controller.ts"
click node_habit_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/habit.controller.ts"
click node_checkin_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/checkin.controller.ts"
click node_gamification "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/services/gamification.service.ts"
click node_day_schedule "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/services/dayBoundary.service.ts"
click node_todo_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/todo.controller.ts"
click node_stats_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/stats.controller.ts"
click node_zen_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/zen.controller.ts"
click node_user_controller "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/user.controller.ts"
click node_auth_middleware "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/middleware/auth.ts"
click node_db "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/config/db.ts"
click node_users "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/User.ts"
click node_habits "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Habit.ts"
click node_checkins "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/CheckIn.ts"
click node_todos "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Todo.ts"
click node_badges "https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Badge.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_app,node_auth,node_api_client,node_habit_wizard,node_home,node_habit_detail,node_todos_ui,node_stats_ui,node_zen_ui,node_profile_ui,node_settings_ui,node_login_ui,node_habit_api,node_todo_api,node_stats_api,node_zen_api,node_user toneBlue
class node_server,node_auth_controller,node_habit_controller,node_checkin_controller,node_gamification,node_day_schedule,node_todo_controller,node_stats_controller,node_zen_controller,node_user_controller,node_auth_middleware toneAmber
class node_db,node_users,node_habits,node_checkins,node_todos,node_badges toneMint
```

## Components

### React client

- [App routes](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Auth context](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/context/AuthContext.tsx): `client/src/context/AuthContext.tsx`
- [API client](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/client.ts): `client/src/api/client.ts`
- [Habit wizard](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HabitWizardPage.tsx): `client/src/pages/HabitWizardPage.tsx`
- [Habit dashboard](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HomePage.tsx): `client/src/pages/HomePage.tsx`
- [Habit detail](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/HabitDetailPage.tsx): `client/src/pages/HabitDetailPage.tsx`
- [Task manager](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/TodoPage.tsx): `client/src/pages/TodoPage.tsx`
- [Analytics view](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/StatsPage.tsx): `client/src/pages/StatsPage.tsx`
- [Focus timer](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/ZenModePage.tsx): `client/src/pages/ZenModePage.tsx`
- [Profile](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/ProfilePage.tsx): `client/src/pages/ProfilePage.tsx`
- [Settings](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/SettingsPage.tsx): `client/src/pages/SettingsPage.tsx`
- [Login and register](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/pages/LoginPage.tsx): `client/src/pages/LoginPage.tsx`
- [Habit API](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/habits.ts): `client/src/api/habits.ts`
- [Task API](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/todos.ts): `client/src/api/todos.ts`
- [Stats API](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/stats.ts): `client/src/api/stats.ts`
- [Focus API](https://github.com/chaitanya-361/velvet-streak/blob/main/client/src/api/zen.ts): `client/src/api/zen.ts`

### API and domain

- [Express app](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/auth.controller.ts): `server/src/controllers/auth.controller.ts`
- [Habit management](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/habit.controller.ts): `server/src/controllers/habit.controller.ts`
- [Check-in workflow](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/checkin.controller.ts): `server/src/controllers/checkin.controller.ts`
- [XP and badges](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/services/gamification.service.ts): `server/src/services/gamification.service.ts`
- [Date scheduling](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/services/dayBoundary.service.ts): `server/src/services/dayBoundary.service.ts`
- [Task management](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/todo.controller.ts): `server/src/controllers/todo.controller.ts`
- [Analytics](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/stats.controller.ts): `server/src/controllers/stats.controller.ts`
- [Focus sessions](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/zen.controller.ts): `server/src/controllers/zen.controller.ts`
- [User settings](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/controllers/user.controller.ts): `server/src/controllers/user.controller.ts`
- [Request authentication](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`

### Persistent records

- [MongoDB](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/config/db.ts): `server/src/config/db.ts`
- [User records](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/User.ts): `server/src/models/User.ts`
- [Habit records](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Habit.ts): `server/src/models/Habit.ts`
- [Check-in records](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/CheckIn.ts): `server/src/models/CheckIn.ts`
- [Task records](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Todo.ts): `server/src/models/Todo.ts`
- [Badge records](https://github.com/chaitanya-361/velvet-streak/blob/main/server/src/models/Badge.ts): `server/src/models/Badge.ts`

### Other components

- **User**

## Connections

- User → App routes: uses
- App routes → Auth context: checks session (evidence: `client/src/App.tsx`)
- App routes → Habit dashboard: routes to (evidence: `client/src/App.tsx`)
- App routes → Habit wizard: routes to (evidence: `client/src/App.tsx`)
- App routes → Habit detail: routes to (evidence: `client/src/App.tsx`)
- App routes → Task manager: routes to (evidence: `client/src/App.tsx`)
- App routes → Analytics view: routes to (evidence: `client/src/App.tsx`)
- App routes → Focus timer: routes to (evidence: `client/src/App.tsx`)
- App routes → Profile: routes to (evidence: `client/src/App.tsx`)
- App routes → Settings: routes to (evidence: `client/src/App.tsx`)
- App routes → Login and register: routes to (evidence: `client/src/App.tsx`)
- Auth context → API client: calls (evidence: `client/src/context/AuthContext.tsx`)
- Login and register → Auth context: authenticates via
- Habit wizard → Habit API: submits habit
- Habit dashboard → Habit API: loads habits
- Habit detail → Habit API: loads detail
- Task manager → Task API: manages tasks
- Analytics view → Stats API: loads analytics
- Focus timer → Focus API: saves and loads (evidence: `client/src/pages/ZenModePage.tsx`)
- Profile → API client: loads profile
- Settings → API client: updates preferences
- API client → Express app: HTTP requests
- Express app → Authentication: mounts auth routes (evidence: `server/src/app.ts`)
- Express app → Habit management: mounts habit routes (evidence: `server/src/app.ts`)
- Express app → Check-in workflow: mounts check-in routes (evidence: `server/src/app.ts`)
- Express app → Task management: mounts task routes (evidence: `server/src/app.ts`)
- Express app → Analytics: mounts stats routes (evidence: `server/src/app.ts`)
- Express app → Focus sessions: mounts focus routes (evidence: `server/src/app.ts`)
- Express app → User settings: mounts user routes (evidence: `server/src/app.ts`)
- Habit management → Request authentication: protected by (evidence: `server/src/routes/habit.routes.ts`)
- Authentication → User records: reads and writes (evidence: `server/src/controllers/auth.controller.ts`)
- Check-in workflow → User records: reads user (evidence: `server/src/controllers/checkin.controller.ts`)
- Check-in workflow → Habit records: reads and updates (evidence: `server/src/controllers/checkin.controller.ts`)
- Check-in workflow → Check-in records: creates and queries (evidence: `server/src/controllers/checkin.controller.ts`)
- Check-in workflow → Date scheduling: computes date (evidence: `server/src/controllers/checkin.controller.ts`)
- Check-in workflow → XP and badges: awards XP and badges (evidence: `server/src/controllers/checkin.controller.ts`)
- XP and badges → User records: updates XP (evidence: `server/src/services/gamification.service.ts`)
- XP and badges → Habit records: checks streaks (evidence: `server/src/services/gamification.service.ts`)
- XP and badges → Check-in records: counts check-ins (evidence: `server/src/services/gamification.service.ts`)
- XP and badges → Task records: counts completed (evidence: `server/src/services/gamification.service.ts`)
- XP and badges → Badge records: evaluates achievements (evidence: `server/src/services/gamification.service.ts`)
- Express app → MongoDB: connects on startup (evidence: `server/src/server.ts`)
- MongoDB → User records: persists models
- MongoDB → Habit records: persists models
- MongoDB → Check-in records: persists models
- MongoDB → Task records: persists models
- MongoDB → Badge records: persists models
