Guides & Resources

Getting Started

Prerequisites

Installation

git clone https://github.com/example/ecommerce-platform.git
cd ecommerce-platform
npm install
cp .env.example .env
# Edit .env with your database credentials
npm run db:migrate
npm run dev

Verification

After starting the server, verify installation:

How-To Guides

How to Add a New Product

  1. Login as admin: POST /api/auth/login with admin credentials
  2. Get JWT token from response
  3. Create product:
    curl -X POST http://localhost:3000/api/products \
      -H "Authorization: Bearer <token>" \
      -H "Content-Type: application/json" \
      -d '{
        "name": "Product Name",
        "description": "Product Description",
        "price": 29.99,
        "stock_quantity": 100,
        "category": "Electronics"
      }'
  4. Verify product created: GET /api/products/:id

How to Test API Endpoints

  1. Start development server: npm run dev
  2. Run tests:
    • All tests: npm test
    • E2E tests only: npm run test:e2e
    • Integration tests: npm run test:integration
    • Unit tests: npm run test:unit
  3. View coverage report: npm run test:coverage

How to Deploy to Production

  1. Build Docker image: docker build -t ecommerce-api .
  2. Push to registry: docker push ecommerce-api:latest
  3. Update ECS task definition with new image
  4. Deploy via GitHub Actions (automatic on merge to main)
  5. Verify deployment: Check CloudWatch logs for startup

Best Practices

Code Style

Testing Approach

Design Patterns

Troubleshooting

Database Connection Errors

Problem: "Unable to connect to PostgreSQL"

Solution:

Port Already in Use

Problem: "Port 3000 is already in use"

Solution:

JWT Token Expired

Problem: "401 Unauthorized - Token expired"

Solution:

Tests Failing Randomly

Problem: Tests pass locally but fail in CI

Solution:

Contributing Guidelines

  1. Fork the repository
  2. Create branch: git checkout -b feature/your-feature
  3. Write code following style guide
  4. Write tests: All new code must have tests (85%+ coverage)
  5. Run tests: npm test (all must pass)
  6. Commit: git commit -m "Add your feature"
  7. Push: git push origin feature/your-feature
  8. Submit PR with description of changes

External Resources