# shubhashish-chakraborty/lastglance architecture

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

- Interactive diagram: https://gitdiagram.com/shubhashish-chakraborty/lastglance
- Repository: https://github.com/shubhashish-chakraborty/lastglance

## Overview

#### Purpose and Runtime
LastGlance is an Expo/React Native mobile study-revision client. It organizes exam notes by subject and connects to a separate backend for authentication, note/subject data, media storage, and service wake-up. The app runs through Expo during development and uses EAS for Android builds.

Key manifests: `package.json`, `app.json`, `eas.json`.

#### Application Entry and Navigation
Expo Router provides file-based routing. The root layout establishes global navigation, while the index route selects the initial experience. Route groups separate unauthenticated and authenticated application areas.

Paths: `src/app/_layout.tsx`, `src/app/index.tsx`, `src/app/(auth)/_layout.tsx`.

#### Authentication Boundary
Authentication screens live in a dedicated route group. Auth state is centralized in a store, exposed through a hook, and backed by secure device token storage. This boundary determines whether users access login/register flows or protected study content.

Paths: `src/app/(auth)/login.tsx`, `src/app/(auth)/register.tsx`, `src/store/authStore.ts`, `src/hooks/useAuth.ts`.

#### Authenticated Study Experience
The protected route group contains the main revision UI: home, profile, about, and parameterized subject views. Subject IDs in the route map UI state to backend subject/note resources; the subject screen is the primary detail boundary for subject-specific material.

Paths: `src/app/(app)/_layout.tsx`, `src/app/(app)/home.tsx`, `src/app/(app)/subject/[id].tsx`.

#### API and Service Layer
Network access is isolated from screens in services. `api.ts` is the shared HTTP-client boundary, while auth and wake-up services represent explicit backend interactions. The API base URL is externally configurable in source for local device-to-server connectivity.

Paths: `src/constants/api.ts`, `src/services/api.ts`, `src/services/authService.ts`, `src/services/wakeupService.ts`.

#### Backend and External Dependencies
The mobile app depends on the separate LastGlance backend repository, expected to provide JWT-based APIs, a PostgreSQL-compatible database, and AWS S3-backed media uploads. The app invokes a backend `/wakeup` endpoint to mitigate Render free-tier cold starts. Tokens are stored with `expo-secure-store`; images, screenshots, and other study media are represented remotely rather than by a local backend in this repository.

Relevant integration paths: `src/services/wakeupService.ts`, `src/services/authService.ts`, `src/constants/api.ts`.

#### Primary Control Flow
1. Expo loads `src/app/_layout.tsx` and resolves `src/app/index.tsx`.
2. Auth state/token retrieval directs navigation into `(auth)` or `(app)`.
3. Authenticated screens call domain services through the shared API layer.
4. The API layer targets the configured backend URL; backend responses drive subject and note views.
5. Media-related content is served via backend-managed AWS S3 integration, while auth tokens remain in device secure storage.

Main entry points: [`src/services/api.ts`](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/api.ts) (Shared API client), [`src/app/index.tsx`](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/index.tsx) (Initial route), [`src/app/(auth)/_layout.tsx`](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/_layout.tsx) (Auth route group), [`src/app/(app)/_layout.tsx`](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/_layout.tsx) (Protected route group)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Expo Mobile App"]
  node_expo{{"Expo / EAS runtime<br/>mobile runtime<br/>[package.json]"}}
  node_auth_state[("Auth state<br/>client store<br/>[authStore.ts]")]
  node_use_auth["Auth hook<br/>state access<br/>[useAuth.ts]"]
  node_secure_store[("Secure token storage<br/>device storage")]
end

subgraph group_routes["Router UI"]
  node_root_layout["Root layout<br/>router root<br/>[_layout.tsx]"]
  node_index_route["Initial route<br/>route selector<br/>[index.tsx]"]
  node_auth_routes["Auth route group<br/>unauthenticated UI<br/>[_layout.tsx]"]
  node_login["Login<br/>auth screen<br/>[login.tsx]"]
  node_register["Register<br/>auth screen<br/>[register.tsx]"]
  node_app_routes["Protected route group<br/>authenticated UI<br/>[_layout.tsx]"]
  node_home["Home<br/>study screen<br/>[home.tsx]"]
  node_subject["Subject detail<br/>parameterized study screen<br/>[&#91;id&#93;.tsx]"]
end

subgraph group_services["Client Services"]
  node_api_config["API base URL<br/>endpoint configuration<br/>[api.ts]"]
  node_api_client{{"Shared API client<br/>HTTP boundary<br/>[api.ts]"}}
  node_auth_service["Auth service<br/>auth API service<br/>[authService.ts]"]
  node_wakeup_service["Wake-up service<br/>availability API service<br/>[wakeupService.ts]"]
end

subgraph group_backend["External Backend"]
  node_backend_api{{"LastGlance backend API<br/>JWT API"}}
  node_database[("PostgreSQL-compatible DB<br/>backend database")]
  node_s3[("AWS S3 media storage<br/>object storage")]
end

