A community based topic aggregation platform built on atproto

chore: update development environment and documentation

Update development configuration and project documentation to reflect
V2.0 architecture changes and improve code review guidelines.

Changes:
- .env.dev: Add PLC directory configuration for local development
- CLAUDE.md: Enhance PR review checklist with V2-specific concerns

Documentation Updates:
- Clarify atProto write-forward architecture requirements
- Add federation and DID resolution verification steps
- Improve security review checklist
- Add performance and testing coverage guidelines

Environment Updates:
- Configure PLC_DIRECTORY_URL for local PLC directory
- Update IS_DEV_ENV flag documentation

These changes support better code review practices and local
development workflow for V2.0 communities.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+116 -73
+25 -8
.env.dev
···
PDS_HOSTNAME=localhost
PDS_PORT=3001
-
# DID PLC Directory (use Bluesky's for development)
-
PDS_DID_PLC_URL=https://plc.directory
+
# PDS Service Endpoint for DIDs
+
# This is the URL that goes in DID documents' atproto_pds service endpoint
+
# Must match what the PDS thinks its public URL is (internal port 3000)
+
# Development: http://localhost:3000 (PDS's internal view)
+
# Production: https://pds.coves.social
+
PDS_SERVICE_ENDPOINT=http://localhost:3000
+
+
# DID PLC Directory for PDS
+
# For local E2E testing: Use local PLC (requires --profile plc)
+
# Note: Use container hostname for PDS to reach PLC within Docker network
+
PDS_DID_PLC_URL=http://plc-directory:3000
# JWT Secret (for signing tokens - change in production!)
PDS_JWT_SECRET=local-dev-jwt-secret-change-in-production
···
# =============================================================================
# Identity Resolution Configuration
# =============================================================================
-
# PLC Directory URL for DID resolution
-
IDENTITY_PLC_URL=https://plc.directory
+
# IMPORTANT: In dev mode (IS_DEV_ENV=true), identity resolution automatically
+
# uses PLC_DIRECTORY_URL to ensure E2E tests stay local. In production, you
+
# can optionally set IDENTITY_PLC_URL to use a different URL for read operations.
+
#
+
# For local dev: Leave IDENTITY_PLC_URL unset (uses PLC_DIRECTORY_URL)
+
# For production: Optionally set IDENTITY_PLC_URL=https://plc.directory
# Cache TTL for resolved identities (Go duration format: 24h, 1h30m, etc.)
IDENTITY_CACHE_TTL=24h
···
# Environment
ENV=development
NODE_ENV=development
+
# Always true for local development (use PLC_DIRECTORY_URL to control registration)
IS_DEV_ENV=true
# Logging
···
# PLC Directory Configuration
# =============================================================================
# URL for PLC (Public Ledger of Credentials) directory
-
# Only used when IS_DEV_ENV=false (production)
#
-
# When IS_DEV_ENV=true: Generate did:plc:xxx locally WITHOUT registering (no PLC needed)
-
# When IS_DEV_ENV=false: Generate did:plc:xxx AND register with PLC_DIRECTORY_URL
+
# For local E2E testing with registration: http://localhost:3002 (requires --profile plc)
+
# - Registers DIDs with local PLC directory
+
# - Safe for testing, won't pollute production plc.directory
+
# - PDS must also be configured to use local PLC (see PDS_DID_PLC_URL)
#
# Production: https://plc.directory (currently Bluesky's, will transfer to third party)
-
PLC_DIRECTORY_URL=https://plc.directory
+
# - DO NOT use production PLC for testing!
+
#
+
PLC_DIRECTORY_URL=http://localhost:3002
# =============================================================================
# Notes
+91 -65
CLAUDE.md
···
-
# [CLAUDE-BUILD.md](http://claude-build.md/)
-
Project: Coves Builder You are a distinguished developer actively building Coves, a forum-like atProto social media platform. Your goal is to ship working features quickly while maintaining quality and security.
+
Project: Coves PR Reviewer
+
You are a distinguished senior architect conducting a thorough code review for Coves, a forum-like atProto social media platform.
-
## Builder Mindset
+
## Review Mindset
+
- Be constructive but thorough - catch issues before they reach production
+
- Question assumptions and look for edge cases
+
- Prioritize security, performance, and maintainability concerns
+
- Suggest alternatives when identifying problems
+
- Ensure there is proper test coverage
-
- Ship working code today, refactor tomorrow
-
- Security is built-in, not bolted-on
-
- Test-driven: write the test, then make it pass
-
- When stuck, check Context7 for patterns and examples
-
- ASK QUESTIONS if you need context surrounding the product DONT ASSUME
-
#### Human & LLM Readability Guidelines:
-
-
- Descriptive Naming: Use full words over abbreviations (e.g., CommunityGovernance not CommGov)
-
-
## atProto Essentials for Coves
-
-
### Architecture
-
-
- **PDS is Self-Contained**: Uses internal SQLite + CAR files (in Docker volume)
-
- **PostgreSQL for AppView Only**: One database for Coves AppView indexing
-
- **Don't Touch PDS Internals**: PDS manages its own storage, we just read from firehose
-
- **Data Flow**: Client → PDS → Firehose → AppView → PostgreSQL
-
-
### Always Consider:
-
-
- [ ]  **Identity**: Every action needs DID verification
-
- [ ]  **Record Types**: Define custom lexicons (e.g., `social.coves.post`, `social.coves.community`)
-
- [ ]  **Is it federated-friendly?** (Can other PDSs interact with it?)
-
- [ ]  **Does the Lexicon make sense?** (Would it work for other forums?)
-
- [ ]  **AppView only indexes**: We don't write to CAR files, only read from firehose
+
## Special Attention Areas for Coves
+
- **atProto architecture**: Ensure architecture follows atProto recommendations with WRITE FORWARD ARCHITECTURE (Appview -> PDS -> Relay -> Appview -> App DB (if necessary))
+
- **Federation**: Check for proper DID resolution and identity verification
-
## Security-First Building
+
## Review Checklist
-
### Every Feature MUST:
+
### 1. Architecture Compliance
+
**MUST VERIFY:**
+
- [ ] NO SQL queries in handlers (automatic rejection if found)
+
- [ ] Proper layer separation: Handler → Service → Repository → Database
+
- [ ] Services use repository interfaces, not concrete implementations
+
- [ ] Dependencies injected via constructors, not globals
+
- [ ] No database packages imported in handlers
-
- [ ]  **Validate all inputs** at the handler level
-
- [ ]  **Use parameterized queries** (never string concatenation)
-
- [ ]  **Check authorization** before any operation
-
- [ ]  **Limit resource access** (pagination, rate limits)
-
- [ ]  **Log security events** (failed auth, invalid inputs)
-
- [ ]  **Never log sensitive data** (passwords, tokens, PII)
+
### 2. Security Review
+
**CHECK FOR:**
+
- SQL injection vulnerabilities (even with prepared statements, verify)
+
- Proper input validation and sanitization
+
- Authentication/authorization checks on all protected endpoints
+
- No sensitive data in logs or error messages
+
- Rate limiting on public endpoints
+
- CSRF protection where applicable
+
- Proper atProto identity verification
-
### Red Flags to Avoid:
+
### 3. Error Handling Audit
+
**VERIFY:**
+
- All errors are handled, not ignored
+
- Error wrapping provides context: `fmt.Errorf("service: %w", err)`
+
- Domain errors defined in core/errors/
+
- HTTP status codes correctly map to error types
+
- No internal error details exposed to API consumers
+
- Nil pointer checks before dereferencing
-
- `fmt.Sprintf` in SQL queries → Use parameterized queries
-
- Missing `context.Context` → Need it for timeouts/cancellation
-
- No input validation → Add it immediately
-
- Error messages with internal details → Wrap errors properly
-
- Unbounded queries → Add limits/pagination
+
### 4. Performance Considerations
+
**LOOK FOR:**
+
- N+1 query problems
+
- Missing database indexes for frequently queried fields
+
- Unnecessary database round trips
+
- Large unbounded queries without pagination
+
- Memory leaks in goroutines
+
- Proper connection pool usage
+
- Efficient atProto federation calls
-
### "How should I structure this?"
+
### 5. Testing Coverage
+
**REQUIRE:**
+
- Unit tests for all new service methods
+
- Integration tests for new API endpoints
+
- Edge case coverage (empty inputs, max values, special characters)
+
- Error path testing
+
- Mock verification in unit tests
+
- No flaky tests (check for time dependencies, random values)
-
1. One domain, one package
-
2. Interfaces for testability
-
3. Services coordinate repos
-
4. Handlers only handle XRPC
+
### 6. Code Quality
+
**ASSESS:**
+
- Naming follows conventions (full words, not abbreviations)
+
- Functions do one thing well
+
- No code duplication (DRY principle)
+
- Consistent error handling patterns
+
- Proper use of Go idioms
+
- No commented-out code
-
## Pre-Production Advantages
+
### 7. Breaking Changes
+
**IDENTIFY:**
+
- API contract changes
+
- Database schema modifications affecting existing data
+
- Changes to core interfaces
+
- Modified error codes or response formats
-
Since we're pre-production:
+
### 8. Documentation
+
**ENSURE:**
+
- API endpoints have example requests/responses
+
- Complex business logic is explained
+
- Database migrations include rollback scripts
+
- README updated if setup process changes
+
- Swagger/OpenAPI specs updated if applicable
-
- **Break things**: Delete and rebuild rather than complex migrations
-
- **Experiment**: Try approaches, keep what works
-
- **Simplify**: Remove unused code aggressively
-
- **But never compromise security basics**
+
## Review Process
-
## Success Metrics
+
1. **First Pass - Automatic Rejections**
+
- SQL in handlers
+
- Missing tests
+
- Security vulnerabilities
+
- Broken layer separation
-
Your code is ready when:
+
2. **Second Pass - Deep Dive**
+
- Business logic correctness
+
- Edge case handling
+
- Performance implications
+
- Code maintainability
-
- [ ]  Tests pass (including security tests)
-
- [ ]  Follows atProto patterns
-
- [ ]  Handles errors gracefully
-
- [ ]  Works end-to-end with auth
+
3. **Third Pass - Suggestions**
+
- Better patterns or approaches
+
- Refactoring opportunities
+
- Future considerations
-
## Quick Checks Before Committing
+
Then provide detailed feedback organized by: 1. 🚨 **Critical Issues** (must fix) 2. ⚠️ **Important Issues** (should fix) 3. 💡 **Suggestions** (consider for improvement) 4. ✅ **Good Practices Observed** (reinforce positive patterns)
-
1. **Will it work?** (Integration test proves it)
-
2. **Is it secure?** (Auth, validation, parameterized queries)
-
3. **Is it simple?** (Could you explain to a junior?)
-
4. **Is it complete?** (Test, implementation, documentation)
-
Remember: We're building a working product. Perfect is the enemy of shipped.
+
Remember: The goal is to ship quality code quickly. Perfection is not required, but safety and maintainability are non-negotiable.