# leanhminh2104/locketlam architecture

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

- Interactive diagram: https://gitdiagram.com/leanhminh2104/locketlam
- Repository: https://github.com/leanhminh2104/locketlam

## Overview

LocketLam is a Python SDK for programmatic access to Locket Camera. The main workflow initializes a client and device profile, authenticates and persists a session, then exposes user, moments, friends, and chat operations through service modules. Moments include feed retrieval and media posting; chat includes message operations and a WebSocket listener. Device emulation and shared API transport support these features. Several subsystem details are documented or only partially excerpted, so relationships not directly shown are omitted.

Main entry points: [`locketlam/client.py`](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/client.py) (Authenticated API), [`locketlam/modules/user.py`](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/user.py) (User Profiles), [`locketlam/modules/chat.py`](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/chat.py) (Chat Messaging), [`locketlam/modules/moments.py`](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/moments.py) (Moments and Feed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client_core["Client Core"]
  node_client["Locket Client<br/>[client.py]"]
  node_transport["Authenticated API<br/>[client.py]"]
  node_errors["SDK Errors<br/>[exceptions.py]"]
end

subgraph group_identity["Identity and Device"]
  node_device["Device Profile<br/>[device.py]"]
  node_session["Session Manager<br/>[session.py]"]
  node_session_file["Session File"]
end

subgraph group_social["Social Features"]
  node_user["User Profiles<br/>[user.py]"]
  node_moments["Moments and Feed<br/>[moments.py]"]
  node_friends["Friends and Groups<br/>[friends.py]"]
  node_chat["Chat Messaging<br/>[chat.py]"]
  node_moment_history["Moment History<br/>[moments.py]"]
  node_chat_history["Chat History<br/>[chat.py]"]
end

subgraph group_integrations["Backend Integrations"]
  node_locket_api{{"Locket Backend"}}
  node_firebase_auth{{"Firebase Auth"}}
  node_firestore[("Firestore")]
  node_cloud_storage[("Firebase Storage")]
  node_chat_socket["Chat WebSocket"]
end

node_developer(("SDK Caller"))

node_developer -->|"creates"| node_client
node_client -->|"configures"| node_device
node_client -->|"initializes"| node_session
node_client -->|"exposes"| node_user
node_client -->|"exposes"| node_moments
node_client -->|"exposes"| node_friends
node_client -->|"exposes"| node_chat
node_session -->|"uses"| node_device
node_session -->|"loads and saves"| node_session_file
node_session -->|"authenticates and refreshes"| node_firebase_auth
node_transport -->|"gets token"| node_session
node_transport -->|"adds headers"| node_device
node_transport -->|"posts requests"| node_locket_api
node_user -->|"calls"| node_transport
node_user -->|"looks up and updates profile"| node_firebase_auth
node_user -->|"uploads avatar"| node_cloud_storage
node_friends -->|"calls"| node_transport
node_friends -->|"reads friend data"| node_firestore
node_friends -->|"fetches profiles"| node_user
node_moments -->|"calls"| node_transport
node_moments -->|"resolves username"| node_user
node_moments -->|"uploads media"| node_cloud_storage
node_moments -->|"reads and writes"| node_moment_history
node_chat -->|"sends messages"| node_transport
node_chat -->|"fetches messages"| node_firestore
node_chat -->|"synchronizes history"| node_chat_history
node_chat -->|"listens for events"| node_chat_socket
node_chat -->|"resolves peer"| node_user
node_transport -.->|"raises API errors"| node_errors

click node_client "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/client.py"
click node_device "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/device.py"
click node_session "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/session.py"
click node_user "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/user.py"
click node_moments "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/moments.py"
click node_friends "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/friends.py"
click node_chat "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/chat.py"
click node_moment_history "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/moments.py"
click node_chat_history "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/chat.py"
click node_transport "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/client.py"
click node_errors "https://github.com/leanhminh2104/locketlam/blob/main/locketlam/exceptions.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_client,node_transport,node_errors toneBlue
class node_device,node_session,node_session_file toneAmber
class node_user,node_moments,node_friends,node_chat,node_moment_history,node_chat_history toneMint
class node_locket_api,node_firebase_auth,node_firestore,node_cloud_storage,node_chat_socket toneRose
class node_developer toneIndigo
```

## Components

### Client Core

- [Locket Client](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/client.py): `locketlam/client.py`
- [Authenticated API](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/client.py): `locketlam/client.py`
- [SDK Errors](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/exceptions.py): `locketlam/exceptions.py`

### Identity and Device

- [Device Profile](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/device.py): `locketlam/device.py`
- [Session Manager](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/session.py): `locketlam/session.py`
- **Session File**

### Social Features

- [User Profiles](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/user.py): `locketlam/modules/user.py`
- [Moments and Feed](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/moments.py): `locketlam/modules/moments.py`
- [Friends and Groups](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/friends.py): `locketlam/modules/friends.py`
- [Chat Messaging](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/chat.py): `locketlam/modules/chat.py`
- [Moment History](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/moments.py): `locketlam/modules/moments.py`
- [Chat History](https://github.com/leanhminh2104/locketlam/blob/main/locketlam/modules/chat.py): `locketlam/modules/chat.py`

### Backend Integrations

- **Locket Backend**
- **Firebase Auth**
- **Firestore**
- **Firebase Storage**
- **Chat WebSocket**

### Other components

- **SDK Caller**

## Connections

- SDK Caller → Locket Client: creates (evidence: `README.md`)
- Locket Client → Device Profile: configures (evidence: `locketlam/client.py`)
- Locket Client → Session Manager: initializes (evidence: `locketlam/client.py`)
- Locket Client → User Profiles: exposes (evidence: `locketlam/client.py`)
- Locket Client → Moments and Feed: exposes (evidence: `locketlam/client.py`)
- Locket Client → Friends and Groups: exposes (evidence: `locketlam/client.py`)
- Locket Client → Chat Messaging: exposes (evidence: `locketlam/client.py`)
- Session Manager → Device Profile: uses (evidence: `locketlam/session.py`)
- Session Manager → Session File: loads and saves (evidence: `locketlam/session.py`)
- Session Manager → Firebase Auth: authenticates and refreshes (evidence: `locketlam/session.py`)
- Authenticated API → Session Manager: gets token (evidence: `locketlam/client.py`)
- Authenticated API → Device Profile: adds headers (evidence: `locketlam/client.py`)
- Authenticated API → Locket Backend: posts requests (evidence: `locketlam/client.py`)
- User Profiles → Authenticated API: calls (evidence: `locketlam/modules/user.py`)
- User Profiles → Firebase Auth: looks up and updates profile (evidence: `locketlam/modules/user.py`)
- User Profiles → Firebase Storage: uploads avatar (evidence: `locketlam/modules/user.py`)
- Friends and Groups → Authenticated API: calls (evidence: `locketlam/modules/friends.py`)
- Friends and Groups → Firestore: reads friend data (evidence: `locketlam/modules/friends.py`)
- Friends and Groups → User Profiles: fetches profiles (evidence: `locketlam/modules/friends.py`)
- Moments and Feed → Authenticated API: calls (evidence: `locketlam/modules/moments.py`)
- Moments and Feed → User Profiles: resolves username (evidence: `locketlam/modules/moments.py`)
- Moments and Feed → Firebase Storage: uploads media (evidence: `README.md`)
- Moments and Feed → Moment History: reads and writes (evidence: `locketlam/modules/moments.py`)
- Chat Messaging → Authenticated API: sends messages (evidence: `locketlam/modules/chat.py`)
- Chat Messaging → Firestore: fetches messages (evidence: `locketlam/modules/chat.py`)
- Chat Messaging → Chat History: synchronizes history (evidence: `locketlam/modules/chat.py`)
- Chat Messaging → Chat WebSocket: listens for events (evidence: `locketlam/modules/chat.py`)
- Chat Messaging → User Profiles: resolves peer (evidence: `locketlam/modules/chat.py`)
- Authenticated API → SDK Errors: raises API errors (evidence: `locketlam/client.py`)
