# lahlan-h/stdyapp architecture

> Architecture diagram of the GitHub repository lahlan-h/stdyapp, 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/lahlan-h/stdyapp
- Repository: https://github.com/lahlan-h/stdyapp

## Overview

stdy is a study-session tracker and social feed: students log study time, track progress, and share activity. The principal workflow runs from mobile session controls through the API’s session service to persistence; session completion also updates streaks and goals. Separate product branches cover groups, posts and social interactions, profiles and authentication, and analytics. The README documents the API’s controller→service→repository layering and core infrastructure. Some capabilities are represented at directory level because their source was not sampled; edges are limited to documented or indexed relationships.

Main entry points: [`apps/api/src/routes`](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/routes) (REST routes), [`apps/api/src/repositories`](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/repositories) (Domain repositories), [`apps/api/src/services/session.service.js`](https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/session.service.js) (Session lifecycle), [`apps/mobile/src/data/api.ts`](https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_session["Session controls<br/>[useFocusSession.ts]"]
  node_mobile_api["API client<br/>[api.ts]"]
  node_mobile_auth["Mobile auth<br/>[auth.ts]"]
  node_mobile_social["Social screens<br/>[index.tsx]"]
end

subgraph group_api["API domain"]
  node_api_routes["REST routes"]
  node_auth_service["Authentication<br/>[auth.service.js]"]
  node_session_service["Session lifecycle<br/>[session.service.js]"]
  node_social_services["Social features"]
  node_progress_services["Progress tracking"]
  node_analytics["Analytics"]
  node_photo_service["Photo storage"]
end

subgraph group_data["Persistence and services"]
  node_repositories["Domain repositories"]
end

subgraph group_platform["Shared infrastructure"]
  node_postgres[("Postgres")]
  node_core["Core clients<br/>[db.js]"]
  node_redis[("Redis cache<br/>[redis.js]")]
  node_rabbitmq["RabbitMQ<br/>[rabbitmq.js]"]
  node_object_storage["R2 storage<br/>[storage.js]"]
end

node_student(("Student"))

node_student -->|"starts study"| node_mobile_session
node_mobile_session -->|"authorizes requests"| node_mobile_auth
node_mobile_session -->|"requests sessions"| node_mobile_api
node_mobile_api -->|"sends requests"| node_api_routes
node_mobile_auth -->|"calls API"| node_mobile_api
node_api_routes -.->|"routes auth"| node_auth_service
node_api_routes -.->|"routes sessions"| node_session_service
node_api_routes -.->|"routes social features"| node_social_services
node_api_routes -.->|"routes analytics"| node_analytics
node_auth_service -->|"uses user service"| node_social_services
node_session_service -->|"reads and writes"| node_repositories
node_session_service -->|"records study progress"| node_progress_services
node_session_service -->|"notifies and posts"| node_social_services
node_progress_services -.->|"persists progress"| node_repositories
node_social_services -.->|"persists social data"| node_repositories
node_analytics -.->|"reads activity"| node_repositories
node_repositories -->|"uses Prisma client"| node_core
node_core -.->|"connects"| node_postgres
node_api_routes -->|"caches responses"| node_redis
node_api_routes -.->|"uses messaging"| node_rabbitmq
node_photo_service -->|"uploads and deletes"| node_object_storage
node_student -->|"browses and shares"| node_mobile_social
node_mobile_social -.->|"loads app data"| node_mobile_api

click node_mobile_session "https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/useFocusSession.ts"
click node_mobile_api "https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/api.ts"
click node_mobile_auth "https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/auth.ts"
click node_mobile_social "https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/app/(tabs)/index.tsx"
click node_api_routes "https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/routes"
click node_auth_service "https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/auth.service.js"
click node_session_service "https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/session.service.js"
click node_social_services "https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/services"
click node_progress_services "https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/services"
click node_analytics "https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/analytics.service.js"
click node_repositories "https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/repositories"
click node_core "https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/db.js"
click node_redis "https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/redis.js"
click node_rabbitmq "https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/rabbitmq.js"
click node_object_storage "https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/storage.js"
click node_photo_service "https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/photoStorage.service.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_mobile_session,node_mobile_api,node_mobile_auth,node_mobile_social toneBlue
class node_api_routes,node_auth_service,node_session_service,node_social_services,node_progress_services,node_analytics,node_photo_service toneAmber
class node_repositories toneMint
class node_postgres,node_core,node_redis,node_rabbitmq,node_object_storage toneRose
class node_student toneIndigo
```

## Components

### Mobile app

- [Session controls](https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/useFocusSession.ts): `apps/mobile/src/data/useFocusSession.ts`
- [API client](https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/api.ts): `apps/mobile/src/data/api.ts`
- [Mobile auth](https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/src/data/auth.ts): `apps/mobile/src/data/auth.ts`
- [Social screens](https://github.com/lahlan-h/stdyapp/blob/main/apps/mobile/app/(tabs)/index.tsx): `apps/mobile/app/(tabs)/index.tsx`

### API domain

- [REST routes](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/routes): `apps/api/src/routes`
- [Authentication](https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/auth.service.js): `apps/api/src/services/auth.service.js`
- [Session lifecycle](https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/session.service.js): `apps/api/src/services/session.service.js`
- [Social features](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/services): `apps/api/src/services`
- [Progress tracking](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/services): `apps/api/src/services`
- [Analytics](https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/analytics.service.js): `apps/api/src/services/analytics.service.js`
- [Photo storage](https://github.com/lahlan-h/stdyapp/blob/main/apps/api/src/services/photoStorage.service.js): `apps/api/src/services/photoStorage.service.js`

### Persistence and services

- [Domain repositories](https://github.com/lahlan-h/stdyapp/tree/main/apps/api/src/repositories): `apps/api/src/repositories`

### Shared infrastructure

- **Postgres**
- [Core clients](https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/db.js): `packages/core/src/db.js`
- [Redis cache](https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/redis.js): `packages/core/src/redis.js`
- [RabbitMQ](https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/rabbitmq.js): `packages/core/src/rabbitmq.js`
- [R2 storage](https://github.com/lahlan-h/stdyapp/blob/main/packages/core/src/storage.js): `packages/core/src/storage.js`

### Other components

- **Student**

## Connections

- Student → Session controls: starts study (evidence: `README.md`)
- Session controls → Mobile auth: authorizes requests (evidence: `apps/mobile/src/data/useFocusSession.ts`)
- Session controls → API client: requests sessions (evidence: `apps/mobile/src/data/useFocusSession.ts`)
- API client → REST routes: sends requests (evidence: `README.md`)
- Mobile auth → API client: calls API (evidence: `apps/mobile/src/data/auth.ts`)
- REST routes → Authentication: routes auth
- REST routes → Session lifecycle: routes sessions
- REST routes → Social features: routes social features
- REST routes → Analytics: routes analytics
- Authentication → Social features: uses user service (evidence: `apps/api/src/services/auth.service.js`)
- Session lifecycle → Domain repositories: reads and writes (evidence: `apps/api/src/services/session.service.js`)
- Session lifecycle → Progress tracking: records study progress (evidence: `apps/api/src/services/session.service.js`)
- Session lifecycle → Social features: notifies and posts (evidence: `apps/api/src/services/session.service.js`)
- Progress tracking → Domain repositories: persists progress (evidence: `apps/api/src/services/session.service.js`)
- Social features → Domain repositories: persists social data (evidence: `apps/api/src/services/session.service.js`)
- Analytics → Domain repositories: reads activity
- Domain repositories → Core clients: uses Prisma client (evidence: `apps/api/src/repositories/session.repository.js`)
- Core clients → Postgres: connects
- REST routes → Redis cache: caches responses (evidence: `README.md`)
- REST routes → RabbitMQ: uses messaging
- Photo storage → R2 storage: uploads and deletes (evidence: `apps/api/src/services/photoStorage.service.js`)
- Student → Social screens: browses and shares (evidence: `README.md`)
- Social screens → API client: loads app data
