···11-# Gemini Code Assistant Context
22-33-This document provides an overview of the "skypod" project to be used as context for AI-assisted development.
44-55-## Project Overview
66-77-**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.
88-99-### Architecture
1010-1111-The application is a full-stack TypeScript project with three main components:
1212-1313-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.
1414-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.
1515-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.
1616-1717-### Key Technologies
1818-1919-- **Language:** TypeScript
2020-- **Frontend:** Preact, Vite, Dexie.js
2121-- **Backend:** Node.js, Express, `ws` for WebSockets
2222-- **P2P & Sync:** WebRTC (`simple-peer`), Hybrid Logical Clocks
2323-- **Schema & Validation:** Zod
2424-- **Build & Tooling:** `npm` with `wireit`, ESLint, Prettier, Jest
2525-2626-## Building and Running
2727-2828-The project uses `npm` and `wireit` for robust script and dependency management.
2929-3030-- **Installation:**
3131- ```bash
3232- npm install
3333- ```
3434-3535-- **Development:**
3636- ```bash
3737- npm run dev
3838- ```
3939- 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`.
4040-4141-- **Production:**
4242- ```bash
4343- npm run start:prod
4444- ```
4545- This command builds the production frontend assets with Vite and starts the backend server.
4646-4747-- **Testing:**
4848- ```bash
4949- npm run test
5050- ```
5151- Runs the entire Jest test suite once.
5252-5353-- **Linting & Type-Checking:**
5454- ```bash
5555- npm run lint
5656- npm run types
5757- ```
5858-5959-## Development Conventions
6060-6161-- **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`.
6262-- **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`.
6363-- **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`.
6464-- **P2P Sync Model:** The synchronization protocol follows a specific hybrid model:
6565- - **PULL for Catch-up:** A new client PULLS the full action history from a single, deterministically chosen `syncPartner` to efficiently get up to date.
6666- - **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.