📋 Overview
This issue outlines the implementation of a modern, scalable hierarchical category system with full multilingual support and comprehensive audit tracking to replace the current simple category structure.
🎯 Objectives
- Hierarchical Categories: Enable parent-child relationships for better content organization
- Multilingual Support: Support multiple languages with dedicated translation tables
- Audit Tracking: Implement comprehensive audit fields for change tracking
- Enhanced Media: Add cover image support for visual category representation
- Scalability: Use
bigint IDs for future-proofing
- Data Integrity: Implement proper constraints and indexes for optimal performance
🏗️ Current vs. Proposed Structure
Current Implementation
public class Category
{
public int Id { get; set; }
public string Name { get; set; }
public string slug { get; set; }
public string Description { get; set; }
public List<Book> Books { get; set; }
}
Proposed Database Schema
Core Categories Table
CREATE TABLE "Categories"
(
"Id" bigserial PRIMARY KEY,
"ParentId" bigint REFERENCES "Categories" ("Id") ON DELETE SET NULL,
"Cover" varchar(255) NOT NULL,
-- Auditing Fields
"CreatedAt" timestamptz NOT NULL DEFAULT now(),
"CreatedBy" bigint NOT NULL,
"UpdatedAt" timestamptz NOT NULL DEFAULT now(),
"UpdatedBy" bigint NULL
);
CREATE INDEX "IdxCategoriesParentId" ON "Categories" ("ParentId");
Multilingual Translations Table
CREATE TABLE "CategoryTranslations"
(
"Id" bigserial PRIMARY KEY,
"CategoryId" bigint NOT NULL REFERENCES "Categories" ("Id") ON DELETE CASCADE,
"LanguageCode" varchar(5) NOT NULL,
"Name" varchar(100) NOT NULL,
"Description" text NOT NULL,
CONSTRAINT "UniqueCategoryLanguage" UNIQUE ("CategoryId", "LanguageCode")
);
CREATE INDEX "IdxCategoryTranslationsCategoryId" ON "CategoryTranslations" ("CategoryId");
CREATE INDEX "IdxCategoryTranslationsLanguageCode" ON "CategoryTranslations" ("LanguageCode");
🚀 Benefits
1. Hierarchical Organization
- Create category trees (e.g., Technology → Programming → Web Development)
- Enable breadcrumb navigation
- Support unlimited nesting levels
- Simplify category management in admin panel
2. True Multilingual Support
- Current: Mixed languages in single fields
- Proposed: Dedicated translations per language
- Seamless language switching without data loss
- Consistent with existing i18n implementation (fa-IR, en-US)
3. Comprehensive Audit Trail
- Track who created/modified categories and when
- Essential for compliance and debugging
- Enables change history and rollback capabilities
4. Enhanced User Experience
- Cover images for visual category representation
- Better SEO with proper hierarchical URLs
- Improved content discovery through category trees
5. Scalability & Performance
bigint IDs support massive scale (9 quintillion records)
- Optimized indexes for fast hierarchy queries
- Efficient language-specific content retrieval
🔧 Implementation Tasks
Phase 1: Database Migration
Phase 2: Entity Models & Configuration
Phase 3: Service Layer Updates
Phase 4: API & Controller Updates
Phase 5: View Models & DTOs
Phase 6: Frontend Integration
Phase 7: Data Migration & Testing
📊 Technical Considerations
Migration Strategy
- Backward Compatibility: Maintain existing functionality during migration
- Data Preservation: Ensure no data loss during schema changes
- Gradual Rollout: Implement feature flags for progressive deployment
Performance Optimization
- Materialized Paths: Consider for deep hierarchies
- Caching Strategy: Implement Redis caching for frequently accessed categories
- Lazy Loading: Optimize Entity Framework queries
Integration Points
- Existing i18n System: Leverage current Persian/English support
- User Management: Connect audit fields to existing
ApplicationUser
- File Management: Integrate with existing image upload system
🎯 Success Criteria
🔍 Future Enhancements
- SEO Optimization: Automatic slug generation from translations
- Category Analytics: Usage statistics and popular categories
- Advanced Permissions: Role-based category management
- Category Templates: Predefined category structures
- Bulk Operations: Mass category operations and migrations
📚 Related Issues
- Internationalization System: Leverages existing multilingual infrastructure
- File Upload System: Requires cover image management integration
- Admin Panel Enhancement: Part of broader admin UI improvements
- Performance Optimization: Supports overall application scalability goals
Priority: High
Complexity: Medium-High
Estimated Effort: 3-4 sprints
Dependencies: Entity Framework, existing i18n system, file upload functionality
📋 Overview
This issue outlines the implementation of a modern, scalable hierarchical category system with full multilingual support and comprehensive audit tracking to replace the current simple category structure.
🎯 Objectives
bigintIDs for future-proofing🏗️ Current vs. Proposed Structure
Current Implementation
Proposed Database Schema
Core Categories Table
Multilingual Translations Table
🚀 Benefits
1. Hierarchical Organization
2. True Multilingual Support
3. Comprehensive Audit Trail
4. Enhanced User Experience
5. Scalability & Performance
bigintIDs support massive scale (9 quintillion records)🔧 Implementation Tasks
Phase 1: Database Migration
Categoriestable with audit fields and hierarchy supportCategoryTranslationstable with proper constraintsBookstablePhase 2: Entity Models & Configuration
Categoryentity modelCategoryTranslationentity modelPhase 3: Service Layer Updates
ICategoryServiceinterface for hierarchy supportCategoryServicewith multilingual methodsPhase 4: API & Controller Updates
ManageCategoryControllerfor hierarchy managementPhase 5: View Models & DTOs
Phase 6: Frontend Integration
Phase 7: Data Migration & Testing
📊 Technical Considerations
Migration Strategy
Performance Optimization
Integration Points
ApplicationUser🎯 Success Criteria
🔍 Future Enhancements
📚 Related Issues
Priority: High
Complexity: Medium-High
Estimated Effort: 3-4 sprints
Dependencies: Entity Framework, existing i18n system, file upload functionality