Skip to content

Commit 3645786

Browse files
authored
Merge branch 'main' into feature/jellyfin-invite-system
2 parents e7da4bf + faea47f commit 3645786

File tree

8 files changed

+137
-246
lines changed

8 files changed

+137
-246
lines changed

README.md

Lines changed: 87 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Plex Management System transforms your Plex experience by combining powerful man
5858
- **Client Configuration Guides** to ensure Direct Play and best quality
5959
- **Issue Reporting** workflow to streamline support requests
6060
- **Media Request** integration (via Overseerr)
61+
- **Discord Integration** for community engagement and announcements (optional)
62+
- **Service Status** monitoring for all connected platforms
6163

6264
### 📊 Plex Wrapped & Statistics
6365
- **Total watch time** breakdown (movies vs. shows)
@@ -73,10 +75,13 @@ Plex Management System transforms your Plex experience by combining powerful man
7375
- **Responsive design** that works on any device
7476

7577
### 🛠️ Admin Features
76-
- **User management** dashboard
78+
- **User management** dashboard with role-based access control
79+
- **Service management** - Monitor and configure Plex, Tautulli, Overseerr, Sonarr, Radarr
80+
- **Announcements system** - Server-wide notifications with markdown support
7781
- **LLM usage tracking** and cost monitoring
7882
- **Share analytics** to see what's popular
79-
- **Centralized configuration** for server integrations
83+
- **Audit logging** for security and compliance
84+
- **Centralized configuration** for all integrations
8085

8186
---
8287

@@ -86,10 +91,12 @@ Plex Management System transforms your Plex experience by combining powerful man
8691

8792
- **Node.js** 18+ (LTS recommended)
8893
- **npm** or **yarn**
94+
- **PostgreSQL** database (SQLite is no longer supported as of Prisma v7)
8995
- Access to:
9096
- A **Plex server** (with admin token)
9197
- **Tautulli** instance (for viewing statistics)
9298
- **Overseerr** (optional, for request stats)
99+
- **Sonarr/Radarr** (optional, for media management features)
93100
- **OpenAI** API key (optional, for AI insights)
94101

95102
### Installation
@@ -111,7 +118,7 @@ cp example.env .env
111118
```
112119

113120
Edit `.env` and configure:
114-
- `DATABASE_URL` - SQLite database path (default: `file:./dev.db`)
121+
- `DATABASE_URL` - PostgreSQL connection string (e.g., `postgresql://user:password@localhost:5432/plex_manager`)
115122
- `NEXT_PUBLIC_APP_URL` - Your public application URL (e.g., `http://localhost:3000` for dev, `https://yourdomain.com` for production)
116123
- `NEXTAUTH_URL` - Your application URL for NextAuth callbacks (should match `NEXT_PUBLIC_APP_URL` in production)
117124
- `NEXTAUTH_SECRET` - Generate with: `openssl rand -base64 32`
@@ -146,26 +153,31 @@ On first launch, you'll be guided through configuring:
146153

147154
```
148155
plex-wrapped/
149-
├── app/ # Next.js App Router routes
150-
│ ├── admin/ # Admin dashboard pages
151-
│ ├── api/ # API routes
156+
├── app/ # Next.js App Router (pages, layouts, routes)
157+
│ ├── (app)/ # Authenticated app layout group
158+
│ ├── admin/ # Admin dashboard and management
159+
│ ├── api/ # API routes (webhooks, external integrations)
152160
│ ├── auth/ # Authentication pages
153161
│ ├── onboarding/ # User onboarding flow
154-
│ ├── setup/ # Initial server setup wizard
155-
│ └── wrapped/ # Wrapped viewer pages
156-
├── actions/ # Server Actions
162+
│ ├── setup/ # Initial setup wizard
163+
│ └── wrapped/ # Wrapped viewer and sharing
164+
├── actions/ # Server Actions (mutations, data operations)
157165
├── components/ # React components
158166
│ ├── admin/ # Admin-specific components
159-
│ ├── onboarding/ # User onboarding components
160-
│ ├── setup-wizard/ # Setup wizard components
161-
│ └── wrapped/ # Wrapped content sections
162-
├── hooks/ # Custom React hooks
163-
├── lib/ # Utilities and helpers
164-
│ ├── connections/ # Plex/Tautulli/Overseerr clients
165-
│ ├── wrapped/ # Wrapped generation logic
166-
│ └── validations/ # Zod schemas
167-
├── prisma/ # Prisma schema and migrations
168-
└── types/ # TypeScript type definitions
167+
│ ├── generator/ # Wrapped generation UI
168+
│ ├── onboarding/ # Onboarding components
169+
│ ├── setup-wizard/ # Setup wizard steps
170+
│ ├── ui/ # Shared UI primitives
171+
│ └── wrapped/ # Wrapped display components
172+
├── lib/ # Utilities, helpers, business logic
173+
│ ├── connections/ # External API clients (Plex, Tautulli, Overseerr, etc.)
174+
│ ├── security/ # Security utilities (rate limiting, CSRF, audit logging)
175+
│ ├── validations/ # Zod schemas for all services
176+
│ ├── wrapped/ # Wrapped generation and statistics
177+
│ └── utils/ # Shared utilities
178+
├── types/ # TypeScript type definitions
179+
├── prisma/ # Database schema and migrations
180+
└── e2e/ # Playwright end-to-end tests
169181
```
170182