node_expo -->|"loads"| node_root_layout
node_root_layout -->|"resolves"| node_index_route
node_index_route -->|"checks session"| node_use_auth
node_use_auth -->|"reads"| node_auth_state
node_auth_state -->|"retrieves token"| node_secure_store
node_index_route -->|"unauthenticated"| node_auth_routes
node_index_route -->|"authenticated"| node_app_routes
node_auth_routes -->|"contains"| node_login
node_auth_routes -->|"contains"| node_register
node_app_routes -->|"contains"| node_home
node_app_routes -->|"contains"| node_subject
node_login -->|"signs in"| node_auth_service
node_register -->|"registers"| node_auth_service
node_auth_service -->|"uses"| node_api_client
node_home -->|"loads study data"| node_api_client
node_subject -->|"loads subject and notes"| node_api_client
node_wakeup_service -->|"uses"| node_api_client
node_api_client -->|"reads URL"| node_api_config
node_api_client -->|"HTTP requests"| node_backend_api
node_backend_api -->|"persists data"| node_database
node_backend_api -->|"serves media"| node_s3

click node_expo "https://github.com/shubhashish-chakraborty/lastglance/blob/main/package.json"
click node_root_layout "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/_layout.tsx"
click node_index_route "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/index.tsx"
click node_auth_routes "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/_layout.tsx"
click node_login "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/login.tsx"
click node_register "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/register.tsx"
click node_app_routes "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/_layout.tsx"
click node_home "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/home.tsx"
click node_subject "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/subject/%5Bid%5D.tsx"
click node_auth_state "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/store/authStore.ts"
click node_use_auth "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/hooks/useAuth.ts"
click node_api_config "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/constants/api.ts"
click node_api_client "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/api.ts"
click node_auth_service "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/authService.ts"
click node_wakeup_service "https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/wakeupService.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_expo,node_auth_state,node_use_auth,node_secure_store toneBlue
class node_root_layout,node_index_route,node_auth_routes,node_login,node_register,node_app_routes,node_home,node_subject toneAmber
class node_api_config,node_api_client,node_auth_service,node_wakeup_service toneMint
class node_backend_api,node_database,node_s3 toneRose
```

## Components

### Expo Mobile App

- [Expo / EAS runtime](https://github.com/shubhashish-chakraborty/lastglance/blob/main/package.json): mobile runtime · Runs development client and produces Android builds. · `package.json`
- [Auth state](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/store/authStore.ts): client store · Centralizes session state and token retrieval. · `src/store/authStore.ts`
- [Auth hook](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/hooks/useAuth.ts): state access · `src/hooks/useAuth.ts`
- **Secure token storage**: device storage · expo-secure-store persists authentication tokens.

### Router UI

- [Root layout](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/_layout.tsx): router root · `src/app/_layout.tsx`
- [Initial route](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/index.tsx): route selector · Selects authenticated or unauthenticated experience. · `src/app/index.tsx`
- [Auth route group](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/_layout.tsx): unauthenticated UI · `src/app/(auth)/_layout.tsx`
- [Login](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/login.tsx): auth screen · `src/app/(auth)/login.tsx`
- [Register](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(auth)/register.tsx): auth screen · `src/app/(auth)/register.tsx`
- [Protected route group](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/_layout.tsx): authenticated UI · `src/app/(app)/_layout.tsx`
- [Home](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/home.tsx): study screen · `src/app/(app)/home.tsx`
- [Subject detail](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/app/(app)/subject/%5Bid%5D.tsx): parameterized study screen · Maps subject IDs to subject and note material. · `src/app/(app)/subject/[id].tsx`

### Client Services

- [API base URL](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/constants/api.ts): endpoint configuration · Configures device-to-server connectivity. · `src/constants/api.ts`
- [Shared API client](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/api.ts): HTTP boundary · `src/services/api.ts`
- [Auth service](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/authService.ts): auth API service · `src/services/authService.ts`
- [Wake-up service](https://github.com/shubhashish-chakraborty/lastglance/blob/main/src/services/wakeupService.ts): availability API service · Calls /wakeup to mitigate backend cold starts. · `src/services/wakeupService.ts`

### External Backend

Separate LastGlance backend repository.

- **LastGlance backend API**: JWT API · Provides authentication, subjects, notes, and media endpoints.
- **PostgreSQL-compatible DB**: backend database
- **AWS S3 media storage**: object storage · Stores remotely managed study media.

## Connections

- Expo / EAS runtime → Root layout: loads
- Root layout → Initial route: resolves
- Initial route → Auth hook: checks session
- Auth hook → Auth state: reads
- Auth state → Secure token storage: retrieves token
- Initial route → Auth route group: unauthenticated
- Initial route → Protected route group: authenticated
- Auth route group → Login: contains
- Auth route group → Register: contains
- Protected route group → Home: contains
- Protected route group → Subject detail: contains
- Login → Auth service: signs in
- Register → Auth service: registers
- Auth service → Shared API client: uses
- Home → Shared API client: loads study data
- Subject detail → Shared API client: loads subject and notes
- Wake-up service → Shared API client: uses
- Shared API client → API base URL: reads URL
- Shared API client → LastGlance backend API: HTTP requests
- LastGlance backend API → PostgreSQL-compatible DB: persists data
- LastGlance backend API → AWS S3 media storage: serves media
