mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 11:11:10 -05:00
Refactor authentication settings and enhance frontend moderation panel with performance optimizations, loading states, error handling, mobile responsiveness, and accessibility improvements
This commit is contained in:
165
memory-bank/systemPatterns.md
Normal file
165
memory-bank/systemPatterns.md
Normal file
@@ -0,0 +1,165 @@
|
||||
# System Patterns
|
||||
|
||||
## Architectural Patterns
|
||||
|
||||
### MVT Implementation
|
||||
1. Models
|
||||
- Use abstract base classes for common fields
|
||||
- Implement custom model managers for complex queries
|
||||
- Define clear relationships and constraints
|
||||
- Include field-level validation
|
||||
|
||||
2. Views
|
||||
- Prefer class-based views
|
||||
- Use mixins for shared functionality
|
||||
- Implement proper permission checks
|
||||
- Handle HTMX requests explicitly
|
||||
|
||||
3. Templates
|
||||
- Maintain hierarchy with base templates
|
||||
- Use partial templates for HTMX responses
|
||||
- Implement component-based structure
|
||||
- Follow progressive enhancement
|
||||
|
||||
## Design Patterns
|
||||
|
||||
### Data Access
|
||||
1. Query Patterns
|
||||
- Use select_related() for foreign keys
|
||||
- Implement prefetch_related() for reverse relationships
|
||||
- Create custom model managers
|
||||
- Optimize database queries
|
||||
|
||||
2. Caching Strategy
|
||||
- Cache template fragments
|
||||
- Implement model-level caching
|
||||
- Use Redis for session storage
|
||||
- Cache invalidation rules
|
||||
|
||||
### Frontend Patterns
|
||||
|
||||
1. HTMX Integration
|
||||
```html
|
||||
<!-- Partial Update Pattern -->
|
||||
<div hx-get="/endpoint"
|
||||
hx-trigger="event"
|
||||
hx-target="#target">
|
||||
```
|
||||
|
||||
2. AlpineJS Components
|
||||
```html
|
||||
<!-- State Management Pattern -->
|
||||
<div x-data="{ state: {} }"
|
||||
x-init="state = await fetchData()">
|
||||
```
|
||||
|
||||
3. Tailwind Components
|
||||
```html
|
||||
<!-- Component Structure -->
|
||||
<div class="component-wrapper">
|
||||
<div class="component-header"></div>
|
||||
<div class="component-content"></div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## Authentication Patterns
|
||||
|
||||
### User Management
|
||||
1. Custom User Model
|
||||
- Extended user profiles
|
||||
- Role-based permissions
|
||||
- Activity tracking
|
||||
- Profile customization
|
||||
|
||||
2. Authentication Flow
|
||||
- Login/registration process
|
||||
- Password reset workflow
|
||||
- Email verification
|
||||
- Session management
|
||||
|
||||
## Content Management
|
||||
|
||||
### Moderation Flow
|
||||
1. Submission Process
|
||||
- Content validation
|
||||
- Automatic checks
|
||||
- Manual review queue
|
||||
- Approval workflow
|
||||
|
||||
2. Review System
|
||||
- Rating framework
|
||||
- Media handling
|
||||
- User verification
|
||||
- Content filtering
|
||||
|
||||
## Error Handling
|
||||
|
||||
### Backend Errors
|
||||
1. Exception Handling
|
||||
```python
|
||||
try:
|
||||
# Operation
|
||||
except SpecificException as e:
|
||||
# Specific handling
|
||||
except Exception as e:
|
||||
# Generic handling
|
||||
```
|
||||
|
||||
2. Response Patterns
|
||||
```python
|
||||
# Success Response
|
||||
return JsonResponse({'status': 'success', 'data': data})
|
||||
|
||||
# Error Response
|
||||
return JsonResponse({'status': 'error', 'message': str(e)})
|
||||
```
|
||||
|
||||
### Frontend Errors
|
||||
1. User Feedback
|
||||
- Toast notifications
|
||||
- Inline validation
|
||||
- Form feedback
|
||||
- Error states
|
||||
|
||||
## Testing Patterns
|
||||
|
||||
### Unit Tests
|
||||
```python
|
||||
class ModelTests(TestCase):
|
||||
def setUp(self):
|
||||
# Test setup
|
||||
|
||||
def test_specific_functionality(self):
|
||||
# Test implementation
|
||||
```
|
||||
|
||||
### Integration Tests
|
||||
```python
|
||||
class ViewTests(TestCase):
|
||||
def setUp(self):
|
||||
self.client = Client()
|
||||
|
||||
def test_view_functionality(self):
|
||||
# Test implementation
|
||||
```
|
||||
|
||||
## Development Workflows
|
||||
|
||||
### Feature Development
|
||||
1. Planning
|
||||
- Technical specification
|
||||
- Component design
|
||||
- Database schema
|
||||
- API endpoints
|
||||
|
||||
2. Implementation
|
||||
- Model creation
|
||||
- View implementation
|
||||
- Template design
|
||||
- Testing coverage
|
||||
|
||||
3. Review Process
|
||||
- Code review
|
||||
- Testing verification
|
||||
- Documentation update
|
||||
- Deployment planning
|
||||
Reference in New Issue
Block a user