Overview
This guide covers the complete development workflow for ScreenPulse, including running the dev server, using npm scripts, working with Storybook for component development, and building for production.Development Server
Starting the Server
ScreenPulse uses Angular’s development server with hot module replacement (HMR) for instant feedback:- Compile TypeScript and SCSS
- Bundle the application
- Start the dev server on
http://localhost:4200/ - Open your default browser (if configured)
- Watch for file changes
The initial compilation may take 10-30 seconds. Subsequent rebuilds are much faster (1-3 seconds) thanks to incremental compilation.
Development Server Options
Run the server on a different port:
Automatically open the browser:
Specify the host for the dev server:
Use a specific build configuration:
Run server with HTTPS:
Hot Module Replacement (HMR)
Angular’s dev server automatically reloads changes:- TypeScript Changes
- HTML Template Changes
- SCSS Style Changes
What happens:
- TypeScript files are recompiled
- Changes are injected into the running app
- Browser refreshes automatically
- Application state is preserved when possible
Available npm Scripts
ScreenPulse includes several npm scripts defined inpackage.json:
Core Development Scripts
package.json
Script Reference
npm start - Development Server
npm start - Development Server
Command:
npm start or npm run startWhat it does:- Starts Angular dev server on port 4200
- Enables hot module replacement
- Watches for file changes
- Uses development configuration
- Developing new features
- Testing changes locally
- Debugging issues
npm run build - Production Build
npm run build - Production Build
Command:
npm run buildWhat it does:- Compiles app for production
- Enables AOT compilation
- Minifies and optimizes code
- Generates output in
dist/controlli-challenge/ - Uses production environment file
- Preparing for deployment
- Testing production build
- Generating optimized bundle
npm run watch - Continuous Build
npm run watch - Continuous Build
Command:
npm run watchWhat it does:- Builds app in development mode
- Watches for file changes
- Rebuilds automatically
- Does NOT serve files (no HTTP server)
- Testing build process
- Validating compilation
- CI/CD pipelines
npm test - Unit Tests
npm test - Unit Tests
Command: Run tests once (for CI):
npm test or npm run testWhat it does:- Runs Jasmine unit tests
- Launches Karma test runner
- Opens Chrome browser for tests
- Watches for file changes
- Re-runs tests on change
- Writing new tests
- Debugging failing tests
- Validating code changes
npm run lint - Code Linting
npm run lint - Code Linting
Command:
npm run lintWhat it does:- Runs ESLint on TypeScript files
- Checks HTML templates
- Enforces code style rules
- Reports warnings and errors
- Before committing code
- Fixing code quality issues
- Ensuring consistent style
eslint.config.jsFix auto-fixable issues:npm run storybook - Component Development
npm run storybook - Component Development
Command:
npm run storybookWhat it does:- Launches Storybook dev server on port 6006
- Shows component documentation
- Provides interactive component playground
- Hot reloads on changes
- Developing UI components in isolation
- Testing component variations
- Writing component documentation
- Showcasing component library
npm run build-storybook - Build Storybook
npm run build-storybook - Build Storybook
Command:
npm run build-storybookWhat it does:- Builds static Storybook site
- Outputs to
storybook-static/ - Ready for deployment
- Deploying component documentation
- Sharing with team
- Hosting on GitHub Pages
npm run deploy - Firebase Deployment
npm run deploy - Firebase Deployment
Command:
npm run deployWhat it does:- Builds app for production
- Deploys to Firebase Hosting
- Updates live site at sreenpulse.web.app
- Firebase CLI installed:
npm install -g firebase-tools - Authenticated:
firebase login - Firebase project configured (see
.firebaserc)
- Deploying to production
- Publishing new releases
npm run compodoc - Generate Documentation
npm run compodoc - Generate Documentation
Command:
npm run compodocWhat it does:- Generates TypeScript code documentation
- Creates JSON output for Storybook
- Documents components, services, modules
- Updating Storybook documentation
- Generating architecture diagrams
documentation.jsonStorybook for Component Development
ScreenPulse uses Storybook 8.3.7 for component-driven development.What is Storybook?
Storybook is a tool for developing UI components in isolation. It allows you to:- Build components outside the main app
- Test different states and props
- Document component APIs
- Share components with designers and stakeholders
- Catch UI bugs early
Launching Storybook
http://localhost:6006/
Storybook Configuration
Storybook configuration is in.storybook/:
angular.json
Writing Stories
Create stories for your components in thesrc/stories/ directory:
button.stories.ts
Using Storybook
Browse Components
Navigate through the component tree in the sidebar to see all available components.
Interact with Controls
Use the Controls panel to change component props in real-time:
- Text inputs for strings
- Sliders for numbers
- Dropdowns for select options
- Toggles for booleans
View Documentation
Click the “Docs” tab to see:
- Component API documentation
- Prop types and descriptions
- Usage examples
- Live component preview
Storybook runs independently from the main app, so you can develop components without worrying about routing, authentication, or other app concerns.
Building for Production
Production Build Command
Build Output
Production builds are output todist/controlli-challenge/:
File names include content hashes (e.g.,
main.abc123.js) for cache busting. The hash changes only when the file content changes.Build Optimizations
Production builds include:AOT Compilation
Ahead-of-Time compilation converts templates to JavaScript at build time, reducing bundle size and improving performance.
Tree Shaking
Removes unused code from bundles, significantly reducing file size.
Minification
Removes whitespace, shortens variable names, and compresses code.
Bundling
Combines multiple files into fewer bundles for faster loading.
Serve Production Build Locally
Test the production build before deploying:http://localhost:8080/ to test.
Build Performance
Typical build times:- Development build: 10-30 seconds (initial), 1-3 seconds (incremental)
- Production build: 30-60 seconds (includes optimization)
Development Best Practices
Use TypeScript Strict Mode
Use TypeScript Strict Mode
ScreenPulse uses TypeScript 5.1 with strict type checking:Benefits:
tsconfig.json
- Catch errors at compile time
- Better IDE support
- Safer refactoring
Run Linter Before Committing
Run Linter Before Committing
Always lint your code before committing:
Test Changes in Both Modes
Test Changes in Both Modes
Test your changes in both development and production:Production builds may reveal issues not visible in development.
Use Component-Driven Development
Use Component-Driven Development
Develop components in isolation using Storybook:
- Create component
- Write story for component
- Test all states in Storybook
- Integrate into app
- Write unit tests
Keep Dev Server Running
Keep Dev Server Running
Keep
npm start running while developing:- Fast hot reload on changes
- Immediate feedback
- Catch compilation errors quickly
angular.jsontsconfig.jsonpackage.json- Environment files
Debugging Tips
Browser DevTools
- Angular DevTools
- Console Debugging
- Network Panel
- Source Maps
VS Code Debugging
ScreenPulse includes VS Code debug configuration in.vscode/launch.json.
To debug:
Next Steps
Architecture Overview
Learn about ScreenPulse’s application structure
Component Guide
Understand the component library
API Integration
Learn how to work with the backend API
Testing Guide
Write and run tests for your code
Resources
- Live Demo: sreenpulse.web.app
- Storybook: Component Documentation
- Backend API: GitHub Repository
- Angular Docs: angular.io/docs
- Storybook Docs: storybook.js.org