Commit graph

7 commits

Author SHA1 Message Date
TheFlow
0d75492c60 feat: add API routes, controllers, and migration tools
Implemented complete backend API foundation with authentication, document
management, blog operations, and admin functionality. Added migration tools
for database seeding and document import.

**Controllers (4 files):**
- auth.controller.js: User authentication (login, getCurrentUser, logout)
- documents.controller.js: Document CRUD operations
- blog.controller.js: Blog post management with admin/public access
- admin.controller.js: Admin dashboard (stats, moderation queue, activity)

**Routes (5 files):**
- auth.routes.js: Authentication endpoints
- documents.routes.js: Document API endpoints
- blog.routes.js: Blog API endpoints
- admin.routes.js: Admin API endpoints
- index.js: Central routing configuration with API documentation

**Migration Tools (2 scripts):**
- seed-admin.js: Create admin user for system access
- migrate-documents.js: Import markdown documents with metadata extraction,
  slug generation, and dry-run support. Successfully migrated 8 documents
  from anthropic-submission directory.

**Server Updates:**
- Integrated all API routes under /api namespace
- Updated homepage to reflect completed API implementation
- Maintained security middleware (Helmet, CORS, rate limiting)

**Testing:**
 Server starts successfully on port 9000
 Authentication flow working (login, token validation)
 Document endpoints tested (list, get by slug)
 Admin stats endpoint verified (requires authentication)
 Migration completed: 8 documents imported

**Database Status:**
- Documents collection: 8 technical papers
- Users collection: 1 admin user
- All indexes operational

This completes the core backend API infrastructure. Next steps: build
Tractatus governance services (InstructionClassifier, CrossReferenceValidator,
BoundaryEnforcer).

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-07 00:36:40 +13:00
TheFlow
067012ad24 docs: add session handoff documentation
- Create SESSION_CLOSEDOWN_20251006.md with complete session summary
- Create NEXT_SESSION.md with startup verification guide
- Document all 10 completed tasks and 11 pending tasks
- Include verification checklist and troubleshooting guide
- Provide three options for next development phase

Status: Foundation complete, ready for API routes
2025-10-07 00:10:24 +13:00
TheFlow
6285adc572 feat: add Express server foundation with middleware
Configuration:
- app.config.js: Centralized configuration (ports, MongoDB, JWT, features)
- Feature flags for AI curation, media triage, case submissions

Middleware:
- auth.middleware.js: JWT authentication, role-based access control
- validation.middleware.js: Input validation, sanitization, ObjectId checks
- error.middleware.js: Global error handling, async wrapper, 404 handler

Express Server (src/server.js):
- Security: Helmet, CORS, rate limiting
- Request logging with Winston
- Health check endpoint
- MongoDB connection with graceful shutdown
- Static file serving
- Temporary homepage showing development status

Features:
- Production-ready error handling
- MongoDB duplicate key detection
- JWT token validation
- XSS protection via sanitization
- Rate limiting (100 req / 15min per IP)
- Graceful shutdown (SIGTERM/SIGINT)

Status: Server foundation complete, ready for API routes
Port: 9000
Database: tractatus_dev (MongoDB 27017)
2025-10-06 23:56:12 +13:00
TheFlow
78ab5754f2 feat: add MongoDB models for core collections
Models Created (7/10):
- Document.model.js: Framework docs with quadrant classification
- BlogPost.model.js: AI-curated blog with moderation
- MediaInquiry.model.js: Press/media triage workflow
- ModerationQueue.model.js: Human oversight queue with priority
- User.model.js: Admin authentication with bcrypt
- CaseSubmission.model.js: Community case studies with AI review
- Resource.model.js: Curated directory with alignment scores

Features:
- Full CRUD operations for each model
- Tractatus quadrant integration
- AI analysis fields for curation
- Human approval workflows
- Status tracking and filtering
- Security (password hashing, sanitized returns)

Deferred (Phase 2-3):
- Citation.model.js
- Translation.model.js
- KohaDonation.model.js

Status: Core models complete, ready for Express server
2025-10-06 23:54:56 +13:00
TheFlow
47818bade1 feat: add governance document and core utilities
Core Values (TRA-VAL-0001):
- Adapt STR-VAL-0001 for Tractatus AI Safety Framework
- Define 6 core values: Sovereignty, Transparency, Harmlessness,
  Human Judgment Primacy, Community, Biodiversity
- Establish AI governance principles and decision framework
- Document Te Tiriti commitment as strategic baseline
- Create values alignment metrics and review process

Database Utilities:
- MongoDB connection with retry logic and health checks
- Singleton pattern for connection management
- Comprehensive error handling and reconnection

Logger Utility:
- Winston-based logging (console + file)
- Request logging middleware
- Error log separation
- Configurable log levels

JWT Utility:
- Token generation and verification
- Secure admin authentication
- Header extraction methods

Markdown Utility:
- Markdown to HTML conversion with syntax highlighting
- XSS protection via sanitization
- Table of contents extraction
- Front matter parsing
- Slug generation

Status: Core infrastructure utilities complete
2025-10-06 23:34:40 +13:00
TheFlow
4f8de209f3 feat: add MongoDB systemd service and database initialization
- Create mongodb-tractatus.service for systemd management
- Add installation script for service setup
- Create init-db.js with complete collection schemas and indexes
- Configure 10 MongoDB collections: documents, blog_posts, media_inquiries,
  case_submissions, resources, moderation_queue, users, citations,
  translations, koha_donations
- Add indexes for performance optimization
- Include verification and statistics output

MongoDB Port: 27017
Database: tractatus_dev
Status: Ready for service installation
2025-10-06 23:28:42 +13:00
TheFlow
4445b0e8d0 feat: initialize tractatus project with complete directory structure
- Create comprehensive project structure (29 directories)
- Add CLAUDE.md with project context and conventions
- Add package.json with dependencies and scripts
- Add .gitignore and .env.example
- Add README.md with project overview
- Configure ports: MongoDB 27017, Application 9000
- Establish Tractatus governance framework baseline
- Document Te Tiriti approach and indigenous perspective
- Set up infrastructure for Phase 1 implementation

Project Status: Development - Phase 1 Foundation Complete
Next: MongoDB instance setup and systemd service configuration
2025-10-06 23:26:26 +13:00