171183
### Available Scripts
@@ -189,27 +201,39 @@ plex-wrapped/
189201

190202
### Development Guidelines
191203

192-
#### **Architecture Principles**
204+
**📖 For comprehensive development guidelines, see [CLAUDE.md](CLAUDE.md)**
205+
206+
The CLAUDE.md file contains detailed information about:
207+
- Architecture patterns and component design
208+
- Server Actions vs API routes
209+
- Database patterns with Prisma
210+
- Integration guides (Plex, Tautulli, Overseerr, Sonarr/Radarr)
211+
- Security best practices
212+
- Testing strategies
213+
- Code style conventions
214+
215+
#### **Quick Reference**
216+
217+
**Architecture Principles**
193218
- **Server Components by default** - Use Client Components (`'use client'`) only when needed
194219
- **Server Actions** - Prefer Server Actions over API routes for mutations
195220
- **TanStack Query** - Use for all client-side data fetching
196-
- **TypeScript strict mode** - Maintain type safety throughout
221+
- **TypeScript strict mode** - Maintain type safety with exhaustive checks
197222

198-
#### **Code Style**
223+
**Code Style**
199224
- **Tailwind CSS** - Use utility classes over custom CSS
200225
- **Zod** - Validate all user inputs and API responses
201226
- **Error boundaries** - Implement proper error handling and loading states
202-
- **Component organization** - Keep components focused and reusable
227+
- **Component organization** - Keep components focused and reusable (max ~200-300 lines)
228+
- **Avoid over-engineering** - Implement exactly what's needed, no premature abstractions
203229

204-
#### **Testing**
205-
- **Jest** - Unit and integration tests
230+
**Testing**
231+
- **Jest** - Unit and integration tests with comprehensive coverage
206232
- **Testing Library** - Component testing utilities
207-
- **Playwright** - End-to-end testing with authenticated sessions
208-
- **Coverage** - Aim for comprehensive test coverage
233+
- **Playwright** - E2E testing with authenticated sessions (use `data-testid` selectors)
234+
- See [E2E Testing Guide](e2e/README.md) for authenticated session patterns
209235

210-
See [E2E Testing Guide](e2e/README.md) for details on writing Playwright tests with authenticated sessions.
211-
212-
#### **Logging**
236+
**Logging**
213237
- Use the `createLogger` utility from `@/lib/utils/logger`
214238
- See [Logging Guide](docs/logging.md) for details on log levels, metadata, and best practices
215239

@@ -259,9 +283,9 @@ When deploying to production, ensure the following environment variables are set
259283
- Generate with: `openssl rand -base64 32`
260284
- Keep this secret and never commit it to version control
261285

262-
4. **`DATABASE_URL`** - Your production database connection string
263-
- For SQLite: `file:./prisma/production.db`
264-
- For PostgreSQL: `postgresql://user:password@host:port/database`
286+
4. **`DATABASE_URL`** - Your production PostgreSQL database connection string
287+
- Example: `postgresql://user:password@host:port/database`
288+
- SQLite is no longer supported (Prisma v7 requirement)
265289

266290
### Important Notes
267291

