This document outlines the conversion of the scouting backend project to use modern Node.js tooling for JavaScript development and asset management.
The scouting backend project currently uses a traditional Django static files approach with JavaScript files scattered across different apps. This conversion will introduce modern Node.js tooling to improve the development experience, code organization, and build processes.
staticfiles/scanner/scanner.js- QR code scanning functionalitystaticfiles/strategy/picklist.js- Team picklist managementstaticfiles/team/replay_system.js- Match replay visualizationstaticfiles/admin/js/- Django admin interface scripts- App-specific
static/directories with duplicate files
- Code Duplication: Same JS files exist in both
staticfiles/and appstatic/directories - No Dependency Management: External libraries are manually included
- No Build Process: No minification, bundling, or optimization
- No Code Quality Tools: No linting or formatting
- Manual Asset Management: Static files managed manually
├── frontend/
│ ├── src/
│ │ ├── scanner/
│ │ │ ├── scanner.js
│ │ │ └── qr-scanner.js
│ │ ├── strategy/
│ │ │ └── picklist.js
│ │ ├── team/
│ │ │ └── replay_system.js
│ │ ├── shared/
│ │ │ ├── utils.js
│ │ │ └── api.js
│ │ └── index.js
│ ├── dist/ (build output)
│ ├── package.json
│ ├── webpack.config.js
│ ├── .eslintrc.js
│ └── .prettierrc
├── staticfiles/ (Django static files)
└── manage.py
- Package Manager: npm
- Build Tool: Webpack 5
- Code Quality: ESLint + Prettier
- Development: Webpack Dev Server with hot reloading
- Production: Minification and optimization
- Initialize npm project with
package.json - Install development dependencies
- Configure build tools (Webpack)
- Set up code quality tools (ESLint, Prettier)
- Create
frontend/src/directory structure - Move and refactor existing JS files
- Extract common functionality into shared modules
- Update import/export statements for ES modules
- Configure Webpack for development and production builds
- Update Django settings for new static file locations
- Create build scripts in package.json
- Set up development workflow
- Configure development server with hot reloading
- Set up watch mode for automatic rebuilds
- Create deployment scripts
- Update documentation
- Modern JavaScript: ES6+ features, modules, async/await
- Hot Reloading: Instant feedback during development
- Code Quality: Automatic linting and formatting
- Dependency Management: Easy library installation and updates
- Bundling: Reduced HTTP requests
- Minification: Smaller file sizes
- Tree Shaking: Remove unused code
- Code Splitting: Load only necessary code
- Organized Structure: Clear separation of concerns
- Shared Code: Reusable components and utilities
- Type Safety: Optional TypeScript integration
- Testing: Jest testing framework integration
# Install Node.js (LTS version)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Initialize project
cd /path/to/scouting-backend-2025
npm init -y
# Install dependencies
npm install --save-dev webpack webpack-cli webpack-dev-server
npm install --save-dev @babel/core @babel/preset-env babel-loader
npm install --save-dev eslint prettier eslint-config-prettier
npm install --save-dev css-loader style-loader mini-css-extract-plugin# settings.py
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'frontend', 'dist'), # Built assets
os.path.join(BASE_DIR, 'scanner', 'static'),
os.path.join(BASE_DIR, 'teams', 'static'),
os.path.join(BASE_DIR, 'strategy', 'static'),
]
# Development vs Production
if DEBUG:
# Use Webpack dev server
WEBPACK_DEV_SERVER_URL = 'http://localhost:8080'
else:
# Use built static files
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'- Current: Direct fetch calls, manual DOM manipulation
- Proposed: Modular structure with error handling, shared API utilities
- Current: Global variables, mixed concerns
- Proposed: Class-based structure, state management, shared utilities
- Current: Large monolithic file
- Proposed: Separate modules for canvas, animation, data fetching
# Start Django development server
python manage.py runserver
# Start Webpack development server (separate terminal)
npm run dev
# Watch for changes and rebuild
npm run watch# Build optimized assets
npm run build
# Collect Django static files
python manage.py collectstaticDuring the transition:
- Keep existing files functional
- Gradually migrate one module at a time
- Maintain Django's static file structure
- Ensure production deployments continue working
- Unit Tests: Jest for individual functions
- Integration Tests: Test API interactions
- E2E Tests: Playwright for full user workflows
- Bundle Analysis: Webpack Bundle Analyzer
- Load Testing: Lighthouse performance audits
- Memory Profiling: Chrome DevTools
{
"version": 2,
"builds": [
{
"src": "vercel_app.py",
"use": "@vercel/python"
},
{
"src": "frontend/package.json",
"use": "@vercel/static-build",
"config": {
"buildCommand": "npm run build",
"outputDirectory": "dist"
}
}
]
}# .github/workflows/build.yml
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build frontend
run: npm run build
- name: Collect static files
run: python manage.py collectstatic --noinput- Week 1: Setup Node.js environment and basic tooling
- Week 2: Migrate scanner.js and establish patterns
- Week 3: Migrate picklist.js and strategy components
- Week 4: Migrate replay_system.js and team components
- Week 5: Testing, optimization, and documentation
- Create initial
package.jsonand install dependencies - Set up basic Webpack configuration
- Create development and production build scripts
- Migrate first JavaScript module (scanner.js) as proof of concept
- Establish patterns and guidelines for remaining modules
This conversion will significantly improve the development experience while maintaining the existing Django backend architecture and functionality.