# crypto2468/orbit architecture

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

- Interactive diagram: https://gitdiagram.com/crypto2468/orbit
- Repository: https://github.com/crypto2468/orbit

## Overview

Orbit is a full-stack habit tracker: users register, create habits, record completions, and review progress; AI features use habit and log data to produce coaching, recovery plans, and reports. The graph follows the sampled React routing/authentication and backend controller/service code. Several feature pages and route modules are represented from their tree paths and documented capabilities, but their detailed wiring was not sampled, so uncertain links are omitted.

Main entry points: [`frontend/app/src/App.jsx`](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/App.jsx) (App routes), [`backend/server.js`](https://github.com/crypto2468/orbit/blob/main/backend/server.js) (API server), [`backend/controllers/aiController.js`](https://github.com/crypto2468/orbit/blob/main/backend/controllers/aiController.js) (Coaching context), [`backend/controllers/habitController.js`](https://github.com/crypto2468/orbit/blob/main/backend/controllers/habitController.js) (Habit operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Habit-tracking interface"]
  node_app["App routes<br/>[App.jsx]"]
  node_api["HTTP client<br/>[axios.js]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_habit_page["Habit manager<br/>[Habits.jsx]"]
  node_weekly_page["Weekly view<br/>[Weekly.jsx]"]
  node_insights_page["Insights view<br/>[Insights.jsx]"]
  node_stats_page["Statistics<br/>[Stats.jsx]"]
end

subgraph group_identity["Account access"]
  node_auth_context["Auth state<br/>[AuthContext.jsx]"]
  node_auth_routes["Auth endpoints<br/>[auth.js]"]
  node_auth_controller["Account operations<br/>[authController.js]"]
  node_auth_middleware["Request protection<br/>[auth.js]"]
end

subgraph group_tracking["Habit and progress"]
  node_habit_routes["Habit endpoints<br/>[habits.js]"]
  node_habit_controller["Habit operations<br/>[habitController.js]"]
  node_log_routes["Completion endpoints<br/>[logs.js]"]
  node_log_controller["Completion and stats<br/>[logController.js]"]
end

subgraph group_coaching["AI coaching"]
  node_ai_routes["Coaching endpoints<br/>[ai.js]"]
  node_ai_controller["Coaching context<br/>[aiController.js]"]
  node_ai_service["AI service<br/>[aiService.js]"]
end

subgraph group_data["Persistence"]
  node_habit_model["Habit records<br/>[Habit.js]"]
  node_log_model["Completion records<br/>[HabitLog.js]"]
  node_user_model["User records<br/>[User.js]"]
  node_insight_model["Coaching records<br/>[AIinsight.js]"]
  node_server["API server<br/>[server.js]"]
  node_database_config["Database connector<br/>[db.js]"]
end

node_user(("User"))
node_mongo[("MongoDB")]
node_gemini{{"Gemini API"}}

node_user -->|"uses"| node_app
node_app -->|"routes"| node_dashboard
node_app -->|"routes"| node_habit_page
node_app -->|"routes"| node_weekly_page
node_app -->|"routes"| node_insights_page
node_app -->|"routes"| node_stats_page
node_auth_context -->|"requests"| node_api
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects"| node_auth_middleware
node_auth_controller -->|"reads/writes"| node_user_model
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_habit_routes
node_server -->|"mounts"| node_log_routes
node_server -->|"mounts"| node_ai_routes
node_server -->|"connects"| node_database_config
node_database_config -->|"connects"| node_mongo
node_habit_routes -->|"dispatches"| node_habit_controller
node_habit_controller -->|"reads/writes"| node_habit_model
node_habit_controller -->|"deletes"| node_log_model
node_log_routes -->|"dispatches"| node_log_controller
node_log_controller -->|"reads"| node_habit_model
node_log_controller -->|"reads/writes"| node_log_model
node_ai_routes -->|"dispatches"| node_ai_controller
node_ai_controller -->|"reads"| node_habit_model
node_ai_controller -->|"reads"| node_log_model
node_ai_controller -->|"requests completions"| node_ai_service
node_ai_controller -->|"writes insights"| node_insight_model
node_ai_service -.->|"generates content"| node_gemini

click node_app "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/App.jsx"
click node_auth_context "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/context/AuthContext.jsx"
click node_api "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/api/axios.js"
click node_dashboard "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Dashboard.jsx"
click node_habit_page "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Habits.jsx"
click node_weekly_page "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Weekly.jsx"
click node_insights_page "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Insights.jsx"
click node_stats_page "https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Stats.jsx"
click node_auth_routes "https://github.com/crypto2468/orbit/blob/main/backend/routes/auth.js"
click node_auth_controller "https://github.com/crypto2468/orbit/blob/main/backend/controllers/authController.js"
click node_auth_middleware "https://github.com/crypto2468/orbit/blob/main/backend/middleware/auth.js"
click node_habit_routes "https://github.com/crypto2468/orbit/blob/main/backend/routes/habits.js"
click node_habit_controller "https://github.com/crypto2468/orbit/blob/main/backend/controllers/habitController.js"
click node_log_routes "https://github.com/crypto2468/orbit/blob/main/backend/routes/logs.js"
click node_log_controller "https://github.com/crypto2468/orbit/blob/main/backend/controllers/logController.js"
click node_ai_routes "https://github.com/crypto2468/orbit/blob/main/backend/routes/ai.js"
click node_ai_controller "https://github.com/crypto2468/orbit/blob/main/backend/controllers/aiController.js"
click node_ai_service "https://github.com/crypto2468/orbit/blob/main/backend/utils/aiService.js"
click node_habit_model "https://github.com/crypto2468/orbit/blob/main/backend/models/Habit.js"
click node_log_model "https://github.com/crypto2468/orbit/blob/main/backend/models/HabitLog.js"
click node_user_model "https://github.com/crypto2468/orbit/blob/main/backend/models/User.js"
click node_insight_model "https://github.com/crypto2468/orbit/blob/main/backend/models/AIinsight.js"
click node_server "https://github.com/crypto2468/orbit/blob/main/backend/server.js"
click node_database_config "https://github.com/crypto2468/orbit/blob/main/backend/config/db.js"

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_api,node_dashboard,node_habit_page,node_weekly_page,node_insights_page,node_stats_page,node_user toneBlue
class node_auth_context,node_auth_routes,node_auth_controller,node_auth_middleware,node_mongo toneAmber
class node_habit_routes,node_habit_controller,node_log_routes,node_log_controller,node_gemini toneMint
class node_ai_routes,node_ai_controller,node_ai_service toneRose
class node_habit_model,node_log_model,node_user_model,node_insight_model,node_server,node_database_config toneIndigo
```

## Components

### Habit-tracking interface

- [App routes](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/App.jsx): `frontend/app/src/App.jsx`
- [HTTP client](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/api/axios.js): `frontend/app/src/api/axios.js`
- [Dashboard](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Dashboard.jsx): `frontend/app/src/pages/Dashboard.jsx`
- [Habit manager](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Habits.jsx): `frontend/app/src/pages/Habits.jsx`
- [Weekly view](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Weekly.jsx): `frontend/app/src/pages/Weekly.jsx`
- [Insights view](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Insights.jsx): `frontend/app/src/pages/Insights.jsx`
- [Statistics](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/pages/Stats.jsx): `frontend/app/src/pages/Stats.jsx`

### Account access

- [Auth state](https://github.com/crypto2468/orbit/blob/main/frontend/app/src/context/AuthContext.jsx): `frontend/app/src/context/AuthContext.jsx`
- [Auth endpoints](https://github.com/crypto2468/orbit/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Account operations](https://github.com/crypto2468/orbit/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Request protection](https://github.com/crypto2468/orbit/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### Habit and progress

- [Habit endpoints](https://github.com/crypto2468/orbit/blob/main/backend/routes/habits.js): `backend/routes/habits.js`
- [Habit operations](https://github.com/crypto2468/orbit/blob/main/backend/controllers/habitController.js): `backend/controllers/habitController.js`
- [Completion endpoints](https://github.com/crypto2468/orbit/blob/main/backend/routes/logs.js): `backend/routes/logs.js`
- [Completion and stats](https://github.com/crypto2468/orbit/blob/main/backend/controllers/logController.js): `backend/controllers/logController.js`

### AI coaching

- [Coaching endpoints](https://github.com/crypto2468/orbit/blob/main/backend/routes/ai.js): `backend/routes/ai.js`
- [Coaching context](https://github.com/crypto2468/orbit/blob/main/backend/controllers/aiController.js): `backend/controllers/aiController.js`
- [AI service](https://github.com/crypto2468/orbit/blob/main/backend/utils/aiService.js): `backend/utils/aiService.js`

### Persistence

- [Habit records](https://github.com/crypto2468/orbit/blob/main/backend/models/Habit.js): `backend/models/Habit.js`
- [Completion records](https://github.com/crypto2468/orbit/blob/main/backend/models/HabitLog.js): `backend/models/HabitLog.js`
- [User records](https://github.com/crypto2468/orbit/blob/main/backend/models/User.js): `backend/models/User.js`
- [Coaching records](https://github.com/crypto2468/orbit/blob/main/backend/models/AIinsight.js): `backend/models/AIinsight.js`
- [API server](https://github.com/crypto2468/orbit/blob/main/backend/server.js): `backend/server.js`
- [Database connector](https://github.com/crypto2468/orbit/blob/main/backend/config/db.js): `backend/config/db.js`

### Other components

- **User**
- **MongoDB**
- **Gemini API**

## Connections

- User → App routes: uses
- App routes → Dashboard: routes
- App routes → Habit manager: routes
- App routes → Weekly view: routes
- App routes → Insights view: routes
- App routes → Statistics: routes
- Auth state → HTTP client: requests
- Auth endpoints → Account operations: dispatches
- Auth endpoints → Request protection: protects
- Account operations → User records: reads/writes
- API server → Auth endpoints: mounts
- API server → Habit endpoints: mounts
- API server → Completion endpoints: mounts
- API server → Coaching endpoints: mounts
- API server → Database connector: connects
- Database connector → MongoDB: connects
- Habit endpoints → Habit operations: dispatches
- Habit operations → Habit records: reads/writes
- Habit operations → Completion records: deletes
- Completion endpoints → Completion and stats: dispatches
- Completion and stats → Habit records: reads
- Completion and stats → Completion records: reads/writes
- Coaching endpoints → Coaching context: dispatches
- Coaching context → Habit records: reads
- Coaching context → Completion records: reads
- Coaching context → AI service: requests completions
- Coaching context → Coaching records: writes insights
- AI service → Gemini API: generates content
