Skip to content

Commit 22430ac

Browse files
authored
Merge pull request #175 from tebanieo/master
Feat: Modernizr workshop content
2 parents d95aa1e + cc396aa commit 22430ac

File tree

190 files changed

+37331
-0
lines changed

Some content is hidden

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

190 files changed

+37331
-0
lines changed

workshops/modernizr/README.md

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Online Shopping Store 🛍️
2+
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.
4+
5+
## 🚀 Features
6+
7+
### Core Functionality
8+
- **User Authentication** - JWT-based auth with secure password hashing
9+
- **Product Management** - Full CRUD operations with categories and inventory
10+
- **Shopping Cart** - Persistent cart with real-time inventory validation
11+
- **Order Processing** - Complete checkout and order management system
12+
- **Seller Dashboard** - Multi-vendor support with seller-specific operations
13+
- **Security** - Comprehensive security measures with rate limiting and input validation
14+
15+
### Advanced Features
16+
- **Load Testing** - Built-in performance testing and monitoring
17+
- **Comprehensive Testing** - Unit, integration, and E2E tests with advanced reporting
18+
- **Performance Monitoring** - Real-time performance metrics and health checks
19+
- **Database Management** - Advanced MySQL operations with connection pooling
20+
- **API Documentation** - Well-documented RESTful API endpoints
21+
22+
## 📁 Project Structure
23+
24+
```
25+
├── backend/ # Node.js/Express.js API server
26+
│ ├── src/
27+
│ │ ├── __tests__/ # Comprehensive test suite
28+
│ │ │ ├── unit/ # Unit tests
29+
│ │ │ ├── integration/ # Integration tests
30+
│ │ │ └── e2e/ # End-to-end tests
31+
│ │ ├── config/ # Configuration files
32+
│ │ ├── database/ # Database schema and CLI
33+
│ │ ├── load-testing/ # Performance testing utilities
34+
│ │ ├── middleware/ # Express middleware
35+
│ │ ├── models/ # Data models and validation
36+
│ │ ├── repositories/ # Data access layer
37+
│ │ ├── routes/ # API route handlers
38+
│ │ ├── services/ # Business logic layer
39+
│ │ ├── test-configs/ # Advanced test configurations
40+
│ │ └── utils/ # Utility functions
41+
│ ├── docs/ # Documentation
42+
│ ├── test-results/ # Test reports and dashboards
43+
│ └── coverage/ # Test coverage reports
44+
├── frontend/ # React application
45+
│ ├── src/
46+
│ │ ├── components/ # React components
47+
│ │ ├── contexts/ # React contexts
48+
│ │ ├── hooks/ # Custom React hooks
49+
│ │ ├── pages/ # Page components
50+
│ │ ├── services/ # API service layer
51+
│ │ ├── types/ # TypeScript type definitions
52+
│ │ └── utils/ # Utility functions
53+
│ └── build/ # Production build files
54+
├── integration-tests/ # Full-stack integration tests
55+
├── scripts/ # Deployment and utility scripts
56+
└── .kiro/ # Development specifications
57+
```
58+
59+
## 🛠️ Getting Started
60+
61+
### Prerequisites
62+
63+
- **Node.js** (v16 or higher)
64+
- **npm** or **yarn**
65+
- **MySQL** 8.0+
66+
- **Git**
67+
68+
### Quick Setup
69+
70+
1. **Clone the repository:**
71+
```bash
72+
git clone <repository-url>
73+
cd online-shopping-store
74+
```
75+
76+
2. **Backend Setup:**
77+
```bash
78+
cd backend
79+
npm install
80+
cp .env.example .env
81+
# Edit .env with your database credentials
82+
npm run db:init
83+
npm run db:seed
84+
npm run dev
85+
```
86+
87+
3. **Frontend Setup (in a new terminal):**
88+
```bash
89+
cd frontend
90+
npm install
91+
npm start
92+
```
93+
94+
4. **Access the application:**
95+
- Frontend: `http://localhost:3000`
96+
- Backend API: `http://localhost:8100`
97+
- API Health Check: `http://localhost:8100/api/health`
98+
99+
## 📋 Available Scripts
100+
101+
### Backend Scripts
102+
103+
#### Development
104+
- `npm run dev` - Start development server with hot reload
105+
- `npm run build` - Build TypeScript to JavaScript
106+
- `npm start` - Start production server
107+
- `npm run lint` - Run ESLint code analysis
108+
- `npm run lint:fix` - Auto-fix ESLint issues
109+
110+
#### Database Management
111+
- `npm run db:test` - Test database connection
112+
- `npm run db:init` - Initialize database schema
113+
- `npm run db:seed` - Seed database with sample data
114+
- `npm run db:reset` - Reset database (drop, init, seed)
115+
- `npm run db:clear` - Clear all seed data
116+
117+
#### Testing & Quality Assurance
118+
- `npm test` - Run unit tests (default)
119+
- `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
122+
- `npm run test:all` - Run all tests with combined reporting
123+
- `npm run test:watch` - Run tests in watch mode
124+
- `npm run test:coverage` - Generate coverage reports
125+
- `npm run test:coverage:all` - Generate coverage for all test types
126+
- `npm run test:report` - Generate combined test dashboard
127+
- `npm run test:report:open` - Generate and open test dashboard
128+
129+
#### Performance & Load Testing
130+
- `npm run load-test` - Run load testing suite
131+
- `npm run load-test:build` - Build and run load tests
132+
133+
### Frontend Scripts
134+
135+
- `npm start` - Start development server
136+
- `npm run build` - Build for production
137+
- `npm test` - Run tests
138+
- `npm run lint` - Run ESLint
139+
- `npm run eject` - Eject from Create React App (not recommended)
140+
141+
## 🏗️ Technology Stack
142+
143+
### Backend
144+
- **Runtime**: Node.js with TypeScript
145+
- **Framework**: Express.js
146+
- **Database**: MySQL 8 with connection pooling
147+
- **Authentication**: JWT with bcrypt password hashing
148+
- **Security**: Helmet.js, CORS, rate limiting, input validation
149+
- **Testing**: Jest with comprehensive test architecture
150+
- **Load Testing**: Custom performance testing framework
151+
- **Documentation**: Comprehensive API documentation
152+
153+
### Frontend
154+
- **Framework**: React 18 with TypeScript
155+
- **Styling**: Tailwind CSS
156+
- **Routing**: React Router v6
157+
- **HTTP Client**: Axios with interceptors
158+
- **State Management**: React Context API
159+
- **Build Tool**: Create React App with TypeScript template
160+
161+
### Development & DevOps
162+
- **Code Quality**: ESLint, TypeScript strict mode
163+
- **Testing**: Jest, Supertest, comprehensive test reporting
164+
- **Environment Management**: dotenv with multiple environments
165+
- **Performance Monitoring**: Built-in performance metrics
166+
- **Documentation**: Markdown with comprehensive guides
167+
168+
## 🧪 Testing Architecture
169+
170+
This project features a comprehensive testing architecture with:
171+
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
176+
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
183+
184+
### Test Commands
185+
```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
193+
npm run test:unit
194+
npm run test:integration
195+
npm run test:e2e
196+
```
197+
198+
## 🔒 Security Features
199+
200+
- **Authentication**: JWT-based stateless authentication
201+
- **Password Security**: bcrypt hashing with configurable salt rounds
202+
- **Input Validation**: Comprehensive request validation and sanitization
203+
- **Rate Limiting**: API endpoint protection against abuse
204+
- **CORS Configuration**: Secure cross-origin resource sharing
205+
- **Security Headers**: Helmet.js for security headers
206+
- **SQL Injection Protection**: Parameterized queries and ORM patterns
207+
208+
## 📊 Performance & Monitoring
209+
210+
- **Performance Metrics**: Real-time performance monitoring
211+
- **Health Checks**: Comprehensive system health endpoints
212+
- **Load Testing**: Built-in performance testing framework
213+
- **Database Optimization**: Connection pooling and query optimization
214+
- **Memory Management**: Optimized memory usage and garbage collection
215+
216+
## 🚀 Deployment Ready
217+
218+
This application is production-ready with:
219+
220+
- **Environment Configuration**: Separate configs for dev/staging/production
221+
- **Security Hardening**: Production-ready security configurations
222+
- **Performance Optimization**: Optimized for production workloads
223+
- **Monitoring**: Built-in health checks and performance metrics
224+
- **Documentation**: Comprehensive deployment guides
225+
226+
## 📚 Documentation
227+
228+
- **API Documentation**: Complete API endpoint documentation
229+
- **Testing Guide**: Comprehensive testing documentation
230+
- **Deployment Guide**: Step-by-step deployment instructions
231+
- **Security Guide**: Security best practices and configurations
232+
- **Performance Guide**: Performance optimization recommendations
233+
234+
## 🤝 Development
235+
236+
### Code Quality
237+
- **TypeScript**: Full type safety across the entire stack
238+
- **ESLint**: Consistent code style and quality enforcement
239+
- **Testing**: Comprehensive test coverage with quality gates
240+
- **Documentation**: Well-documented code and APIs
241+
242+
### Development Workflow
243+
- **Hot Reload**: Instant feedback during development
244+
- **Environment Isolation**: Separate development and production configurations
245+
- **Test-Driven Development**: Comprehensive testing at all levels
246+
- **Performance Monitoring**: Built-in performance tracking
247+
248+
## 📈 Project Status
249+
250+
**Complete Features:**
251+
- User authentication and authorization
252+
- Product and category management
253+
- Shopping cart and order processing
254+
- Seller dashboard and management
255+
- Comprehensive testing infrastructure
256+
- Security hardening and performance optimization
257+
- Load testing and monitoring capabilities
258+
259+
🚀 **Ready for Deployment:**
260+
- Production-ready configuration
261+
- Comprehensive test coverage
262+
- Security best practices implemented
263+
- Performance optimized
264+
- Documentation complete
265+
266+
---
267+
268+
For detailed setup instructions, API documentation, and deployment guides, see the respective README files in the `backend/` and `frontend/` directories.

workshops/modernizr/backend/.env

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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=63de917288d776db7e6761b183bc1fd8ffc5905565d30c635294c25cc574adc496062bc59cc4370479ecbf1e826fff3c12abe4a6ecbc5203a4d58ca24a86e6fa
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
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Database Configuration
2+
DB_HOST=localhost
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 (IMPORTANT: Change this in production!)
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
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Test Environment Configuration
2+
NODE_ENV=test
3+
JWT_SECRET=test-jwt-secret-key-for-testing-only-do-not-use-in-production-this-is-long-enough-for-security-validation
4+
JWT_EXPIRES_IN=1h
5+
6+
# Database Configuration (Test)
7+
DB_HOST=127.0.0.1
8+
DB_PORT=3306
9+
DB_USER=root
10+
DB_PASSWORD=TestDbPass123!
11+
DB_NAME=online_shopping_store_test
12+
DB_CONNECTION_LIMIT=5
13+
DB_ACQUIRE_TIMEOUT=30000
14+
DB_TIMEOUT=30000
15+
16+
# Server Configuration
17+
PORT=8101
18+
19+
# Security Configuration
20+
BCRYPT_SALT_ROUNDS=10
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# E2E Test Environment - Full Server and Database
2+
NODE_ENV=test
3+
JWT_SECRET=test-jwt-secret-key-for-testing-only-do-not-use-in-production-this-is-long-enough-for-security-validation
4+
JWT_EXPIRES_IN=1h
5+
BCRYPT_SALT_ROUNDS=10
6+
7+
# Database Configuration (Real connections for e2e tests)
8+
DB_HOST=127.0.0.1
9+
DB_PORT=3306
10+
DB_USER=root
11+
DB_PASSWORD=
12+
DB_NAME=online_shopping_store_test_e2e
13+
DB_CONNECTION_LIMIT=5
14+
DB_ACQUIRE_TIMEOUT=30000
15+
DB_TIMEOUT=30000
16+
17+
# Server Configuration
18+
PORT=8101
19+
20+
# Rate Limiting Configuration (Very Lenient for E2E Tests)
21+
RATE_LIMIT_MAX_REQUESTS=10000
22+
RATE_LIMIT_WINDOW_MS=60000
23+
RATE_LIMIT_AUTH_MAX=1000
24+
RATE_LIMIT_AUTH_WINDOW_MS=60000
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Integration Test Environment - Real Database Connections
2+
NODE_ENV=test
3+
JWT_SECRET=test-jwt-secret-key-for-testing-only-do-not-use-in-production-this-is-long-enough-for-security-validation
4+
JWT_EXPIRES_IN=1h
5+
BCRYPT_SALT_ROUNDS=10
6+
7+
# Database Configuration (Real connections for integration tests)
8+
DB_HOST=127.0.0.1
9+
DB_PORT=3306
10+
DB_USER=root
11+
DB_PASSWORD=
12+
DB_NAME=online_shopping_store_test_integration
13+
DB_CONNECTION_LIMIT=5
14+
DB_ACQUIRE_TIMEOUT=30000
15+
DB_TIMEOUT=30000
16+
17+
# Server Configuration
18+
PORT=8103
19+
20+
# Rate Limiting Configuration (Lenient for Integration Tests)
21+
RATE_LIMIT_MAX_REQUESTS=1000
22+
RATE_LIMIT_WINDOW_MS=60000
23+
RATE_LIMIT_AUTH_MAX=100
24+
RATE_LIMIT_AUTH_WINDOW_MS=60000

0 commit comments

Comments
 (0)