@@ -83,60 +83,190 @@ make down-prod # Stop production environment
8383
8484```
8585encrypted-p2p-chat/
86- ├── backend/
87- │ ├── app/
88- │ │ ├── api/ # API endpoints
89- │ │ │ ├── auth.py # WebAuthn authentication
90- │ │ │ ├── encryption.py # Prekey bundle endpoints
91- │ │ │ └── websocket.py # WebSocket endpoint
92- │ │ ├── core/
93- │ │ │ ├── encryption/
94- │ │ │ │ ├── x3dh_manager.py # X3DH key exchange
95- │ │ │ │ └── double_ratchet.py # Double Ratchet engine
96- │ │ │ ├── passkey/
97- │ │ │ │ └── passkey_manager.py # WebAuthn manager
98- │ │ │ ├── exceptions.py # Custom exceptions
99- │ │ │ ├── redis_manager.py # Redis client
100- │ │ │ ├── surreal_manager.py # SurrealDB client
101- │ │ │ └── websocket_manager.py # WebSocket connections
102- │ │ ├── models/ # SQLModel database models
103- │ │ ├── schemas/ # Pydantic schemas
104- │ │ ├── services/ # Business logic layer
105- │ │ ├── config.py # Configuration and constants
106- │ │ ├── factory.py # FastAPI app factory
107- │ │ └── main.py # Entry point
108- │ ├── tests/ # Pytest tests
109- │ ├── Dockerfile # Production
110- │ ├── Dockerfile.dev # Development
111- │ └── pyproject.toml
112- ├── frontend/
113- │ ├── src/
114- │ │ ├── pages/ # SolidJS pages
115- │ │ ├── App.tsx # Root component with routes
116- │ │ ├── index.tsx # Entry point
117- │ │ ├── index.css # Tailwind imports
118- │ │ └── config.ts # Constants
119- │ ├── public/
120- │ │ └── index.html
121- │ ├── Dockerfile # Production
122- │ ├── Dockerfile.dev # Development
123- │ ├── vite.config.ts
124- │ ├── tsconfig.json
125- │ └── package.json
126- ├── nginx/
127- │ ├── nginx.dev.conf # Development config
128- │ ├── nginx.prod.conf # Production config
129- │ └── Dockerfile
130- ├── docker-compose.yml # Production
131- ├── docker-compose.dev.yml # Development
13286├── Makefile
133- └── .env.example
134-
87+ ├── README.md
88+ ├── backend
89+ │ ├── alembic
90+ │ │ ├── README
91+ │ │ ├── env.py
92+ │ │ ├── script.py.mako
93+ │ │ └── versions
94+ │ ├── alembic.ini
95+ │ ├── app
96+ │ │ ├── api
97+ │ │ │ ├── auth.py
98+ │ │ │ ├── encryption.py
99+ │ │ │ ├── rooms.py
100+ │ │ │ └── websocket.py
101+ │ │ ├── config.py
102+ │ │ ├── core
103+ │ │ │ ├── encryption
104+ │ │ │ │ ├── double_ratchet.py
105+ │ │ │ │ └── x3dh_manager.py
106+ │ │ │ ├── enums.py
107+ │ │ │ ├── exception_handlers.py
108+ │ │ │ ├── exceptions.py
109+ │ │ │ ├── passkey
110+ │ │ │ │ └── passkey_manager.py
111+ │ │ │ ├── redis_manager.py
112+ │ │ │ ├── surreal_manager.py
113+ │ │ │ └── websocket_manager.py
114+ │ │ ├── factory.py
115+ │ │ ├── main.py
116+ │ │ ├── models
117+ │ │ │ ├── Base.py
118+ │ │ │ ├── Credential.py
119+ │ │ │ ├── IdentityKey.py
120+ │ │ │ ├── OneTimePrekey.py
121+ │ │ │ ├── RatchetState.py
122+ │ │ │ ├── SignedPrekey.py
123+ │ │ │ ├── SkippedMessageKey.py
124+ │ │ │ └── User.py
125+ │ │ ├── schemas
126+ │ │ │ ├── auth.py
127+ │ │ │ ├── common.py
128+ │ │ │ ├── rooms.py
129+ │ │ │ ├── surreal.py
130+ │ │ │ └── websocket.py
131+ │ │ └── services
132+ │ │ ├── auth_service.py
133+ │ │ ├── message_service.py
134+ │ │ ├── prekey_service.py
135+ │ │ ├── presence_service.py
136+ │ │ └── websocket_service.py
137+ │ ├── encrypted_p2p_chat.egg-info
138+ │ │ ├── PKG-INFO
139+ │ │ ├── SOURCES.txt
140+ │ │ ├── dependency_links.txt
141+ │ │ ├── requires.txt
142+ │ │ └── top_level.txt
143+ │ ├── pyproject.toml
144+ │ └── tests
145+ │ ├── conftest.py
146+ │ ├── test_auth_service.py
147+ │ ├── test_encryption.py
148+ │ ├── test_message_service.py
149+ │ └── test_x3dh.py
150+ ├── conf
151+ │ ├── docker
152+ │ │ ├── dev
153+ │ │ │ ├── fastapi.docker
154+ │ │ │ └── vite.docker
155+ │ │ └── prod
156+ │ │ ├── fastapi.docker
157+ │ │ └── vite.docker
158+ │ └── nginx
159+ │ ├── dev.nginx
160+ │ ├── http.conf
161+ │ └── prod.nginx
162+ ├── docker-compose.dev.yml
163+ ├── docker-compose.prod.yml
164+ └── frontend
165+ ├── README.md
166+ ├── eslint.config.js
167+ ├── index.html
168+ ├── package-lock.json
169+ ├── package.json
170+ ├── public
171+ ├── src
172+ │ ├── App.tsx
173+ │ ├── components
174+ │ │ ├── Auth
175+ │ │ │ ├── AuthCard.tsx
176+ │ │ │ ├── AuthForm.tsx
177+ │ │ │ ├── PasskeyButton.tsx
178+ │ │ │ └── index.ts
179+ │ │ ├── Chat
180+ │ │ │ ├── ChatHeader.tsx
181+ │ │ │ ├── ChatInput.tsx
182+ │ │ │ ├── ConversationItem.tsx
183+ │ │ │ ├── ConversationList.tsx
184+ │ │ │ ├── EncryptionBadge.tsx
185+ │ │ │ ├── MessageBubble.tsx
186+ │ │ │ ├── MessageList.tsx
187+ │ │ │ ├── NewConversation.tsx
188+ │ │ │ ├── OnlineStatus.tsx
189+ │ │ │ ├── TypingIndicator.tsx
190+ │ │ │ ├── UserSearch.tsx
191+ │ │ │ └── index.ts
192+ │ │ ├── Layout
193+ │ │ │ ├── AppShell.tsx
194+ │ │ │ ├── Header.tsx
195+ │ │ │ ├── ProtectedRoute.tsx
196+ │ │ │ ├── Sidebar.tsx
197+ │ │ │ └── index.ts
198+ │ │ └── UI
199+ │ │ ├── Avatar.tsx
200+ │ │ ├── Badge.tsx
201+ │ │ ├── Button.tsx
202+ │ │ ├── Dropdown.tsx
203+ │ │ ├── IconButton.tsx
204+ │ │ ├── Input.tsx
205+ │ │ ├── Modal.tsx
206+ │ │ ├── Skeleton.tsx
207+ │ │ ├── Spinner.tsx
208+ │ │ ├── TextArea.tsx
209+ │ │ ├── Toast.tsx
210+ │ │ ├── Tooltip.tsx
211+ │ │ └── index.ts
212+ │ ├── config.ts
213+ │ ├── crypto
214+ │ │ ├── crypto-service.ts
215+ │ │ ├── double-ratchet.ts
216+ │ │ ├── index.ts
217+ │ │ ├── key-store.ts
218+ │ │ ├── primitives.ts
219+ │ │ └── x3dh.ts
220+ │ ├── index.css
221+ │ ├── index.tsx
222+ │ ├── lib
223+ │ │ ├── api-client.ts
224+ │ │ ├── base64.ts
225+ │ │ ├── date.ts
226+ │ │ ├── index.ts
227+ │ │ └── validators.ts
228+ │ ├── pages
229+ │ │ ├── Chat.tsx
230+ │ │ ├── Home.tsx
231+ │ │ ├── Login.tsx
232+ │ │ ├── NotFound.tsx
233+ │ │ └── Register.tsx
234+ │ ├── services
235+ │ │ ├── auth.service.ts
236+ │ │ └── index.ts
237+ │ ├── stores
238+ │ │ ├── auth.store.ts
239+ │ │ ├── index.ts
240+ │ │ ├── messages.store.ts
241+ │ │ ├── presence.store.ts
242+ │ │ ├── rooms.store.ts
243+ │ │ ├── session.store.ts
244+ │ │ ├── settings.store.ts
245+ │ │ ├── typing.store.ts
246+ │ │ └── ui.store.ts
247+ │ ├── styles
248+ │ ├── types
249+ │ │ ├── api.ts
250+ │ │ ├── auth.ts
251+ │ │ ├── chat.ts
252+ │ │ ├── components.ts
253+ │ │ ├── encryption.ts
254+ │ │ ├── guards.ts
255+ │ │ ├── index.ts
256+ │ │ └── websocket.ts
257+ │ ├── vite-env.d.ts
258+ │ └── websocket
259+ │ ├── index.ts
260+ │ ├── message-handlers.ts
261+ │ └── websocket-manager.ts
262+ ├── tsconfig.json
263+ └── vite.config.ts
264+ ```
135265## Features
136266
137267### Authentication
138268- Passwordless login with WebAuthn/Passkeys
139- - Discoverable credentials (device- based auth)
269+ - Discoverable credentials (device based auth)
140270- Multi-device support
141271- Signature counter verification
142272
@@ -145,7 +275,7 @@ encrypted-p2p-chat/
145275- X3DH key exchange for async messaging
146276- Forward secrecy
147277- Break-in recovery
148- - Out-of- order message handling
278+ - Out of order message handling
149279
150280### Real-time Messaging
151281- WebSocket connections
@@ -173,7 +303,6 @@ python -m pytest tests/ -v
173303cd frontend
174304npm install
175305npm run dev
176- npm run typecheck
177306npm run lint
178307```
179308
@@ -224,7 +353,7 @@ Shared Secret
224353 ↓
225354Double Ratchet Initialization
226355 ↓
227- Per- Message Encryption (AES-256-GCM)
356+ Per Message Encryption (AES-256-GCM)
228357```
229358
230359### WebSocket Flow
0 commit comments