Skip to content

Commit fd0d22b

Browse files
committed
feat: Modernizr workshop, updated readmes, cleaned up folder structure, added mysql logs for central reference, adding python script to parse the logs, fixed some UI elements in shopping cart, registration and seller dashboard
1 parent ff8a01c commit fd0d22b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1378
-3433
lines changed

workshops/modernizr/README.md

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Online Shopping Store 🛍️
22

3-
A production-ready, full-stack e-commerce application built with Node.js/TypeScript backend and React/TypeScript frontend. Features comprehensive user authentication, product management, order processing, and advanced testing infrastructure.
3+
A full-stack e-commerce application built with Node.js/TypeScript backend and React/TypeScript frontend. Features comprehensive user authentication, product management, order processing, and advanced testing infrastructure.
44

55
## 🚀 Features
66

@@ -52,8 +52,8 @@ A production-ready, full-stack e-commerce application built with Node.js/TypeScr
5252
│ │ └── utils/ # Utility functions
5353
│ └── build/ # Production build files
5454
├── integration-tests/ # Full-stack integration tests
55-
── scripts/ # Deployment and utility scripts
56-
└── .kiro/ # Development specifications
55+
── scripts/ # Deployment and utility scripts
56+
5757
```
5858

5959
## 🛠️ Getting Started
@@ -104,6 +104,8 @@ A production-ready, full-stack e-commerce application built with Node.js/TypeScr
104104
- `npm run dev` - Start development server with hot reload
105105
- `npm run build` - Build TypeScript to JavaScript
106106
- `npm start` - Start production server
107+
- `npm run clean` - Clean build artifacts, coverage, and cache
108+
- `npm run clean:all` - Clean everything including node_modules
107109
- `npm run lint` - Run ESLint code analysis
108110
- `npm run lint:fix` - Auto-fix ESLint issues
109111

@@ -113,12 +115,14 @@ A production-ready, full-stack e-commerce application built with Node.js/TypeScr
113115
- `npm run db:seed` - Seed database with sample data
114116
- `npm run db:reset` - Reset database (drop, init, seed)
115117
- `npm run db:clear` - Clear all seed data
118+
- `npm run db:setup-integration` - Setup integration test database (auto-run before integration tests)
119+
- `npm run db:setup-e2e` - Setup e2e test database (auto-run before e2e tests)
116120

117121
#### Testing & Quality Assurance
118122
- `npm test` - Run unit tests (default)
119123
- `npm run test:unit` - Run unit tests with reporting
120-
- `npm run test:integration` - Run integration tests
121-
- `npm run test:e2e` - Run end-to-end tests
124+
- `npm run test:integration` - Run integration tests (auto-sets up test database)
125+
- `npm run test:e2e` - Run end-to-end tests (auto-builds and sets up test database)
122126
- `npm run test:all` - Run all tests with combined reporting
123127
- `npm run test:watch` - Run tests in watch mode
124128
- `npm run test:coverage` - Generate coverage reports
@@ -135,7 +139,8 @@ A production-ready, full-stack e-commerce application built with Node.js/TypeScr
135139
- `npm start` - Start development server
136140
- `npm run build` - Build for production
137141
- `npm test` - Run tests
138-
- `npm run lint` - Run ESLint
142+
- `npm run clean` - Clean build artifacts and cache
143+
- `npm run clean:all` - Clean everything including node_modules
139144
- `npm run eject` - Eject from Create React App (not recommended)
140145

141146
## 🏗️ Technology Stack
@@ -165,35 +170,65 @@ A production-ready, full-stack e-commerce application built with Node.js/TypeScr
165170
- **Performance Monitoring**: Built-in performance metrics
166171
- **Documentation**: Markdown with comprehensive guides
167172

168-
## 🧪 Testing Architecture
173+
## 🧪 Testing
169174

170-
This project features a comprehensive testing architecture with:
175+
This project features a comprehensive testing architecture with unit, integration, and end-to-end tests.
171176

172-
### Test Types
173-
- **Unit Tests** (284 tests) - Fast, isolated component testing
174-
- **Integration Tests** - Component interaction testing
175-
- **End-to-End Tests** - Complete user workflow testing
177+
### Running Tests
176178

177-
### Test Features
178-
- **Advanced Reporting** - HTML dashboards with performance metrics
179-
- **Coverage Analysis** - Detailed coverage reports for all test types
180-
- **Performance Monitoring** - Automatic detection of slow tests
181-
- **Reliability Improvements** - Retry mechanisms and flaky test detection
182-
- **CI/CD Integration** - JUnit XML reports for automated pipelines
179+
All tests include automatic database setup - just run the commands and everything will be configured for you:
183180

184-
### Test Commands
181+
#### Unit Tests
185182
```bash
186-
# Run all tests with comprehensive reporting
187-
npm run test:all
188-
189-
# View test dashboard
190-
npm run test:report:open
191-
192-
# Run specific test types
183+
cd backend
193184
npm run test:unit
185+
```
186+
- Fast, isolated component testing
187+
- No database setup required
188+
- Tests business logic, utilities, and individual components
189+
190+
#### Integration Tests
191+
```bash
192+
cd backend
194193
npm run test:integration
194+
```
195+
- Tests component interactions with real database
196+
- Automatically sets up `online_shopping_store_test_integration` database
197+
- Tests API endpoints, services, and database operations
198+
199+
#### End-to-End Tests
200+
```bash
201+
cd backend
195202
npm run test:e2e
196203
```
204+
- Complete user workflow testing
205+
- Automatically builds the application and sets up `online_shopping_store_test_e2e` database
206+
- Tests full application flows from frontend to database
207+
208+
#### Run All Tests
209+
```bash
210+
cd backend
211+
npm run test:all
212+
```
213+
- Runs unit, integration, and e2e tests in sequence
214+
- Generates comprehensive test reports and coverage
215+
- Creates HTML dashboard with results
216+
217+
#### Test Reports
218+
```bash
219+
cd backend
220+
npm run test:report:open
221+
```
222+
- Generates and opens interactive test dashboard
223+
- Shows test results, coverage, and performance metrics
224+
- Available at `backend/test-results/combined/dashboard.html`
225+
226+
### Test Features
227+
- **Automatic Setup** - All database setup handled automatically
228+
- **Isolated Environments** - Each test type uses separate databases
229+
- **Advanced Reporting** - HTML dashboards with performance metrics
230+
- **Coverage Analysis** - Detailed coverage reports for all test types
231+
- **Performance Monitoring** - Automatic detection of slow tests
197232

198233
## 🔒 Security Features
199234

@@ -213,15 +248,15 @@ npm run test:e2e
213248
- **Database Optimization**: Connection pooling and query optimization
214249
- **Memory Management**: Optimized memory usage and garbage collection
215250

216-
## 🚀 Deployment Ready
251+
## 🚀 Deployment
217252

218-
This application is production-ready with:
253+
This application includes:
219254

220-
- **Environment Configuration**: Separate configs for dev/staging/production
221-
- **Security Hardening**: Production-ready security configurations
222-
- **Performance Optimization**: Optimized for production workloads
255+
- **Environment Configuration**: Separate configs for different environments
256+
- **Security Features**: Security configurations and best practices
257+
- **Performance Optimization**: Optimized for better performance
223258
- **Monitoring**: Built-in health checks and performance metrics
224-
- **Documentation**: Comprehensive deployment guides
259+
- **Documentation**: Comprehensive setup and deployment guides
225260

226261
## 📚 Documentation
227262

@@ -256,9 +291,8 @@ This application is production-ready with:
256291
- Security hardening and performance optimization
257292
- Load testing and monitoring capabilities
258293

259-
🚀 **Ready for Deployment:**
260-
- Production-ready configuration
261-
- Comprehensive test coverage
294+
🚀 **Development Status:**
295+
- Comprehensive test coverage with automated setup
262296
- Security best practices implemented
263297
- Performance optimized
264298
- Documentation complete

workshops/modernizr/backend/.env

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Database Configuration
2+
DB_HOST=127.0.0.1
3+
DB_PORT=3306
4+
DB_USER=root
5+
DB_PASSWORD=
6+
DB_NAME=online_shopping_store
7+
DB_CONNECTION_LIMIT=10
8+
DB_ACQUIRE_TIMEOUT=60000
9+
DB_TIMEOUT=60000
10+
11+
# Server Configuration
12+
PORT=8100
13+
14+
# JWT Configuration
15+
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production-make-it-long-and-random
16+
JWT_EXPIRES_IN=24h
17+
18+
# Environment
19+
NODE_ENV=development
20+
21+
# Security Configuration
22+
BCRYPT_SALT_ROUNDS=12
23+
24+
# Performance Monitoring Thresholds
25+
MEMORY_WARNING_THRESHOLD=85
26+
MEMORY_CRITICAL_THRESHOLD=95
27+
28+
# Rate Limiting Configuration (for load testing)
29+
RATE_LIMIT_AUTH_MAX=1000
30+
RATE_LIMIT_AUTH_WINDOW_MS=60000
31+
32+
# Global Rate Limiting Configuration (for load testing)
33+
RATE_LIMIT_MAX_REQUESTS=10000
34+
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/.env.example

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,19 @@ JWT_SECRET=your-super-secret-jwt-key-change-this-in-production-make-it-long-and-
1616
JWT_EXPIRES_IN=24h
1717

1818
# Environment
19-
NODE_ENV=development
19+
NODE_ENV=development
20+
21+
# Security Configuration
22+
BCRYPT_SALT_ROUNDS=12
23+
24+
# Performance Monitoring Thresholds
25+
MEMORY_WARNING_THRESHOLD=85
26+
MEMORY_CRITICAL_THRESHOLD=95
27+
28+
# Rate Limiting Configuration
29+
RATE_LIMIT_AUTH_MAX=1000
30+
RATE_LIMIT_AUTH_WINDOW_MS=60000
31+
32+
# Global Rate Limiting Configuration
33+
RATE_LIMIT_MAX_REQUESTS=10000
34+
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/.env.test

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ JWT_EXPIRES_IN=1h
77
DB_HOST=127.0.0.1
88
DB_PORT=3306
99
DB_USER=root
10-
DB_PASSWORD=TestDbPass123!
10+
DB_PASSWORD=
1111
DB_NAME=online_shopping_store_test
1212
DB_CONNECTION_LIMIT=5
1313
DB_ACQUIRE_TIMEOUT=30000
@@ -17,4 +17,14 @@ DB_TIMEOUT=30000
1717
PORT=8101
1818

1919
# Security Configuration
20-
BCRYPT_SALT_ROUNDS=10
20+
BCRYPT_SALT_ROUNDS=10
21+
22+
# Performance Monitoring Thresholds
23+
MEMORY_WARNING_THRESHOLD=85
24+
MEMORY_CRITICAL_THRESHOLD=95
25+
26+
# Rate Limiting Configuration
27+
RATE_LIMIT_AUTH_MAX=100
28+
RATE_LIMIT_AUTH_WINDOW_MS=60000
29+
RATE_LIMIT_MAX_REQUESTS=1000
30+
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/.env.test.e2e

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ DB_TIMEOUT=30000
1717
# Server Configuration
1818
PORT=8101
1919

20+
# Performance Monitoring Thresholds
21+
MEMORY_WARNING_THRESHOLD=85
22+
MEMORY_CRITICAL_THRESHOLD=95
23+
2024
# Rate Limiting Configuration (Very Lenient for E2E Tests)
2125
RATE_LIMIT_MAX_REQUESTS=10000
2226
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/.env.test.integration

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ DB_TIMEOUT=30000
1717
# Server Configuration
1818
PORT=8103
1919

20+
# Performance Monitoring Thresholds
21+
MEMORY_WARNING_THRESHOLD=85
22+
MEMORY_CRITICAL_THRESHOLD=95
23+
2024
# Rate Limiting Configuration (Lenient for Integration Tests)
2125
RATE_LIMIT_MAX_REQUESTS=1000
2226
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/.env.test.unit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ DB_NAME=test_unit_db
1414
# Server Configuration
1515
PORT=8102
1616

17+
# Performance Monitoring Thresholds
18+
MEMORY_WARNING_THRESHOLD=85
19+
MEMORY_CRITICAL_THRESHOLD=95
20+
1721
# Rate Limiting Configuration (Lenient for Unit Tests)
1822
RATE_LIMIT_MAX_REQUESTS=1000
1923
RATE_LIMIT_WINDOW_MS=60000

workshops/modernizr/backend/README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,21 @@ The API will be available at `http://localhost:8100`
8282
### Testing
8383
- `npm test` - Run unit tests (fast feedback)
8484
- `npm run test:unit` - Run unit tests only
85-
- `npm run test:integration` - Run integration tests
86-
- `npm run test:e2e` - Run end-to-end tests
87-
- `npm run test:all` - Run all test types in sequence
85+
- `npm run test:integration` - Run integration tests (auto-sets up test database)
86+
- `npm run test:e2e` - Run end-to-end tests (auto-builds and sets up test database)
87+
- `npm run test:all` - Run all test types in sequence with comprehensive reporting
8888
- `npm run test:watch` - Run tests in watch mode
8989
- `npm run test:coverage` - Run tests with coverage report
90+
- `npm run test:report:open` - Generate and open interactive test dashboard
9091

