- Remove OCR noise, credits, and duplicates from rules-database.json (288→255 rules) - Add clean_rules.py script for rule cleanup - Add CLAUDE.md, docs/, and update README with documentation links Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4.8 KiB
4.8 KiB
CLAUDE.md - Codebase Documentation for Claude Code
This file helps Claude understand the Deathwatch Roller codebase and provide better assistance.
Project Overview
Deathwatch Roller is a React-based web application for managing Deathwatch tabletop RPG sessions.
Main Features:
- Player management (CRUD operations for player accounts)
- Requisition shop (browse and purchase items with RP)
- Session tracking (track game sessions and progress)
- GM Kit (comprehensive Game Master tools)
- Bestiary (monster and enemy reference)
- Rules database (searchable rules and mechanics)
Tech Stack:
- Frontend: React + TypeScript
- Backend: Node.js + Express + TypeScript
- Database: SQLite
- Styling: CSS modules / Tailwind
Architecture
dwroller/
├── backend/ # Express API server
├── frontend/ # React frontend (Vite)
├── data/ # Static data and assets
├── database/ # SQLite database and backups
└── docs/ # Documentation (see docs/)
Key Files and Locations
Backend
backend/server.js- Express server entry pointbackend/src/routes/- API route handlersbackend/src/middleware/- Authentication, validation middlewarebackend/src/models/- Data modelsbackend/src/controllers/- Route controllers
Frontend
frontend/src/components/- React componentsfrontend/src/pages/- Route pagesfrontend/src/hooks/- Custom React hooksfrontend/src/store/- State management
Shared
.env- Environment variables (port, secrets, database path)package.json- Root package.json with scriptsdatabase/data.db- SQLite database (created on first run)
Development Workflow
- Install dependencies:
npm install - Create
.envfrom.env.example - Start backend:
npm run server(ornpm run devfor dev) - Start frontend:
npm start(ornpm run devfor dev)
Scripts
npm start- Start frontendnpm run server- Start backendnpm run dev- Start both in dev modenpm run build- Build for productionnpm run pm2:start- Start with PM2
API Endpoints
| Endpoint | Description |
|---|---|
GET /api/players |
Get all players |
POST /api/players |
Create player (GM only) |
GET /api/shop |
Get shop inventory |
GET /api/bestiary |
Get bestiary data |
GET /api/rules/search |
Search rules |
Authentication
- Sessions use HTTP-only cookies
- GM endpoints require
x-gm-secretheader - Passwords hashed with bcrypt
Code Style
- Use TypeScript for all new code
- Follow Airbnb JavaScript style guide
- Use ESLint for linting
- Maximum 100 character line length
- Functional React components with hooks
Security Considerations
- Session cookies are HTTP-only
- Passwords hashed with bcrypt
- SQL queries use parameterized statements
- Rate limiting enabled (100 req/min)
- CORS configured for allowed origins
- Input validation on all endpoints
Database
- SQLite by default
- Schema created automatically on first run
- Tables: players, items, inventory, sessions, webhooks
- Database path configurable via
DATABASE_PATHenv var - Backups in
database/backups/
Frontend Components
Main component locations:
Shop/- Shop and inventory componentsBestiary/- Creature reference componentsRules/- Rules database componentsSessions/- Session tracking componentsPlayers/- Player management (GM only)
Common Tasks
Adding a New API Endpoint
- Create route file in
backend/src/routes/ - Add controller in
backend/src/controllers/ - Register route in
server.js - Add tests in
backend/src/routes/__tests__/
Adding a New Frontend Component
- Create component in
frontend/src/components/ - Add TypeScript interface for props
- Use existing CSS patterns
- Test in browser
Adding a Database Model
- Create model in
backend/src/models/ - Define schema with
sequelize - Add indexes for frequent queries
- Write migration if needed
Testing
- Backend tests:
npm test - Frontend tests:
cd frontend && npm test - E2E tests:
npm run test:e2e
Documentation
Full documentation is in docs/:
SUMMARY.md- Documentation indexquick-start.md- Installation guideuser-guide.md- User documentationapi.md- API referencedeveloper-guide.md- Contributing guidesecurity.md- Security best practicestroubleshooting.md- Common issuespm2.md- Production deployment
Environment Variables
PORT=5000 # Backend server port
SESSION_SECRET=... # Session encryption key
X_GM_SECRET=... # GM authentication secret
DATABASE_PATH=./database/data.db # SQLite path
NODE_ENV=development # env: development|production
Getting Help
- Check documentation in
docs/ - Review code examples in the codebase
- See open issues on GitHub
- Create new issue for questions