diff --git a/.cursorrules b/.cursorrules new file mode 100644 index 00000000..48593f2f --- /dev/null +++ b/.cursorrules @@ -0,0 +1,329 @@ +# IGNY8 Development Rules +# ======================== +# These rules MUST be followed for all code changes. +# Version: 1.8.4 | Last Updated: January 20, 2026 + +## 📋 MANDATORY CHECKLIST (Every Change) + +Before submitting ANY code change: + +1. [ ] Documentation updated (if behavior changed) +2. [ ] CHANGELOG.md updated (if user-facing) +3. [ ] Design guide followed (frontend changes) +4. [ ] Types/interfaces match API responses +5. [ ] No hardcoded values (use constants/settings) + +--- + +## 🗂️ Project Structure + +``` +/ +├── INDEX.md # Start here +├── DESIGN-GUIDE.md # UI/UX standards (MANDATORY) +├── CHANGELOG.md # All notable changes +├── README.md # Setup & overview +├── docs/ # Detailed documentation +│ ├── 00-SYSTEM/ # Architecture & core concepts +│ ├── 10-MODULES/ # Business logic modules +│ ├── 20-API/ # API endpoints +│ ├── 30-FRONTEND/ # React components & stores +│ ├── 40-WORKFLOWS/ # Business processes +│ ├── 50-DEPLOYMENT/ # DevOps & infrastructure +│ ├── 60-PLUGINS/ # Plugin system +│ └── 90-REFERENCE/ # Models, enums, glossary +├── backend/ # Django app +└── frontend/ # React app +``` + +--- + +## 📝 Documentation Rules + +### When to Update Docs + +| Change Type | Update Required | +|-------------|-----------------| +| New API endpoint | `docs/20-API/ENDPOINTS.md` | +| New model | `docs/90-REFERENCE/MODELS.md` | +| New route/page | `docs/30-FRONTEND/PAGES.md` | +| New store | `docs/30-FRONTEND/STORES.md` | +| UI component | `docs/30-FRONTEND/COMPONENT-SYSTEM.md` | +| Settings change | `docs/00-SYSTEM/ARCHITECTURE.md` | +| New module | `docs/10-MODULES/.md` | +| New Celery task | Document in module's backend docs | + +### Documentation Standards + +```markdown +# Document Title + +> Brief one-line description + +**Version:** X.Y.Z +**Last Updated:** YYYY-MM-DD + +## Section 1 +Content... + +## Section 2 +Content... +``` + +--- + +## 🎨 Frontend Rules + +### MUST Follow Design Guide + +All frontend code MUST adhere to `DESIGN-GUIDE.md`: + +1. **Components**: Use our component library, NEVER raw HTML +2. **Colors**: Only semantic colors (brand, success, warning, error, purple, gray) +3. **Icons**: Import from central `icons/` directory only +4. **Forms**: Use standardized form components + +### File Organization + +``` +src/ +├── components/ +│ ├── ui/ # Reusable UI components +│ ├── form/ # Form-specific components +│ ├── layout/ # Layout components +│ └── [module]/ # Module-specific components +├── pages/ # Route pages +├── stores/ # Zustand stores +├── services/ # API service functions +├── hooks/ # Custom React hooks +├── types/ # TypeScript type definitions +└── utils/ # Utility functions +``` + +### TypeScript Standards + +```typescript +// ✅ CORRECT: Use interfaces for API responses +interface Site { + id: string; + name: string; + domain: string; +} + +// ✅ CORRECT: Type all props +interface ComponentProps { + title: string; + onClose: () => void; + children?: React.ReactNode; +} + +// ❌ WRONG: No any types +const data: any = response; +``` + +--- + +## 🐍 Backend Rules + +### Django/DRF Standards + +1. **Serializers**: Must match model fields exactly +2. **Views**: Use DRF ViewSets where possible +3. **URLs**: Follow RESTful conventions +4. **Models**: Document all fields with help_text + +### Serializer Field Validation + +```python +# ✅ CORRECT: Fields match model +class SettingsSerializer(serializers.ModelSerializer): + class Meta: + model = Settings + fields = ['id', 'key', 'value'] # 'value' exists on model + +# ❌ WRONG: Field doesn't exist on model +class SettingsSerializer(serializers.ModelSerializer): + config = serializers.JSONField() # 'config' doesn't exist! + class Meta: + model = Settings + fields = ['id', 'key', 'config'] +``` + +### API Response Format + +```python +# Standard success response +{ + "data": { ... }, + "message": "Operation successful" +} + +# Standard error response +{ + "error": "Error message", + "details": { ... } +} + +# Paginated response +{ + "count": 100, + "next": "http://...", + "previous": null, + "results": [ ... ] +} +``` + +--- + +## 📊 CHANGELOG Rules + +### When to Update + +- New features (user-visible) +- Bug fixes (user-affecting) +- API changes +- Breaking changes +- Performance improvements + +### Format + +```markdown +## [1.8.4] - 2026-01-21 + +### Added +- New feature description + +### Changed +- Changed behavior description + +### Fixed +- Bug fix description + +### Deprecated +- Deprecated feature warning + +### Removed +- Removed feature notice + +### Security +- Security fix description +``` + +--- + +## ✅ Code Review Checklist + +### Before Creating PR + +- [ ] Code compiles/runs without errors +- [ ] All tests pass +- [ ] No console.log or print statements (unless intentional) +- [ ] Documentation updated +- [ ] CHANGELOG updated (if applicable) +- [ ] No hardcoded secrets/URLs +- [ ] Follows design guide (frontend) +- [ ] Serializers match models (backend) + +### Review Focus Areas + +1. **Logic**: Does the code do what it's supposed to? +2. **Types**: Are TypeScript types correct and complete? +3. **Security**: Any security concerns? +4. **Performance**: Any obvious performance issues? +5. **Consistency**: Follows existing patterns? + +--- + +## 🔧 Development Workflow + +### Making Changes + +1. Understand the context (read relevant docs first) +2. Make the change +3. Update documentation +4. Update CHANGELOG (if user-facing) +5. Test thoroughly +6. Submit for review + +### Adding New Features + +1. Document the feature design first +2. Implement backend (if needed) +3. Update API docs +4. Implement frontend +5. Update frontend docs +6. Add to CHANGELOG + +--- + +## 🚨 Common Mistakes to Avoid + +### Frontend + +- Using raw HTML instead of components +- Using default Tailwind colors +- Importing icons from wrong source +- Not typing API responses +- Hardcoding API URLs + +### Backend + +- Serializer fields not matching models +- Missing model validations +- Not handling edge cases in views +- Forgetting to add URLs to router + +### Documentation + +- Not updating docs after changes +- Outdated version numbers +- Missing new endpoints/pages +- Inconsistent formatting + +--- + +## 📚 Key Documentation Files + +| Purpose | Location | +|---------|----------| +| Quick start | `/INDEX.md` | +| UI standards | `/DESIGN-GUIDE.md` | +| Change history | `/CHANGELOG.md` | +| Architecture | `/docs/00-SYSTEM/ARCHITECTURE.md` | +| API reference | `/docs/20-API/ENDPOINTS.md` | +| Data models | `/docs/90-REFERENCE/MODELS.md` | +| Frontend routes | `/docs/30-FRONTEND/PAGES.md` | +| State stores | `/docs/30-FRONTEND/STORES.md` | +| Components | `/docs/30-FRONTEND/COMPONENT-SYSTEM.md` | + +--- + +## 🔄 Maintenance Scripts + +### Verify Documentation Accuracy + +```bash +./scripts/verify-docs.sh +``` + +### Update API Schema + +```bash +cd backend && python manage.py spectacular --file schema.yml +``` + +### Check for Unused Code + +```bash +cd frontend && npm run lint +``` + +--- + +## Version Info + +- **App Version:** 1.8.3 +- **Backend:** Django 5.1, DRF 3.15 +- **Frontend:** React 19, TypeScript 5 +- **Database:** PostgreSQL 16 +- **Cache:** Redis 7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d5d37eb..ee33be22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # IGNY8 Change Log -**Current Version:** 1.8.3 +**Current Version:** 1.8.4 **Last Updated:** January 20, 2026 --- @@ -9,6 +9,7 @@ | Version | Date | Summary | |---------|------|---------| +| 1.8.4 | Jan 20, 2026 | **Documentation Accuracy & Launch Prep** - Fixed API docs (Swagger/ReDoc), serializer field mismatches resolved, comprehensive docs audit, root-level INDEX.md + DESIGN-GUIDE.md + .cursorrules created | | 1.8.3 | Jan 20, 2026 | **Billing System Standardization** - Two-pool credit system (plan + bonus), industry-standard renewal workflow (no advance notice for Stripe/PayPal), simplified bank transfer flow (3 emails), Payment Logs in admin, WebhookEvent logging for all payment types | | 1.8.2 | Jan 19, 2026 | **Keywords Library Redesign & Sector Filtering** - Complete Keywords Library page overhaul with sector metric cards, Smart Suggestions, cascading filters, sector-specific keyword filtering, UI/UX improvements, and backend sector_ids parameter support | | 1.8.1 | Jan 18, 2026 | **Automation Scheduling Overhaul** - Hourly scheduling (replaces 15-min windows), DefaultAutomationConfig singleton for centralized defaults, test mode for admin testing, Reset button fetches from backend, new migrations 0009-0012 | @@ -50,6 +51,65 @@ --- +## v1.8.4 - January 20, 2026 + +### Documentation Accuracy & Launch Preparation + +This release focuses on ensuring 100% documentation accuracy and establishing maintainability standards for launch. + +--- + +### 🔧 API Documentation Fixes + +**Problem Resolved:** +- Swagger UI (`/api/docs/`) and ReDoc (`/api/redoc/`) were returning 500 errors +- Root cause: Serializer field mismatches in `settings_serializers.py` + +**Fixes Applied:** +- `AccountSettingsSerializer`: Changed `config` → `value` to match model +- `ModuleSettingsSerializer`: Removed non-existent `config` field + +**Verified:** +- Schema endpoint returns valid OpenAPI YAML +- Both documentation UIs now accessible + +--- + +### 📚 Root-Level Documentation + +**New Files Created:** +| File | Purpose | +|------|---------| +| `/INDEX.md` | Quick-start documentation index | +| `/DESIGN-GUIDE.md` | Mandatory UI/UX standards | +| `/.cursorrules` | Development rules & standards | + +--- + +### 📊 Documentation Audit Results + +**Codebase Metrics Verified:** +- Routes: 100 (documented in PAGES.md) +- Models: 52+ (documented in MODELS.md) +- Zustand Stores: 11 (documented in STORES.md) +- Celery Tasks: 25+ (documented per module) + +**Files Cleaned:** +- `docs/30-FRONTEND/PAGES.md`: Removed duplicate content, rebuilt from scratch + +--- + +### 📋 Maintainability Standards + +**New .cursorrules establishes:** +1. Mandatory documentation updates for code changes +2. CHANGELOG updates for user-facing changes +3. Design guide compliance for frontend +4. Serializer-model field validation +5. Code review checklist + +--- + ## v1.8.3 - January 20, 2026 ### Billing System Standardization & Two-Pool Credit System diff --git a/DESIGN-GUIDE.md b/DESIGN-GUIDE.md new file mode 100644 index 00000000..098db120 --- /dev/null +++ b/DESIGN-GUIDE.md @@ -0,0 +1,311 @@ +# IGNY8 Design Guide + +> **🔒 MANDATORY** - All frontend code MUST follow these standards +> **Version:** 1.8.3 +> **Last Updated:** January 20, 2026 + +--- + +## Quick Reference + +| Need | Use | Import From | +|------|-----|-------------| +| Button | ` + +