9192
### Database Management
9293
- `npm run db:test` - Test database connection
9394
- `npm run db:init` - Initialize database schema
9495
- `npm run db:seed` - Seed database with sample data
9596
- `npm run db:reset` - Reset database (drop, init, seed)
9697
- `npm run db:clear` - Clear all seed data
98+
- `npm run db:setup-integration` - Setup integration test database (auto-run before integration tests)
99+
- `npm run db:setup-e2e` - Setup e2e test database (auto-run before e2e tests)
97100

98101
### Load Testing
99102
- `npm run load-test` - Run load testing suite
@@ -157,10 +160,20 @@ backend/
157160
| `DB_USER` | Database username | root |
158161
| `DB_PASSWORD` | Database password | - |
159162
| `DB_NAME` | Database name | online_shopping_store |
163+
| `DB_CONNECTION_LIMIT` | Max database connections | 10 |
164+
| `DB_ACQUIRE_TIMEOUT` | Connection acquire timeout (ms) | 60000 |
165+
| `DB_TIMEOUT` | Query timeout (ms) | 60000 |
160166
| `PORT` | Server port | 8100 |
161167
| `JWT_SECRET` | JWT signing secret | - |
162168
| `JWT_EXPIRES_IN` | JWT expiration time | 24h |
163169
| `NODE_ENV` | Environment | development |
170+
| `BCRYPT_SALT_ROUNDS` | Password hashing salt rounds | 12 |
171+
| `MEMORY_WARNING_THRESHOLD` | Memory warning threshold (%) | 85 |
172+
| `MEMORY_CRITICAL_THRESHOLD` | Memory critical threshold (%) | 95 |
173+
| `RATE_LIMIT_MAX_REQUESTS` | Global rate limit max requests | 10000 |
174+
| `RATE_LIMIT_WINDOW_MS` | Global rate limit window (ms) | 60000 |
175+
| `RATE_LIMIT_AUTH_MAX` | Auth rate limit max requests | 1000 |
176+
| `RATE_LIMIT_AUTH_WINDOW_MS` | Auth rate limit window (ms) | 60000 |
164177

