···1-# Gemini Code Assistant Context
2-3-This document provides an overview of the "skypod" project to be used as context for AI-assisted development.
4-5-## Project Overview
6-7-**Skypod** is an offline-first, peer-to-peer RSS and podcast Progressive Web App (PWA). The primary goal is to allow a user to manage their subscriptions and listening history across multiple devices, with data synchronizing directly between them.
8-9-### Architecture
10-11-The application is a full-stack TypeScript project with three main components:
12-13-1. **Frontend Client:** A Preact-based single-page application built with Vite. It is responsible for all UI, managing local data in IndexedDB via **Dexie.js**, and handling the peer-to-peer communication.
14-2. **Backend Server:** A lightweight Node.js server using Express. Its primary roles are to act as a proxy for fetching and parsing external RSS feeds and to run a WebSocket-based signaling server for establishing WebRTC connections between clients.
15-3. **P2P Sync Protocol:** The core of the application is a custom peer-to-peer synchronization protocol. It uses WebRTC (via `simple-peer`) for direct communication between a user's devices. Data consistency is achieved by syncing an immutable log of actions, with ordering guaranteed by a **Hybrid Logical Clock (HLC)** implementation.
16-17-### Key Technologies
18-19-- **Language:** TypeScript
20-- **Frontend:** Preact, Vite, Dexie.js
21-- **Backend:** Node.js, Express, `ws` for WebSockets
22-- **P2P & Sync:** WebRTC (`simple-peer`), Hybrid Logical Clocks
23-- **Schema & Validation:** Zod
24-- **Build & Tooling:** `npm` with `wireit`, ESLint, Prettier, Jest
25-26-## Building and Running
27-28-The project uses `npm` and `wireit` for robust script and dependency management.
29-30-- **Installation:**
31- ```bash
32- npm install
33- ```
34-35-- **Development:**
36- ```bash
37- npm run dev
38- ```
39- This is the primary development command. It uses `wireit` to concurrently run the Vite dev server, the backend server with `tsx` for live reloading, and watch modes for linting and type-checking. The frontend is available at `http://127.0.0.1:4000` and the backend at `http://127.0.0.1:4001`.
40-41-- **Production:**
42- ```bash
43- npm run start:prod
44- ```
45- This command builds the production frontend assets with Vite and starts the backend server.
46-47-- **Testing:**
48- ```bash
49- npm run test
50- ```
51- Runs the entire Jest test suite once.
52-53-- **Linting & Type-Checking:**
54- ```bash
55- npm run lint
56- npm run types
57- ```
58-59-## Development Conventions
60-61-- **Code Style:** The project enforces a strict code style using Prettier and ESLint. Configurations can be found in `prettier.config.js` and `eslint.config.js`.
62-- **Git Hooks:** A `pre-commit` hook is provided in `.githooks/` to automatically run linting and type-checking. Enable it with `git config core.hooksPath .githooks`.
63-- **Path Aliases:** The codebase uses import aliases like `#common/*` and `#client/*` for clean, absolute-style imports. These are defined in `package.json` and `tsconfig.json`.
64-- **P2P Sync Model:** The synchronization protocol follows a specific hybrid model:
65- - **PULL for Catch-up:** A new client PULLS the full action history from a single, deterministically chosen `syncPartner` to efficiently get up to date.
66- - **PUSH for Updates:** All clients PUSH their own new or offline-generated changes to all connected peers. This is not a simple broadcast; the client sends a *tailored* set of missing actions to each peer based on a handshake where "knowledge vectors" are exchanged.