@@ -285,7 +309,7 @@ The project includes a `Dockerfile` for containerized deployments. When deployin
285309
|----------|-----------|
286310
| **Framework** | Next.js 14+ (App Router) |
287311
| **Language** | TypeScript (strict mode) |
288-
| **Database** | Prisma + SQLite |
312+
| **Database** | Prisma v7 + PostgreSQL |
289313
| **Authentication** | NextAuth.js (Plex PIN-based authentication) |
290314
| **Data Fetching** | TanStack Query (React Query) |
291315
| **Styling** | Tailwind CSS |
@@ -305,14 +329,39 @@ The project includes a `Dockerfile` for containerized deployments. When deployin
305329

306330
---
307331

332+
## Integrations
333+
334+
The platform integrates with multiple services to provide a comprehensive Plex management experience:
335+
336+
### Core Services
337+
- **Plex Media Server** - Primary media server integration (required)
338+
- **Tautulli** - Watch history and statistics tracking (required for Wrapped features)
339+
340+
### Optional Services
341+
- **Overseerr** - Media request management and availability tracking
342+
- **Sonarr** - TV series management and monitoring
343+
- **Radarr** - Movie management and monitoring
344+
- **Discord** - Bot integration for server announcements and community features
345+
- **OpenAI/LLM Providers** - AI-powered insights for Wrapped summaries
346+
347+
All integrations are configured through the setup wizard or admin panel, with validation and connection testing built-in.
348+
349+
---
350+
308351
## Security
309352

310353
- **PIN-based authentication** via Plex
311-
- **Server access verification** - only users with access to your Plex server can sign in
312-
- **Secure token generation** for sharing
354+
- **Server access verification** - Only users with access to your Plex server can sign in
355+
- **Secure token generation** for sharing features
313356
- **Admin-only actions** protected by role checks
314-
- **Input validation** with Zod schemas
315-
- **SQL injection protection** via Prisma
357+
- **Input validation** with Zod schemas on all user inputs and API responses
358+
- **SQL injection protection** via Prisma parameterized queries
359+
- **XSS prevention** - React escapes by default, no unsafe HTML rendering
360+
- **CSRF protection** - Built into Next.js Server Actions
361+
- **Rate limiting** - Protection for sensitive endpoints
362+
- **Audit logging** - Tracking of admin actions and security events
363+
364+
See [CLAUDE.md](CLAUDE.md) for detailed security best practices.
316365

317366
---
318367

__tests__/actions/chatbot.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Tests for actions/chatbot.ts - chatbot sources tracking functionality
33
*/
44

5-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
5+
import { chatWithAdminBot } from "@/actions/chatbot"
6+
import { type ChatMessage } from "@/actions/chatbot/types"
67
import { callChatLLM } from "@/lib/llm/chat"
78
import { prisma } from "@/lib/prisma"
89
import { getServerSession } from "next-auth"

actions/chatbot/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import { type ChatMessage, type ChatResponse } from "./types"
99

1010
const logger = createLogger("CHATBOT")
1111

12-
export type { ChatMessage, ChatResponse }
13-
1412
export async function chatWithAdminBot(
1513
messages: ChatMessage[],
1614
conversationId?: string

components/__tests__/admin/chatbot/chat-window.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { Chatbot } from "@/components/admin/chatbot/chat-window"
66
import { ChatProvider } from "@/components/admin/chatbot/chat-context"
77
import { render, screen, waitFor } from "@testing-library/react"
88
import userEvent from "@testing-library/user-event"
9-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
9+
import { chatWithAdminBot } from "@/actions/chatbot"
10+
import { type ChatMessage } from "@/actions/chatbot/types"
1011

1112
// Mock the chatbot action
1213
jest.mock("@/actions/chatbot", () => ({

components/admin/chatbot/chat-window.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client"
22

3-
import { chatWithAdminBot, type ChatMessage } from "@/actions/chatbot"
3+
import { chatWithAdminBot } from "@/actions/chatbot"
4+
import { type ChatMessage } from "@/actions/chatbot/types"
45
import { AnimatePresence, motion } from "framer-motion"
56
import dynamic from "next/dynamic"
67
import { useEffect, useRef, useState } from "react"

0 commit comments

Comments
 (0)