ntc-dev-kit 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ntc/__init__.py +5 -0
- ntc/app_creator.py +296 -0
- ntc/cli.py +4 -0
- ntc/cli_enhanced.py +820 -0
- ntc/composer/__init__.py +0 -0
- ntc/composer/main.py +443 -0
- ntc/deployment/__init__.py +0 -0
- ntc/templates/__init__.py +2 -0
- ntc/templates/auth_app/__init__.py +0 -0
- ntc/templates/auth_app/admin.py +24 -0
- ntc/templates/auth_app/apps.py +6 -0
- ntc/templates/auth_app/models.py +30 -0
- ntc/templates/auth_app/serializers.py +101 -0
- ntc/templates/auth_app/urls.py +19 -0
- ntc/templates/auth_app/views.py +175 -0
- ntc/templates/drf_structure/__init__.py +1 -0
- ntc/templates/drf_structure/drf_structure.md +83 -0
- ntc/templates/drf_structure/main.py +389 -0
- ntc/templates/drf_structure/structure.json +126 -0
- ntc/templates/drf_structure/templates/.entry/start_core_backend.sh +37 -0
- ntc/templates/drf_structure/templates/.entry/start_tasks_backend.sh +30 -0
- ntc/templates/drf_structure/templates/CLAUDE.md +194 -0
- ntc/templates/drf_structure/templates/README.md +117 -0
- ntc/templates/drf_structure/templates/apps/app_admin.py +3 -0
- ntc/templates/drf_structure/templates/apps/app_apps.py +6 -0
- ntc/templates/drf_structure/templates/apps/app_models.py +4 -0
- ntc/templates/drf_structure/templates/apps/app_urls.py +8 -0
- ntc/templates/drf_structure/templates/apps/app_views.py +6 -0
- ntc/templates/drf_structure/templates/apps/common_apps.py +6 -0
- ntc/templates/drf_structure/templates/apps/common_models.py +8 -0
- ntc/templates/drf_structure/templates/config/gunicorn_config.py +9 -0
- ntc/templates/drf_structure/templates/config/http.conf +33 -0
- ntc/templates/drf_structure/templates/core/base_model.py +9 -0
- ntc/templates/drf_structure/templates/core/formatter.py +5 -0
- ntc/templates/drf_structure/templates/core/logger.py +8 -0
- ntc/templates/drf_structure/templates/core/pagination.py +6 -0
- ntc/templates/drf_structure/templates/core/response_wrapper.py +7 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/backend.py +108 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/client.py +296 -0
- ntc/templates/drf_structure/templates/core/services/azure/email/notifier.py +102 -0
- ntc/templates/drf_structure/templates/core/services/object_storage.py +285 -0
- ntc/templates/drf_structure/templates/django_project/asgi.py +5 -0
- ntc/templates/drf_structure/templates/django_project/celery.py +8 -0
- ntc/templates/drf_structure/templates/django_project/dev_settings.py +2 -0
- ntc/templates/drf_structure/templates/django_project/django_settings.txt +322 -0
- ntc/templates/drf_structure/templates/django_project/management_command.py +114 -0
- ntc/templates/drf_structure/templates/django_project/prod_settings.py +3 -0
- ntc/templates/drf_structure/templates/django_project/schema.py +7 -0
- ntc/templates/drf_structure/templates/django_project/urls.py +6 -0
- ntc/templates/drf_structure/templates/django_project/wsgi.py +5 -0
- ntc/templates/drf_structure/templates/docker/docker-compose.yml +11 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_description.md +201 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_design_pattern.md +722 -0
- ntc/templates/drf_structure/templates/knowledge/knowledge_structure.md +151 -0
- ntc/templates/drf_structure/templates/root/README.md +307 -0
- ntc/templates/drf_structure/templates/root/django_env.txt +98 -0
- ntc/templates/drf_structure/templates/root/django_requirements.txt +24 -0
- ntc/templates/drf_structure/templates/root/gitignore.txt +6 -0
- ntc/templates/drf_structure/templates/root/manage.py +11 -0
- ntc/templates/flutter/.gitignore +44 -0
- ntc/templates/flutter/.knowledge/knowledge_description.md +215 -0
- ntc/templates/flutter/.knowledge/knowledge_design_pattern.md +310 -0
- ntc/templates/flutter/.knowledge/knowledge_structure.md +83 -0
- ntc/templates/flutter/CLAUDE.md +190 -0
- ntc/templates/flutter/__init__.py +0 -0
- ntc/templates/flutter/analysis_options.yaml +9 -0
- ntc/templates/flutter/main.py +187 -0
- ntc/templates/flutter/pubspec.yaml +65 -0
- ntc/templates/flutter/structure.json +51 -0
- ntc/templates/nextjs/.env.example +10 -0
- ntc/templates/nextjs/.gitignore +36 -0
- ntc/templates/nextjs/CLAUDE.md +181 -0
- ntc/templates/nextjs/README.md +94 -0
- ntc/templates/nextjs/__init__.py +0 -0
- ntc/templates/nextjs/knowledge/knowledge_description.md +208 -0
- ntc/templates/nextjs/knowledge/knowledge_design_pattern.md +460 -0
- ntc/templates/nextjs/knowledge/knowledge_structure.md +75 -0
- ntc/templates/nextjs/main.py +224 -0
- ntc/templates/nextjs/package.json +25 -0
- ntc/templates/nextjs/src/app/globals.css +26 -0
- ntc/templates/nextjs/src/app/layout.tsx +59 -0
- ntc/templates/nextjs/src/app/page.tsx +21 -0
- ntc/templates/nextjs/src/components/Header.tsx +16 -0
- ntc/templates/nextjs/src/services/api.ts +81 -0
- ntc/templates/nextjs/src/utils/constants.ts +1 -0
- ntc/templates/nextjs/structure.json +32 -0
- ntc/templates/nextjs/tsconfig.json +27 -0
- ntc/templates/react_admin/.env.example +1 -0
- ntc/templates/react_admin/.gitignore +10 -0
- ntc/templates/react_admin/CLAUDE.md +210 -0
- ntc/templates/react_admin/README.md +72 -0
- ntc/templates/react_admin/__init__.py +0 -0
- ntc/templates/react_admin/index.html +13 -0
- ntc/templates/react_admin/knowledge/knowledge_description.md +202 -0
- ntc/templates/react_admin/knowledge/knowledge_design_pattern.md +448 -0
- ntc/templates/react_admin/knowledge/knowledge_structure.md +97 -0
- ntc/templates/react_admin/main.py +208 -0
- ntc/templates/react_admin/package.json +35 -0
- ntc/templates/react_admin/src/App.tsx +60 -0
- ntc/templates/react_admin/src/components/ProtectedRoute.tsx +16 -0
- ntc/templates/react_admin/src/components/Sidebar.tsx +90 -0
- ntc/templates/react_admin/src/components/TopNav.tsx +44 -0
- ntc/templates/react_admin/src/context/AuthContext.tsx +107 -0
- ntc/templates/react_admin/src/context/ThemeContext.tsx +34 -0
- ntc/templates/react_admin/src/context/WorkspaceContext.tsx +28 -0
- ntc/templates/react_admin/src/hooks/useApi.ts +39 -0
- ntc/templates/react_admin/src/index.css +34 -0
- ntc/templates/react_admin/src/layouts/AuthLayout.tsx +23 -0
- ntc/templates/react_admin/src/layouts/DashboardLayout.tsx +24 -0
- ntc/templates/react_admin/src/main.tsx +5 -0
- ntc/templates/react_admin/src/pages/DashboardPage.tsx +10 -0
- ntc/templates/react_admin/src/pages/auth/LoginPage.tsx +79 -0
- ntc/templates/react_admin/src/pages/auth/RegisterPage.tsx +93 -0
- ntc/templates/react_admin/src/services/api.service.ts +44 -0
- ntc/templates/react_admin/src/services/base.service.ts +193 -0
- ntc/templates/react_admin/structure.json +52 -0
- ntc/templates/react_admin/tsconfig.app.json +25 -0
- ntc/templates/react_admin/tsconfig.json +7 -0
- ntc/templates/react_admin/tsconfig.node.json +19 -0
- ntc/templates/react_admin/vite.config.ts +13 -0
- ntc/templates/react_structure/CLAUDE.md +176 -0
- ntc/templates/react_structure/__init__.py +1 -0
- ntc/templates/react_structure/index.css +21 -0
- ntc/templates/react_structure/index.html +13 -0
- ntc/templates/react_structure/knowledge/knowledge_description.md +170 -0
- ntc/templates/react_structure/knowledge/knowledge_design_pattern.md +411 -0
- ntc/templates/react_structure/knowledge/knowledge_structure.md +74 -0
- ntc/templates/react_structure/main.py +217 -0
- ntc/templates/react_structure/package.json +32 -0
- ntc/templates/react_structure/src/App.tsx +63 -0
- ntc/templates/react_structure/src/components/Header.tsx +51 -0
- ntc/templates/react_structure/src/main.tsx +5 -0
- ntc/templates/react_structure/src/services/api.ts +90 -0
- ntc/templates/react_structure/src/utils/constants.ts +1 -0
- ntc/templates/react_structure/structure.json +65 -0
- ntc/templates/react_structure/tsconfig.app.json +25 -0
- ntc/templates/react_structure/tsconfig.json +7 -0
- ntc/templates/react_structure/tsconfig.node.json +19 -0
- ntc/templates/react_structure/vite.config.ts +12 -0
- ntc/utils/__init__.py +1 -0
- ntc/utils/environment.py +67 -0
- ntc/utils/output.py +41 -0
- ntc_dev_kit-1.0.0.dist-info/METADATA +188 -0
- ntc_dev_kit-1.0.0.dist-info/RECORD +148 -0
- ntc_dev_kit-1.0.0.dist-info/WHEEL +5 -0
- ntc_dev_kit-1.0.0.dist-info/entry_points.txt +2 -0
- ntc_dev_kit-1.0.0.dist-info/licenses/LICENSE +21 -0
- ntc_dev_kit-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from django.core.management.base import BaseCommand
|
|
3
|
+
from django.core.management import execute_from_command_line
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Command(BaseCommand):
|
|
7
|
+
help = 'Create a new app with NTC structure'
|
|
8
|
+
|
|
9
|
+
def add_arguments(self, parser):
|
|
10
|
+
parser.add_argument('app_name', type=str, help='Name of the app to create')
|
|
11
|
+
|
|
12
|
+
def handle(self, *args, **options):
|
|
13
|
+
app_name = options['app_name']
|
|
14
|
+
|
|
15
|
+
# Sanitize app name (remove domain extensions, replace dots with underscores)
|
|
16
|
+
app_name = self.sanitize_name(app_name)
|
|
17
|
+
|
|
18
|
+
self.stdout.write(f'Creating app: {app_name}')
|
|
19
|
+
|
|
20
|
+
# Create the app directory structure
|
|
21
|
+
self.create_app_structure(app_name)
|
|
22
|
+
|
|
23
|
+
self.stdout.write(
|
|
24
|
+
self.style.SUCCESS(f'Successfully created app "{app_name}"')
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
def sanitize_name(self, name):
|
|
28
|
+
"""Sanitize project/app name by removing TLD and replacing dots with underscores."""
|
|
29
|
+
# Common TLDs to remove
|
|
30
|
+
tlds = ['.com', '.org', '.net', '.io', '.co', '.app', '.dev', '.tech', '.ai']
|
|
31
|
+
|
|
32
|
+
# Remove TLD if present
|
|
33
|
+
for tld in tlds:
|
|
34
|
+
if name.lower().endswith(tld):
|
|
35
|
+
name = name[:-len(tld)]
|
|
36
|
+
break
|
|
37
|
+
|
|
38
|
+
# Replace dots with underscores
|
|
39
|
+
name = name.replace('.', '_')
|
|
40
|
+
|
|
41
|
+
# Remove any other invalid characters and ensure it starts with a letter
|
|
42
|
+
import re
|
|
43
|
+
name = re.sub(r'[^a-zA-Z0-9_]', '_', name)
|
|
44
|
+
if name and name[0].isdigit():
|
|
45
|
+
name = 'app_' + name
|
|
46
|
+
|
|
47
|
+
return name.lower()
|
|
48
|
+
|
|
49
|
+
def create_app_structure(self, app_name):
|
|
50
|
+
"""Create the app directory structure."""
|
|
51
|
+
base_path = os.path.join('apps', app_name)
|
|
52
|
+
|
|
53
|
+
# Create directories
|
|
54
|
+
directories = [
|
|
55
|
+
base_path,
|
|
56
|
+
os.path.join(base_path, 'permissions'),
|
|
57
|
+
os.path.join(base_path, 'serializers'),
|
|
58
|
+
os.path.join(base_path, 'selectors'),
|
|
59
|
+
os.path.join(base_path, 'services'),
|
|
60
|
+
os.path.join(base_path, 'socket'),
|
|
61
|
+
os.path.join(base_path, 'tasks'),
|
|
62
|
+
os.path.join(base_path, 'tests'),
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
for directory in directories:
|
|
66
|
+
os.makedirs(directory, exist_ok=True)
|
|
67
|
+
# Create __init__.py in each directory
|
|
68
|
+
init_file = os.path.join(directory, '__init__.py')
|
|
69
|
+
if not os.path.exists(init_file):
|
|
70
|
+
with open(init_file, 'w') as f:
|
|
71
|
+
f.write('')
|
|
72
|
+
|
|
73
|
+
# Create main app files
|
|
74
|
+
files_content = {
|
|
75
|
+
'admin.py': f'''from django.contrib import admin
|
|
76
|
+
|
|
77
|
+
# Register your models here.
|
|
78
|
+
''',
|
|
79
|
+
'apps.py': f'''from django.apps import AppConfig
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class {app_name.title()}Config(AppConfig):
|
|
83
|
+
default_auto_field = 'django.db.models.BigAutoField'
|
|
84
|
+
name = 'apps.{app_name}'
|
|
85
|
+
''',
|
|
86
|
+
'models.py': f'''from django.db import models
|
|
87
|
+
from apps.common.models import TimeStampedModel
|
|
88
|
+
|
|
89
|
+
# Create your models here.
|
|
90
|
+
''',
|
|
91
|
+
'urls.py': f'''from django.urls import path
|
|
92
|
+
from . import views
|
|
93
|
+
|
|
94
|
+
app_name = '{app_name}'
|
|
95
|
+
|
|
96
|
+
urlpatterns = [
|
|
97
|
+
# Add your URL patterns here
|
|
98
|
+
]
|
|
99
|
+
''',
|
|
100
|
+
'views.py': f'''from rest_framework import viewsets, status
|
|
101
|
+
from rest_framework.decorators import action
|
|
102
|
+
from rest_framework.response import Response
|
|
103
|
+
from core.response_wrapper import success_response, error_response
|
|
104
|
+
|
|
105
|
+
# Create your views here.
|
|
106
|
+
''',
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
for filename, content in files_content.items():
|
|
110
|
+
file_path = os.path.join(base_path, filename)
|
|
111
|
+
with open(file_path, 'w') as f:
|
|
112
|
+
f.write(content)
|
|
113
|
+
|
|
114
|
+
self.stdout.write(f'Created app structure in apps/{app_name}/')
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
|
|
2
|
+
from django.urls import path
|
|
3
|
+
|
|
4
|
+
urlpatterns = [
|
|
5
|
+
path('schema/', SpectacularAPIView.as_view(), name='schema'),
|
|
6
|
+
path('docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
|
|
7
|
+
]
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Project Description - {project_name}
|
|
2
|
+
|
|
3
|
+
This document provides a comprehensive overview of the project architecture, purpose, and technical stack for AI assistants.
|
|
4
|
+
|
|
5
|
+
## 🎯 Project Purpose
|
|
6
|
+
|
|
7
|
+
**{project_name}** is a Django REST Framework (DRF) project built using the **NTC (Nexent Toolkit Console)** structure. This project follows enterprise-grade patterns and best practices for building scalable, maintainable API-driven applications.
|
|
8
|
+
|
|
9
|
+
## 🏛️ Architecture Overview
|
|
10
|
+
|
|
11
|
+
### **API-First Design**
|
|
12
|
+
- **Backend**: Django REST Framework providing JSON APIs
|
|
13
|
+
- **Frontend**: Separate frontend applications (React, Angular, Vue, etc.)
|
|
14
|
+
- **Communication**: RESTful APIs with standardized JSON responses
|
|
15
|
+
- **Authentication**: JWT-based authentication with refresh tokens
|
|
16
|
+
|
|
17
|
+
### **Modular Structure**
|
|
18
|
+
- **Apps**: Feature-based Django applications in `apps/` directory
|
|
19
|
+
- **Core**: Shared utilities, base classes, and framework extensions
|
|
20
|
+
- **Services**: External integrations (AWS, Azure, payment gateways)
|
|
21
|
+
- **Common**: Shared models, serializers, and utilities
|
|
22
|
+
|
|
23
|
+
## 🛠️ Technical Stack
|
|
24
|
+
|
|
25
|
+
### **Backend Framework**
|
|
26
|
+
- **Django 4.2+**: Web framework
|
|
27
|
+
- **Django REST Framework**: API framework
|
|
28
|
+
- **PostgreSQL/SQLite**: Database (configurable)
|
|
29
|
+
- **Redis**: Caching and session storage
|
|
30
|
+
- **Celery**: Background task processing
|
|
31
|
+
- **JWT**: Authentication tokens
|
|
32
|
+
- **Uvicorn**: ASGI server for async performance
|
|
33
|
+
- **Gunicorn**: WSGI HTTP server
|
|
34
|
+
- **Nginx**: Reverse proxy and static file serving
|
|
35
|
+
|
|
36
|
+
### **Development Tools**
|
|
37
|
+
- **Docker**: Containerization (Python 3.12-slim)
|
|
38
|
+
- **Docker Compose**: Local development environment
|
|
39
|
+
- **CapRover**: Deployment platform
|
|
40
|
+
- **Environment Variables**: Configuration management via django-environ
|
|
41
|
+
|
|
42
|
+
### **API Features**
|
|
43
|
+
- **OpenAPI/Swagger**: Auto-generated API documentation at `/docs/`
|
|
44
|
+
- **CORS**: Cross-origin resource sharing configured
|
|
45
|
+
- **Pagination**: Standardized pagination for list endpoints
|
|
46
|
+
- **Error Handling**: Consistent error response format
|
|
47
|
+
- **Logging**: Structured logging with custom formatters
|
|
48
|
+
|
|
49
|
+
## 🔧 Key Components
|
|
50
|
+
|
|
51
|
+
### **Authentication System**
|
|
52
|
+
- **JWT Access Tokens**: Short-lived (15 minutes default)
|
|
53
|
+
- **Refresh Tokens**: Long-lived (14 days default)
|
|
54
|
+
- **Token Blacklisting**: Secure logout functionality
|
|
55
|
+
- **Cookie Support**: Optional cookie-based authentication
|
|
56
|
+
|
|
57
|
+
### **Response Format**
|
|
58
|
+
All API responses follow a standardized format:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"status": "success|error",
|
|
63
|
+
"message": "Human-readable message",
|
|
64
|
+
"data": { /* Response data */ }
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### **Database Models**
|
|
69
|
+
- **TimeStampedModel**: Base model with `created_at` and `updated_at`
|
|
70
|
+
- **BaseModel**: Enhanced base model with BigAutoField primary key
|
|
71
|
+
- **Abstract Models**: Reusable model patterns in `apps.common`
|
|
72
|
+
|
|
73
|
+
### **Business Logic Pattern**
|
|
74
|
+
- **Views**: Handle HTTP requests/responses only
|
|
75
|
+
- **Services**: Contain business logic and complex operations
|
|
76
|
+
- **Selectors**: Handle data querying and filtering
|
|
77
|
+
- **Serializers**: Data validation and transformation
|
|
78
|
+
|
|
79
|
+
## 🌐 External Integrations
|
|
80
|
+
|
|
81
|
+
### **Cloud Services**
|
|
82
|
+
- **Cloudflare R2**: S3-compatible object storage (fully implemented)
|
|
83
|
+
- **Azure Communication Services**: Email backend (fully implemented)
|
|
84
|
+
- **AWS Services**: S3, SES, SNS (configured but not implemented)
|
|
85
|
+
- **Azure Services**: Storage, SMS (configured but not implemented)
|
|
86
|
+
|
|
87
|
+
### **Monitoring & Error Tracking**
|
|
88
|
+
- **Sentry**: Error tracking and performance monitoring (fully configured)
|
|
89
|
+
|
|
90
|
+
### **Payment Gateways** (Tanzania-focused)
|
|
91
|
+
- **SELCOM**: Mobile payments
|
|
92
|
+
- **ClickPesa**: Payment processing
|
|
93
|
+
- **Beem**: SMS and payment services
|
|
94
|
+
- **Polar**: Payment gateway
|
|
95
|
+
|
|
96
|
+
### **Communication**
|
|
97
|
+
- **Email**: Azure Communication Services Email backend with template support
|
|
98
|
+
- **SMS**: Integration ready for Beem and other providers
|
|
99
|
+
- **WebSocket**: Socket handlers in app structure
|
|
100
|
+
|
|
101
|
+
## 🔄 Development Patterns
|
|
102
|
+
|
|
103
|
+
### **Service/Selector Pattern**
|
|
104
|
+
```python
|
|
105
|
+
# services/user_service.py
|
|
106
|
+
def create_user(email, password):
|
|
107
|
+
# Business logic here
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
# selectors/user_selector.py
|
|
111
|
+
def get_active_users():
|
|
112
|
+
# Data querying here
|
|
113
|
+
pass
|
|
114
|
+
|
|
115
|
+
# views.py
|
|
116
|
+
def create_user_view(request):
|
|
117
|
+
# Use service for business logic
|
|
118
|
+
user = create_user(email, password)
|
|
119
|
+
return success_response(data=user)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### **Response Wrapper Usage**
|
|
123
|
+
```python
|
|
124
|
+
from core.response_wrapper import success_response, error_response
|
|
125
|
+
|
|
126
|
+
# Success response
|
|
127
|
+
return success_response(
|
|
128
|
+
data={"user_id": 123},
|
|
129
|
+
message="User created successfully"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Error response
|
|
133
|
+
return error_response(
|
|
134
|
+
message="Invalid credentials",
|
|
135
|
+
code=400
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 📊 Environment Configuration
|
|
140
|
+
|
|
141
|
+
### **Development Settings** (`settings/dev.py`)
|
|
142
|
+
- **DEBUG**: True
|
|
143
|
+
- **Database**: SQLite (default)
|
|
144
|
+
- **CORS**: Localhost allowed
|
|
145
|
+
- **Logging**: Console output
|
|
146
|
+
|
|
147
|
+
### **Production Settings** (`settings/prod.py`)
|
|
148
|
+
- **DEBUG**: False
|
|
149
|
+
- **Database**: PostgreSQL (via environment variables)
|
|
150
|
+
- **Security**: HTTPS redirects, secure cookies
|
|
151
|
+
- **Logging**: File-based logging
|
|
152
|
+
|
|
153
|
+
## 🚀 Deployment
|
|
154
|
+
|
|
155
|
+
### **Docker Support**
|
|
156
|
+
- **Multi-stage builds**: Optimized for production with Python 3.12-slim
|
|
157
|
+
- **Nginx Reverse Proxy**: Handles HTTP/WebSocket traffic and static files
|
|
158
|
+
- **Uvicorn Workers**: ASGI server for async performance
|
|
159
|
+
- **Gunicorn**: WSGI HTTP server with Uvicorn workers
|
|
160
|
+
- **Entry Scripts**: `.entry/start_core_backend.sh` and `.entry/start_tasks_backend.sh`
|
|
161
|
+
- **Configuration Files**: `config/gunicorn_config.py` and `config/http.conf`
|
|
162
|
+
- **Environment Variables**: Configurable via `.env`
|
|
163
|
+
- **Health checks**: Built-in health monitoring
|
|
164
|
+
- **Production Settings**: ASGI/WSGI use `settings.prod` by default
|
|
165
|
+
- **DEBUG=False**: Production-ready default configuration
|
|
166
|
+
|
|
167
|
+
### **CapRover Deployment**
|
|
168
|
+
- **One-click deployment**: Using `captain-definition`
|
|
169
|
+
- **Auto-scaling**: Configurable scaling rules
|
|
170
|
+
- **SSL**: Automatic SSL certificate management
|
|
171
|
+
|
|
172
|
+
## 📝 API Documentation
|
|
173
|
+
|
|
174
|
+
### **Auto-generated Docs**
|
|
175
|
+
- **Swagger UI**: Available at `/docs/`
|
|
176
|
+
- **OpenAPI Schema**: Available at `/schema/`
|
|
177
|
+
- **Interactive Testing**: Built-in API testing interface
|
|
178
|
+
|
|
179
|
+
### **Response Examples**
|
|
180
|
+
The API provides consistent, well-documented responses with examples for all endpoints.
|
|
181
|
+
|
|
182
|
+
## 🎯 Best Practices Implemented
|
|
183
|
+
|
|
184
|
+
1. **Separation of Concerns**: Clear separation between views, services, and data access
|
|
185
|
+
2. **DRY Principle**: Reusable components and base classes
|
|
186
|
+
3. **Security First**: JWT authentication, CORS, secure headers
|
|
187
|
+
4. **Scalability**: Modular app structure, background tasks with Celery
|
|
188
|
+
5. **Maintainability**: Clear naming conventions, comprehensive documentation
|
|
189
|
+
6. **Testing Ready**: Test directories in every app, test utilities available
|
|
190
|
+
|
|
191
|
+
## 🤖 AI Assistant Guidelines
|
|
192
|
+
|
|
193
|
+
When working with this project:
|
|
194
|
+
- **Follow NTC patterns** and conventions
|
|
195
|
+
- **Use the service/selector pattern** for business logic
|
|
196
|
+
- **Leverage existing utilities** in `core/` and `apps.common/`
|
|
197
|
+
- **Maintain consistent API responses** using response wrappers
|
|
198
|
+
- **Add proper error handling** and validation
|
|
199
|
+
- **Update documentation** when adding new features
|
|
200
|
+
- **Use environment variables** for configuration
|
|
201
|
+
- **Follow Django and DRF best practices**
|