Skip to content

ayushr23/ecp

Repository files navigation

E-Commerce Platform

A modern, scalable full-stack e-commerce platform built with React, TypeScript, Node.js, Express, PostgreSQL, and Stripe integration.

🚀 Features

Frontend

  • Modern React 18 with TypeScript
  • Vite for fast development and optimized builds
  • Tailwind CSS for responsive design
  • JWT-based authentication
  • Shopping cart with persistent storage
  • Product browsing and filtering
  • Stripe payment integration
  • User dashboard
  • Admin panel for product management

Backend

  • Node.js with Express and TypeScript
  • PostgreSQL with Prisma ORM
  • JWT authentication with refresh tokens
  • Role-based access control (User/Admin)
  • RESTful API design
  • Input validation with Zod
  • Error handling and logging
  • Stripe API integration
  • AWS S3 integration for product images

📋 Prerequisites

  • Node.js 18+
  • PostgreSQL 14+
  • npm or yarn
  • Docker & Docker Compose (optional)
  • Stripe account (for payments)
  • AWS account (for S3 storage)

🛠️ Installation

1. Clone the Repository

git clone <repository-url>
cd ecommerce-platform

2. Setup Backend

cd backend

# Copy environment variables
cp .env.example .env

# Install dependencies
npm install

# Setup database
npm run db:migrate
npm run db:seed

# Start development server
npm run dev

The backend will run on http://localhost:5000

3. Setup Frontend

cd frontend

# Copy environment variables
cp .env.example .env.local

# Install dependencies
npm install

# Start development server
npm run dev

The frontend will run on http://localhost:5173

🐳 Docker Setup

Using Docker Compose

# Start all services
docker-compose up

# Run migrations
docker-compose exec backend npm run db:migrate

# Seed database
docker-compose exec backend npm run db:seed

📚 API Documentation

Authentication Endpoints

POST /api/auth/register Register a new user

{
  "name": "John Doe",
  "email": "john@example.com",
  "password": "SecurePassword123"
}

POST /api/auth/login Login user

{
  "email": "john@example.com",
  "password": "SecurePassword123"
}

Products Endpoints

GET /api/products Get all products (with optional filters)

GET /api/products/:id Get single product details

POST /api/products (Admin only) Create new product

{
  "name": "Product Name",
  "description": "Product description",
  "price": 99.99,
  "stock": 100,
  "category": "Electronics"
}

🔐 Environment Variables

Backend (.env)

DATABASE_URL=postgresql://user:password@localhost:5432/ecommerce
JWT_SECRET=your-secret-key
STRIPE_SECRET_KEY=sk_test_...
AWS_ACCESS_KEY_ID=your-key
AWS_SECRET_ACCESS_KEY=your-secret
AWS_S3_BUCKET=your-bucket
NODE_ENV=development
PORT=5000

Frontend (.env.local)

VITE_API_URL=http://localhost:5000/api
VITE_STRIPE_PUBLIC_KEY=pk_test_...

📂 Project Structure

ecommerce-platform/
├── frontend/
│   ├── src/
│   │   ├── components/
│   │   ├── pages/
│   │   ├── hooks/
│   │   ├── contexts/
│   │   ├── utils/
│   │   ├── types/
│   │   ├── styles/
│   │   └── App.tsx
│   └── package.json
├── backend/
│   ├── src/
│   │   ├── controllers/
│   │   ├── middleware/
│   │   ├── models/
│   │   ├── routes/
│   │   ├── services/
│   │   ├── utils/
│   │   ├── config.ts
│   │   └── app.ts
│   ├── prisma/
│   └── package.json
└── docker-compose.yml

🧪 Testing

Frontend

cd frontend
npm run test
npm run test:ui

Backend

cd backend
npm run test

🚀 Deployment

Docker

# Build images
docker build -t ecommerce-backend ./backend
docker build -t ecommerce-frontend ./frontend

# Run with Docker Compose
docker-compose up -d

AWS Deployment

The project includes Docker configuration for AWS Elastic Beanstalk deployment. See deployment documentation for setup instructions.

🔧 Development

Code Quality

# Frontend
cd frontend
npm run type-check
npm run lint

# Backend
cd backend
npm run type-check
npm run lint

Database Management

# Create migration
cd backend
npm run db:migrate

# View database in studio
npm run db:studio

# Seed database
npm run db:seed

📝 API Response Format

All API responses follow this format:

{
  "success": true,
  "data": { /* response data */ },
  "message": "Operation successful"
}

Error responses:

{
  "success": false,
  "error": "Error message"
}

🤝 Contributing

  1. Create a feature branch (git checkout -b feature/amazing-feature)
  2. Commit changes (git commit -m 'Add amazing feature')
  3. Push to branch (git push origin feature/amazing-feature)
  4. Open a Pull Request

📄 License

This project is licensed under the MIT License.

🆘 Support

For issues and questions:

  • Open an issue on GitHub
  • Check existing documentation
  • Contact the development team

🎯 Roadmap

  • Advanced product filtering
  • Real-time notifications
  • Product recommendations
  • Email notifications
  • PDF invoices
  • Multi-language support
  • PWA capabilities
  • GraphQL API
  • Advanced analytics
  • Inventory management system

Last Updated: January 2024

About

Full-Stack E-Commerce Platform – Developed with React, TypeScript, Node.js, PostgreSQL. Implemented user authentication, product management, and shopping cart. Deployed on AWS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors