# fga0138-mds-ajax/2026.2-t02-shannon architecture

> Architecture diagram of the GitHub repository fga0138-mds-ajax/2026.2-t02-shannon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fga0138-mds-ajax/2026.2-t02-shannon
- Repository: https://github.com/fga0138-mds-ajax/2026.2-t02-shannon

## Overview

Habbit is a habit-management product with a mobile app and API. The main workflow is account authentication, habit creation and goal setting, then recording check-ins and viewing progress or history. The API also supports habit visibility and lifecycle changes, check-in editing, and session refresh/logout. The excerpts show API routes, domain services, and persistence; mobile-to-API wiring and some listed subsystems were not sampled, so those links are omitted or marked unverified.

Main entry points: [`apps/api/app/main.py`](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/main.py) (API application), [`apps/api/app/habits/service.py`](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/service.py) (Habit service), [`apps/api/app/auth/service.py`](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/service.py) (Auth service), [`apps/api/app/goals/service.py`](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/service.py) (Goal service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_screens["App screens"]
  node_mobile_auth["Auth screens"]
  node_mobile_context["Auth context<br/>[auth-context.tsx]"]
  node_mobile_api["API clients<br/>[api.ts]"]
end

subgraph group_identity["Identity and sessions"]
  node_auth_routes["Auth routes<br/>[router.py]"]
  node_auth_service["Auth service<br/>[service.py]"]
  node_auth_sessions["Session service<br/>[service.py]"]
  node_auth_tokens["Token handling<br/>[tokens.py]"]
  node_auth_dependencies["Auth dependencies<br/>[dependencies.py]"]
end

subgraph group_habits["Habit management"]
  node_habit_routes["Habit routes<br/>[router.py]"]
  node_habit_service["Habit service<br/>[service.py]"]
  node_habit_repository["Habit repository<br/>[repository.py]"]
end

subgraph group_tracking["Goals and check-ins"]
  node_goal_routes["Goal routes<br/>[router.py]"]
  node_goal_service["Goal service<br/>[service.py]"]
  node_goal_streak["Progress calculation<br/>[streak.py]"]
  node_checkin_routes["Check-in routes<br/>[router.py]"]
  node_checkin_service["Check-in service<br/>[service.py]"]
  node_checkin_repository["Check-in repository<br/>[repository.py]"]
end

subgraph group_persistence["Persistence"]
  node_database[("Database session<br/>[database.py]")]
end

node_user(("User"))
node_api_entry["API application<br/>[main.py]"]

node_user -->|"signs in"| node_mobile_auth
node_user -->|"manages habits"| node_mobile_screens
node_mobile_auth -.->|"uses"| node_mobile_context
node_mobile_screens -.->|"requests data"| node_mobile_api
node_mobile_api -.->|"calls API"| node_api_entry
node_api_entry -->|"registers"| node_auth_routes
node_api_entry -->|"registers"| node_habit_routes
node_api_entry -->|"registers"| node_goal_routes
node_api_entry -->|"registers"| node_checkin_routes
node_auth_routes -->|"delegates to"| node_auth_service
node_auth_service -->|"starts session"| node_auth_sessions
node_auth_service -->|"decodes tokens"| node_auth_tokens
node_auth_dependencies -->|"validates tokens"| node_auth_tokens
node_habit_routes -->|"delegates to"| node_habit_service
node_habit_service -->|"persists habits"| node_habit_repository
node_goal_routes -->|"delegates to"| node_goal_service
node_goal_service -->|"checks ownership"| node_habit_service
node_goal_service -->|"calculates progress"| node_goal_streak
node_checkin_routes -->|"delegates to"| node_checkin_service
node_checkin_service -->|"persists check-ins"| node_checkin_repository
node_checkin_service -->|"checks eligible habits"| node_habit_service
node_database -.->|"provides sessions"| node_auth_routes

click node_mobile_screens "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/tree/main/apps/mobile/src/app/(app)"
click node_mobile_auth "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/tree/main/apps/mobile/src/app/(auth)"
click node_mobile_context "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/mobile/src/contexts/auth-context.tsx"
click node_mobile_api "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/mobile/src/services/api.ts"
click node_api_entry "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/main.py"
click node_auth_routes "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/router.py"
click node_auth_service "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/service.py"
click node_auth_sessions "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/session/service.py"
click node_auth_tokens "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/tokens.py"
click node_auth_dependencies "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/dependencies.py"
click node_habit_routes "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/router.py"
click node_habit_service "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/service.py"
click node_habit_repository "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/repository.py"
click node_goal_routes "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/router.py"
click node_goal_service "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/service.py"
click node_goal_streak "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/streak.py"
click node_checkin_routes "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/router.py"
click node_checkin_service "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/service.py"
click node_checkin_repository "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/repository.py"
click node_database "https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/database.py"

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_mobile_screens,node_mobile_auth,node_mobile_context,node_mobile_api,node_user toneBlue
class node_auth_routes,node_auth_service,node_auth_sessions,node_auth_tokens,node_auth_dependencies toneAmber
class node_habit_routes,node_habit_service,node_habit_repository,node_api_entry toneMint
class node_goal_routes,node_goal_service,node_goal_streak,node_checkin_routes,node_checkin_service,node_checkin_repository toneRose
class node_database toneIndigo
```

## Components

### Mobile app

- [App screens](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/tree/main/apps/mobile/src/app/(app)): `apps/mobile/src/app/(app)`
- [Auth screens](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/tree/main/apps/mobile/src/app/(auth)): `apps/mobile/src/app/(auth)`
- [Auth context](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/mobile/src/contexts/auth-context.tsx): `apps/mobile/src/contexts/auth-context.tsx`
- [API clients](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/mobile/src/services/api.ts): `apps/mobile/src/services/api.ts`

### Identity and sessions

- [Auth routes](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/router.py): `apps/api/app/auth/router.py`
- [Auth service](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/service.py): `apps/api/app/auth/service.py`
- [Session service](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/session/service.py): `apps/api/app/auth/session/service.py`
- [Token handling](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/tokens.py): `apps/api/app/auth/tokens.py`
- [Auth dependencies](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/auth/dependencies.py): `apps/api/app/auth/dependencies.py`

### Habit management

- [Habit routes](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/router.py): `apps/api/app/habits/router.py`
- [Habit service](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/service.py): `apps/api/app/habits/service.py`
- [Habit repository](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/habits/repository.py): `apps/api/app/habits/repository.py`

### Goals and check-ins

- [Goal routes](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/router.py): `apps/api/app/goals/router.py`
- [Goal service](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/service.py): `apps/api/app/goals/service.py`
- [Progress calculation](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/goals/streak.py): `apps/api/app/goals/streak.py`
- [Check-in routes](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/router.py): `apps/api/app/checkins/router.py`
- [Check-in service](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/service.py): `apps/api/app/checkins/service.py`
- [Check-in repository](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/checkins/repository.py): `apps/api/app/checkins/repository.py`

### Persistence

- [Database session](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/database.py): `apps/api/app/database.py`

### Other components

- **User**
- [API application](https://github.com/fga0138-mds-ajax/2026.2-t02-shannon/blob/main/apps/api/app/main.py): `apps/api/app/main.py`

## Connections

- User → Auth screens: signs in
- User → App screens: manages habits
- Auth screens → Auth context: uses
- App screens → API clients: requests data
- API clients → API application: calls API
- API application → Auth routes: registers (evidence: `apps/api/app/main.py`)
- API application → Habit routes: registers (evidence: `apps/api/app/main.py`)
- API application → Goal routes: registers (evidence: `apps/api/app/main.py`)
- API application → Check-in routes: registers (evidence: `apps/api/app/main.py`)
- Auth routes → Auth service: delegates to (evidence: `apps/api/app/auth/router.py`)
- Auth service → Session service: starts session (evidence: `apps/api/app/auth/service.py`)
- Auth service → Token handling: decodes tokens (evidence: `apps/api/app/auth/service.py`)
- Auth dependencies → Token handling: validates tokens (evidence: `apps/api/app/auth/dependencies.py`)
- Habit routes → Habit service: delegates to (evidence: `apps/api/app/habits/router.py`)
- Habit service → Habit repository: persists habits (evidence: `apps/api/app/habits/service.py`)
- Goal routes → Goal service: delegates to (evidence: `apps/api/app/goals/router.py`)
- Goal service → Habit service: checks ownership (evidence: `apps/api/app/goals/service.py`)
- Goal service → Progress calculation: calculates progress (evidence: `apps/api/app/goals/service.py`)
- Check-in routes → Check-in service: delegates to (evidence: `apps/api/app/checkins/router.py`)
- Check-in service → Check-in repository: persists check-ins (evidence: `apps/api/app/checkins/service.py`)
- Check-in service → Habit service: checks eligible habits (evidence: `apps/api/app/checkins/service.py`)
- Database session → Auth routes: provides sessions (evidence: `apps/api/app/auth/router.py`)
