claude-code-templates 1.16.0 → 1.17.0
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.
- package/README.md +7 -7
- package/bin/create-claude-config.js +17 -8
- package/package.json +2 -3
- package/src/analytics/core/AgentAnalyzer.js +17 -3
- package/src/analytics/core/ProcessDetector.js +23 -7
- package/src/analytics/core/StateCalculator.js +102 -33
- package/src/analytics/data/DataCache.js +7 -7
- package/src/analytics-web/chats_mobile.html +2590 -0
- package/src/analytics-web/components/App.js +10 -10
- package/src/analytics-web/components/SessionTimer.js +1 -1
- package/src/analytics-web/components/Sidebar.js +5 -14
- package/src/analytics-web/index.html +932 -78
- package/src/analytics.js +263 -5
- package/src/chats-mobile.js +682 -0
- package/src/claude-api-proxy.js +460 -0
- package/src/file-operations.js +239 -36
- package/src/health-check.js +310 -0
- package/src/index.js +1252 -56
- package/src/tracking-service.js +31 -34
- package/components/agents/api-security-audit.md +0 -92
- package/components/agents/database-optimization.md +0 -94
- package/components/agents/react-performance-optimization.md +0 -64
- package/components/commands/check-file.md +0 -53
- package/components/commands/generate-tests.md +0 -68
- package/components/mcps/deepgraph-nextjs.json +0 -12
- package/components/mcps/deepgraph-react.json +0 -12
- package/components/mcps/deepgraph-typescript.json +0 -12
- package/components/mcps/deepgraph-vue.json +0 -12
- package/components/mcps/filesystem-access.json +0 -12
- package/components/mcps/github-integration.json +0 -11
- package/components/mcps/memory-integration.json +0 -8
- package/components/mcps/mysql-integration.json +0 -11
- package/components/mcps/postgresql-integration.json +0 -11
- package/components/mcps/web-fetch.json +0 -8
- package/src/analytics-web/components/AgentsPage.js +0 -4761
- package/templates/common/.claude/commands/git-workflow.md +0 -239
- package/templates/common/.claude/commands/project-setup.md +0 -316
- package/templates/common/.mcp.json +0 -41
- package/templates/common/CLAUDE.md +0 -109
- package/templates/common/README.md +0 -96
- package/templates/go/.mcp.json +0 -78
- package/templates/go/README.md +0 -25
- package/templates/javascript-typescript/.claude/commands/api-endpoint.md +0 -51
- package/templates/javascript-typescript/.claude/commands/debug.md +0 -52
- package/templates/javascript-typescript/.claude/commands/lint.md +0 -48
- package/templates/javascript-typescript/.claude/commands/npm-scripts.md +0 -48
- package/templates/javascript-typescript/.claude/commands/refactor.md +0 -55
- package/templates/javascript-typescript/.claude/commands/test.md +0 -61
- package/templates/javascript-typescript/.claude/commands/typescript-migrate.md +0 -51
- package/templates/javascript-typescript/.claude/settings.json +0 -142
- package/templates/javascript-typescript/.mcp.json +0 -80
- package/templates/javascript-typescript/CLAUDE.md +0 -185
- package/templates/javascript-typescript/README.md +0 -259
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/components.md +0 -63
- package/templates/javascript-typescript/examples/angular-app/.claude/commands/services.md +0 -62
- package/templates/javascript-typescript/examples/node-api/.claude/commands/api-endpoint.md +0 -46
- package/templates/javascript-typescript/examples/node-api/.claude/commands/database.md +0 -56
- package/templates/javascript-typescript/examples/node-api/.claude/commands/middleware.md +0 -61
- package/templates/javascript-typescript/examples/node-api/.claude/commands/route.md +0 -57
- package/templates/javascript-typescript/examples/node-api/CLAUDE.md +0 -102
- package/templates/javascript-typescript/examples/react-app/.claude/commands/component.md +0 -29
- package/templates/javascript-typescript/examples/react-app/.claude/commands/hooks.md +0 -44
- package/templates/javascript-typescript/examples/react-app/.claude/commands/state-management.md +0 -45
- package/templates/javascript-typescript/examples/react-app/CLAUDE.md +0 -81
- package/templates/javascript-typescript/examples/react-app/agents/react-performance-optimization.md +0 -530
- package/templates/javascript-typescript/examples/react-app/agents/react-state-management.md +0 -295
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/components.md +0 -46
- package/templates/javascript-typescript/examples/vue-app/.claude/commands/composables.md +0 -51
- package/templates/python/.claude/commands/lint.md +0 -111
- package/templates/python/.claude/commands/test.md +0 -73
- package/templates/python/.claude/settings.json +0 -153
- package/templates/python/.mcp.json +0 -78
- package/templates/python/CLAUDE.md +0 -276
- package/templates/python/examples/django-app/.claude/commands/admin.md +0 -264
- package/templates/python/examples/django-app/.claude/commands/django-model.md +0 -124
- package/templates/python/examples/django-app/.claude/commands/views.md +0 -222
- package/templates/python/examples/django-app/CLAUDE.md +0 -313
- package/templates/python/examples/django-app/agents/django-api-security.md +0 -642
- package/templates/python/examples/django-app/agents/django-database-optimization.md +0 -752
- package/templates/python/examples/fastapi-app/.claude/commands/api-endpoints.md +0 -513
- package/templates/python/examples/fastapi-app/.claude/commands/auth.md +0 -775
- package/templates/python/examples/fastapi-app/.claude/commands/database.md +0 -657
- package/templates/python/examples/fastapi-app/.claude/commands/deployment.md +0 -160
- package/templates/python/examples/fastapi-app/.claude/commands/testing.md +0 -927
- package/templates/python/examples/fastapi-app/CLAUDE.md +0 -229
- package/templates/python/examples/flask-app/.claude/commands/app-factory.md +0 -384
- package/templates/python/examples/flask-app/.claude/commands/blueprint.md +0 -243
- package/templates/python/examples/flask-app/.claude/commands/database.md +0 -410
- package/templates/python/examples/flask-app/.claude/commands/deployment.md +0 -620
- package/templates/python/examples/flask-app/.claude/commands/flask-route.md +0 -217
- package/templates/python/examples/flask-app/.claude/commands/testing.md +0 -559
- package/templates/python/examples/flask-app/CLAUDE.md +0 -391
- package/templates/ruby/.claude/commands/model.md +0 -360
- package/templates/ruby/.claude/commands/test.md +0 -480
- package/templates/ruby/.claude/settings.json +0 -146
- package/templates/ruby/.mcp.json +0 -83
- package/templates/ruby/CLAUDE.md +0 -284
- package/templates/ruby/examples/rails-app/.claude/commands/authentication.md +0 -490
- package/templates/ruby/examples/rails-app/CLAUDE.md +0 -376
- package/templates/rust/.mcp.json +0 -78
- package/templates/rust/README.md +0 -26
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
# Flask Project Configuration
|
|
2
|
-
|
|
3
|
-
This file provides specific guidance for Flask web application development using Claude Code.
|
|
4
|
-
|
|
5
|
-
## Project Overview
|
|
6
|
-
|
|
7
|
-
This is a Flask web application project optimized for scalable web development with the Flask micro-framework. The project follows Flask best practices and modern Python development patterns.
|
|
8
|
-
|
|
9
|
-
## Flask-Specific Development Commands
|
|
10
|
-
|
|
11
|
-
### Project Management
|
|
12
|
-
- `flask run` - Start development server
|
|
13
|
-
- `flask run --host=0.0.0.0 --port=5000` - Start server accessible from network
|
|
14
|
-
- `flask shell` - Open Flask shell with application context
|
|
15
|
-
- `python -m flask --help` - Show available Flask commands
|
|
16
|
-
|
|
17
|
-
### Database Management
|
|
18
|
-
- `flask db init` - Initialize database migrations
|
|
19
|
-
- `flask db migrate -m "message"` - Create database migration
|
|
20
|
-
- `flask db upgrade` - Apply database migrations
|
|
21
|
-
- `flask db downgrade` - Rollback database migration
|
|
22
|
-
- `flask db current` - Show current migration
|
|
23
|
-
- `flask db history` - Show migration history
|
|
24
|
-
|
|
25
|
-
### Development Tools
|
|
26
|
-
- `flask routes` - Show all registered routes
|
|
27
|
-
- `flask --version` - Show Flask version
|
|
28
|
-
- `export FLASK_ENV=development` - Set development environment
|
|
29
|
-
- `export FLASK_DEBUG=1` - Enable debug mode
|
|
30
|
-
|
|
31
|
-
### Custom Commands
|
|
32
|
-
- `flask init-db` - Initialize database with tables
|
|
33
|
-
- `flask seed-db` - Seed database with sample data
|
|
34
|
-
- `flask reset-db` - Reset database (development only)
|
|
35
|
-
|
|
36
|
-
## Flask Project Structure
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
myproject/
|
|
40
|
-
├── app/ # Application package
|
|
41
|
-
│ ├── __init__.py # Application factory
|
|
42
|
-
│ ├── extensions.py # Flask extensions
|
|
43
|
-
│ ├── config.py # Configuration settings
|
|
44
|
-
│ ├── models/ # Database models
|
|
45
|
-
│ │ ├── __init__.py
|
|
46
|
-
│ │ ├── base.py # Base model class
|
|
47
|
-
│ │ ├── user.py # User model
|
|
48
|
-
│ │ └── post.py # Post model
|
|
49
|
-
│ ├── blueprints/ # Application blueprints
|
|
50
|
-
│ │ ├── __init__.py
|
|
51
|
-
│ │ ├── main/ # Main blueprint
|
|
52
|
-
│ │ ├── auth/ # Authentication blueprint
|
|
53
|
-
│ │ ├── api/ # API blueprint
|
|
54
|
-
│ │ └── admin/ # Admin blueprint
|
|
55
|
-
│ ├── templates/ # Jinja2 templates
|
|
56
|
-
│ │ ├── base.html
|
|
57
|
-
│ │ ├── index.html
|
|
58
|
-
│ │ └── auth/
|
|
59
|
-
│ ├── static/ # Static files
|
|
60
|
-
│ │ ├── css/
|
|
61
|
-
│ │ ├── js/
|
|
62
|
-
│ │ └── images/
|
|
63
|
-
│ ├── forms/ # WTForms
|
|
64
|
-
│ │ ├── __init__.py
|
|
65
|
-
│ │ ├── auth.py
|
|
66
|
-
│ │ └── user.py
|
|
67
|
-
│ ├── utils/ # Utility functions
|
|
68
|
-
│ └── cli.py # Custom CLI commands
|
|
69
|
-
├── migrations/ # Database migrations
|
|
70
|
-
├── tests/ # Test files
|
|
71
|
-
│ ├── conftest.py
|
|
72
|
-
│ ├── test_models.py
|
|
73
|
-
│ ├── test_views.py
|
|
74
|
-
│ └── test_api.py
|
|
75
|
-
├── requirements/ # Requirements files
|
|
76
|
-
│ ├── base.txt
|
|
77
|
-
│ ├── development.txt
|
|
78
|
-
│ └── production.txt
|
|
79
|
-
├── wsgi.py # WSGI entry point
|
|
80
|
-
├── gunicorn.conf.py # Gunicorn configuration
|
|
81
|
-
└── docker-compose.yml # Docker Compose configuration
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Flask Application Factory
|
|
85
|
-
|
|
86
|
-
```python
|
|
87
|
-
# app/__init__.py
|
|
88
|
-
from flask import Flask
|
|
89
|
-
from app.extensions import db, migrate, login_manager, csrf, cache
|
|
90
|
-
from app.config import config
|
|
91
|
-
|
|
92
|
-
def create_app(config_name='default'):
|
|
93
|
-
app = Flask(__name__)
|
|
94
|
-
app.config.from_object(config[config_name])
|
|
95
|
-
|
|
96
|
-
# Initialize extensions
|
|
97
|
-
db.init_app(app)
|
|
98
|
-
migrate.init_app(app, db)
|
|
99
|
-
login_manager.init_app(app)
|
|
100
|
-
csrf.init_app(app)
|
|
101
|
-
cache.init_app(app)
|
|
102
|
-
|
|
103
|
-
# Register blueprints
|
|
104
|
-
from app.blueprints.main import main_bp
|
|
105
|
-
from app.blueprints.auth import auth_bp
|
|
106
|
-
from app.blueprints.api import api_bp
|
|
107
|
-
|
|
108
|
-
app.register_blueprint(main_bp)
|
|
109
|
-
app.register_blueprint(auth_bp, url_prefix='/auth')
|
|
110
|
-
app.register_blueprint(api_bp, url_prefix='/api/v1')
|
|
111
|
-
|
|
112
|
-
# Register CLI commands
|
|
113
|
-
from app.cli import init_commands
|
|
114
|
-
init_commands(app)
|
|
115
|
-
|
|
116
|
-
return app
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## Configuration Management
|
|
120
|
-
|
|
121
|
-
```python
|
|
122
|
-
# app/config.py
|
|
123
|
-
import os
|
|
124
|
-
from datetime import timedelta
|
|
125
|
-
|
|
126
|
-
class Config:
|
|
127
|
-
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key'
|
|
128
|
-
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
|
129
|
-
SQLALCHEMY_RECORD_QUERIES = True
|
|
130
|
-
|
|
131
|
-
# Session configuration
|
|
132
|
-
PERMANENT_SESSION_LIFETIME = timedelta(hours=1)
|
|
133
|
-
SESSION_COOKIE_SECURE = True
|
|
134
|
-
SESSION_COOKIE_HTTPONLY = True
|
|
135
|
-
SESSION_COOKIE_SAMESITE = 'Lax'
|
|
136
|
-
|
|
137
|
-
# File upload
|
|
138
|
-
MAX_CONTENT_LENGTH = 16 * 1024 * 1024 # 16MB
|
|
139
|
-
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'uploads')
|
|
140
|
-
|
|
141
|
-
# Cache
|
|
142
|
-
CACHE_TYPE = 'simple'
|
|
143
|
-
CACHE_DEFAULT_TIMEOUT = 300
|
|
144
|
-
|
|
145
|
-
class DevelopmentConfig(Config):
|
|
146
|
-
DEBUG = True
|
|
147
|
-
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
|
|
148
|
-
'sqlite:///dev.db'
|
|
149
|
-
SESSION_COOKIE_SECURE = False
|
|
150
|
-
|
|
151
|
-
class ProductionConfig(Config):
|
|
152
|
-
DEBUG = False
|
|
153
|
-
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
|
|
154
|
-
|
|
155
|
-
# Security headers
|
|
156
|
-
SECURITY_HEADERS = {
|
|
157
|
-
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
|
|
158
|
-
'X-Content-Type-Options': 'nosniff',
|
|
159
|
-
'X-Frame-Options': 'DENY',
|
|
160
|
-
'X-XSS-Protection': '1; mode=block'
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
class TestingConfig(Config):
|
|
164
|
-
TESTING = True
|
|
165
|
-
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
|
|
166
|
-
WTF_CSRF_ENABLED = False
|
|
167
|
-
|
|
168
|
-
config = {
|
|
169
|
-
'development': DevelopmentConfig,
|
|
170
|
-
'production': ProductionConfig,
|
|
171
|
-
'testing': TestingConfig,
|
|
172
|
-
'default': DevelopmentConfig
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Flask Best Practices
|
|
177
|
-
|
|
178
|
-
### Application Structure
|
|
179
|
-
- Use application factory pattern for configuration flexibility
|
|
180
|
-
- Organize code into blueprints for modularity
|
|
181
|
-
- Separate models, views, and forms into different modules
|
|
182
|
-
- Use extensions.py to initialize Flask extensions
|
|
183
|
-
- Implement proper error handling and logging
|
|
184
|
-
|
|
185
|
-
### Database Models
|
|
186
|
-
- Use SQLAlchemy ORM for database operations
|
|
187
|
-
- Implement base model with common functionality
|
|
188
|
-
- Add proper relationships between models
|
|
189
|
-
- Use database migrations for schema changes
|
|
190
|
-
- Implement model validation and constraints
|
|
191
|
-
|
|
192
|
-
### Blueprint Organization
|
|
193
|
-
- Group related functionality into blueprints
|
|
194
|
-
- Use URL prefixes for namespacing
|
|
195
|
-
- Implement blueprint-specific templates
|
|
196
|
-
- Add proper error handlers for each blueprint
|
|
197
|
-
- Use blueprint factories for complex blueprints
|
|
198
|
-
|
|
199
|
-
### Template Management
|
|
200
|
-
- Use template inheritance for consistent layout
|
|
201
|
-
- Create reusable template macros
|
|
202
|
-
- Implement proper CSRF protection in forms
|
|
203
|
-
- Use Flask-WTF for form handling and validation
|
|
204
|
-
- Organize templates by blueprint
|
|
205
|
-
|
|
206
|
-
### Security Considerations
|
|
207
|
-
- Always validate and sanitize user input
|
|
208
|
-
- Use Flask-Login for user session management
|
|
209
|
-
- Implement proper authentication and authorization
|
|
210
|
-
- Use CSRF protection for all forms
|
|
211
|
-
- Set secure session cookie configuration
|
|
212
|
-
- Implement rate limiting for API endpoints
|
|
213
|
-
|
|
214
|
-
## Flask Extensions
|
|
215
|
-
|
|
216
|
-
### Essential Extensions
|
|
217
|
-
```python
|
|
218
|
-
# app/extensions.py
|
|
219
|
-
from flask_sqlalchemy import SQLAlchemy
|
|
220
|
-
from flask_migrate import Migrate
|
|
221
|
-
from flask_login import LoginManager
|
|
222
|
-
from flask_wtf.csrf import CSRFProtect
|
|
223
|
-
from flask_caching import Cache
|
|
224
|
-
from flask_limiter import Limiter
|
|
225
|
-
from flask_limiter.util import get_remote_address
|
|
226
|
-
|
|
227
|
-
db = SQLAlchemy()
|
|
228
|
-
migrate = Migrate()
|
|
229
|
-
login_manager = LoginManager()
|
|
230
|
-
csrf = CSRFProtect()
|
|
231
|
-
cache = Cache()
|
|
232
|
-
limiter = Limiter(key_func=get_remote_address)
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
### Recommended Extensions
|
|
236
|
-
- **Flask-SQLAlchemy** - Database ORM
|
|
237
|
-
- **Flask-Migrate** - Database migrations
|
|
238
|
-
- **Flask-Login** - User session management
|
|
239
|
-
- **Flask-WTF** - Form handling and CSRF protection
|
|
240
|
-
- **Flask-Caching** - Caching support
|
|
241
|
-
- **Flask-Limiter** - Rate limiting
|
|
242
|
-
- **Flask-Mail** - Email support
|
|
243
|
-
- **Flask-Admin** - Admin interface
|
|
244
|
-
|
|
245
|
-
## Testing Strategy
|
|
246
|
-
|
|
247
|
-
### Test Organization
|
|
248
|
-
```python
|
|
249
|
-
# tests/conftest.py
|
|
250
|
-
import pytest
|
|
251
|
-
from app import create_app
|
|
252
|
-
from app.extensions import db
|
|
253
|
-
|
|
254
|
-
@pytest.fixture(scope='session')
|
|
255
|
-
def app():
|
|
256
|
-
app = create_app('testing')
|
|
257
|
-
with app.app_context():
|
|
258
|
-
db.create_all()
|
|
259
|
-
yield app
|
|
260
|
-
db.drop_all()
|
|
261
|
-
|
|
262
|
-
@pytest.fixture
|
|
263
|
-
def client(app):
|
|
264
|
-
return app.test_client()
|
|
265
|
-
|
|
266
|
-
@pytest.fixture
|
|
267
|
-
def runner(app):
|
|
268
|
-
return app.test_cli_runner()
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### Test Types
|
|
272
|
-
- **Unit tests** for models and utilities
|
|
273
|
-
- **Integration tests** for views and API endpoints
|
|
274
|
-
- **Functional tests** for user workflows
|
|
275
|
-
- **Performance tests** for critical paths
|
|
276
|
-
|
|
277
|
-
### Testing Best Practices
|
|
278
|
-
- Use fixtures for common test data
|
|
279
|
-
- Test both success and error conditions
|
|
280
|
-
- Mock external dependencies
|
|
281
|
-
- Use factory_boy for test data generation
|
|
282
|
-
- Implement database transaction rollback in tests
|
|
283
|
-
|
|
284
|
-
## Performance Optimization
|
|
285
|
-
|
|
286
|
-
### Database Optimization
|
|
287
|
-
- Use connection pooling for production
|
|
288
|
-
- Implement query optimization with indexes
|
|
289
|
-
- Use lazy loading for relationships
|
|
290
|
-
- Cache frequently accessed data
|
|
291
|
-
- Monitor database query performance
|
|
292
|
-
|
|
293
|
-
### Caching Strategy
|
|
294
|
-
- Implement Redis for session storage
|
|
295
|
-
- Use view-level caching for static content
|
|
296
|
-
- Cache database query results
|
|
297
|
-
- Implement cache invalidation strategies
|
|
298
|
-
- Use CDN for static files
|
|
299
|
-
|
|
300
|
-
### Application Optimization
|
|
301
|
-
- Use Gunicorn with multiple workers
|
|
302
|
-
- Implement proper logging and monitoring
|
|
303
|
-
- Optimize static file serving
|
|
304
|
-
- Use async tasks for long-running operations
|
|
305
|
-
- Implement proper error handling
|
|
306
|
-
|
|
307
|
-
## Deployment Considerations
|
|
308
|
-
|
|
309
|
-
### Production Setup
|
|
310
|
-
- Use environment variables for configuration
|
|
311
|
-
- Implement proper logging and monitoring
|
|
312
|
-
- Set up database connection pooling
|
|
313
|
-
- Configure reverse proxy (Nginx)
|
|
314
|
-
- Use HTTPS with proper SSL certificates
|
|
315
|
-
|
|
316
|
-
### Docker Configuration
|
|
317
|
-
```dockerfile
|
|
318
|
-
FROM python:3.11-slim
|
|
319
|
-
WORKDIR /app
|
|
320
|
-
COPY requirements/production.txt requirements.txt
|
|
321
|
-
RUN pip install -r requirements.txt
|
|
322
|
-
COPY . .
|
|
323
|
-
EXPOSE 5000
|
|
324
|
-
CMD ["gunicorn", "--config", "gunicorn.conf.py", "wsgi:app"]
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### Environment Variables
|
|
328
|
-
```bash
|
|
329
|
-
FLASK_ENV=production
|
|
330
|
-
SECRET_KEY=your-secret-key
|
|
331
|
-
DATABASE_URL=postgresql://user:pass@host:port/db
|
|
332
|
-
REDIS_URL=redis://host:port/db
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
## Common Flask Patterns
|
|
336
|
-
|
|
337
|
-
### Custom Decorators
|
|
338
|
-
```python
|
|
339
|
-
from functools import wraps
|
|
340
|
-
from flask import abort
|
|
341
|
-
from flask_login import current_user
|
|
342
|
-
|
|
343
|
-
def admin_required(f):
|
|
344
|
-
@wraps(f)
|
|
345
|
-
def decorated_function(*args, **kwargs):
|
|
346
|
-
if not current_user.is_admin:
|
|
347
|
-
abort(403)
|
|
348
|
-
return f(*args, **kwargs)
|
|
349
|
-
return decorated_function
|
|
350
|
-
```
|
|
351
|
-
|
|
352
|
-
### Request Context Processors
|
|
353
|
-
```python
|
|
354
|
-
@app.context_processor
|
|
355
|
-
def inject_user():
|
|
356
|
-
return dict(current_user=current_user)
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
### Custom Filters
|
|
360
|
-
```python
|
|
361
|
-
@app.template_filter('datetime')
|
|
362
|
-
def datetime_filter(value, format='%Y-%m-%d %H:%M'):
|
|
363
|
-
return value.strftime(format) if value else ''
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
## Development Workflow
|
|
367
|
-
|
|
368
|
-
### Getting Started
|
|
369
|
-
1. Clone the repository
|
|
370
|
-
2. Create virtual environment: `python -m venv venv`
|
|
371
|
-
3. Activate environment: `source venv/bin/activate`
|
|
372
|
-
4. Install dependencies: `pip install -r requirements/development.txt`
|
|
373
|
-
5. Set environment variables
|
|
374
|
-
6. Initialize database: `flask db upgrade`
|
|
375
|
-
7. Run development server: `flask run`
|
|
376
|
-
|
|
377
|
-
### Development Process
|
|
378
|
-
1. Create feature branch from main
|
|
379
|
-
2. Implement changes with tests
|
|
380
|
-
3. Run test suite: `pytest`
|
|
381
|
-
4. Check code quality: `flake8`, `black`
|
|
382
|
-
5. Create pull request for review
|
|
383
|
-
6. Deploy after approval
|
|
384
|
-
|
|
385
|
-
### Code Quality Tools
|
|
386
|
-
- **Black** - Code formatting
|
|
387
|
-
- **isort** - Import sorting
|
|
388
|
-
- **flake8** - Linting
|
|
389
|
-
- **mypy** - Type checking
|
|
390
|
-
- **pytest** - Testing framework
|
|
391
|
-
- **coverage** - Test coverage
|