- type
- summary
- created
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- updated
- Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
- sources
- raw/notes/codeGuidelines
- tags
- code-guidelines angular django testing git naming-conventions
Code Guidelines Summary
abstract
Coding standards for B2BPaper covering Angular frontend conventions (standalone/OnPush/Tailwind/Reactive Forms), Django backend rules (explicit serializers, service layer, PostgreSQL-only), naming conventions, git branching strategy, and testing requirements.
Angular Frontend Rules
Component Architecture
- Standalone components with
OnPush change detection and ViewEncapsulation.None
- Reactive Forms exclusively -- never template-driven forms
- Tailwind CSS exclusively -- custom SCSS only when Tailwind cannot handle it
- ApexCharts for visualization -- never Highcharts
- Feature-based project structure (not type-based)
- Separate
.html files -- never inline templates
- Never use
any -- use proper types or unknown
- Barrel exports (
index.ts) per feature folder
State Management
BehaviorSubject in services, exposed via .asObservable()
takeUntil + _destroy$ pattern for subscription cleanup
take(1) for one-off subscriptions
Naming Conventions
| Type |
Convention |
Example |
| Files |
kebab-case |
surplus-list.component.ts |
| Classes |
PascalCase |
SurplusListComponent |
| Interfaces |
PascalCase, no I prefix |
SurplusItem |
| Observables |
$ suffix |
surplus$ |
| Private members |
_ prefix |
_surplusSubject |
Critical Rules
Django Backend Rules
API Architecture
- ModelSerializer with explicit
fields -- never '__all__'
- ViewSets or GenericAPIView for CRUD operations
- Custom permissions for business logic authorization
- django-filter for query filtering
- drf-spectacular for API documentation
- 12-factor app -- environment variables for all configuration
- Google-style docstrings (Args/Returns/Raises)
select_related / prefetch_related to avoid N+1 queries
- Business logic in
services.py, not in views or serializers (see wiki/concepts/service-layer-pattern)
Naming Conventions
| Type |
Convention |
Example |
| Files |
lowercase_underscores |
surplus_views.py |
| Classes |
CamelCase |
SurplusItemSerializer |
| Functions |
lowercase_underscores |
get_surplus_by_mill() |
| Constants |
UPPER_SNAKE_CASE |
MAX_CONTAINER_WEIGHT_KG |
| URLs |
kebab-case |
/api/surplus-items/ |
Critical Rules
- PostgreSQL always -- never SQLite or MySQL
- NEVER run
python manage.py runserver -- use python manage.py check to verify
- See wiki/concepts/django-app-layout for app organization
Git Workflow
Branching Strategy
- Feature branches:
feature/<short-description> (e.g., feature/surplus-matching)
- Bug fix branches:
fix/<short-description> (e.g., fix/container-weight-calc)
- Main branch:
main (protected)
- Develop branch:
develop (integration)
Commit Messages
- Descriptive and imperative mood: "Add surplus item filtering by GSM range"
- Reference issue numbers when applicable
- Subject line under 72 characters
Testing Standards
- Frontend: Jasmine/Karma for unit tests, Cypress for E2E
- Backend: Django
TestCase for models, APITestCase for APIs
- Write tests for all new code
- Aim for TDD where practical
- Service tests in
tests/test_services/, API tests in tests/test_api/
Code Review Process
- All code goes through PR review
- At least one approval before merge
- Address all review comments
Sources
Related