165178
## Database Schema
166179

@@ -193,32 +206,41 @@ npm run load-test -- --users 100 --duration 60s --endpoint /api/products
193206

194207
### Testing
195208

196-
Our testing architecture follows the testing pyramid with three distinct test types:
209+
Our testing architecture follows the testing pyramid with automatic database setup:
197210

198-
**Unit Tests** (`npm test` or `npm run test:unit`)
211+
**Unit Tests** (`npm run test:unit`)
199212
- Fast execution (< 10 seconds)
200213
- Test individual functions/classes in isolation
201214
- All external dependencies mocked
215+
- No database setup required
202216
- Located in `src/__tests__/unit/`
203217

204218
**Integration Tests** (`npm run test:integration`)
205219
- Medium execution speed (< 60 seconds)
206220
- Test component interactions with real database
221+
- Automatically sets up `online_shopping_store_test_integration` database
207222
- External services mocked
208223
- Located in `src/__tests__/integration/`
209224

210225
**End-to-End Tests** (`npm run test:e2e`)
211226
- Comprehensive testing (< 120 seconds)
212227
- Test complete user workflows
228+
- Automatically builds application and sets up `online_shopping_store_test_e2e` database
213229
- Real server + database + HTTP requests
214230
- Located in `src/__tests__/e2e/`
215231

232+
**Test Reports** (`npm run test:report:open`)
233+
- Interactive HTML dashboard with test results
234+
- Coverage analysis and performance metrics
235+
- Available at `test-results/combined/dashboard.html`
236+
216237
**Guidelines:**
238+
- All database setup is automatic - just run the test commands
239+
- Each test type uses isolated databases to prevent interference
217240
- Write unit tests for business logic
218241
- Write integration tests for component interactions
219242
- Write E2E tests for critical user workflows
220243
- Maintain test coverage above 80%
221-
- See [Testing Guide](docs/TESTING.md) for detailed documentation
222244

223245
### Security
224246
- Always validate input data

0 commit comments

Comments
 (0)