A full-stack e-commerce application built with React, Node.js/Express, and PostgreSQL.
- Overview
- Architecture
- Features
- Prerequisites
- Installation
- Running the Application
- API Endpoints
- Troubleshooting
This is a modern 3-tier web application demonstrating best practices for full-stack development. The application features a React frontend, RESTful API backend, and PostgreSQL database.
- Frontend: React 18, Axios, CSS3
- Backend: Node.js, Express.js, pg (node-postgres)
- Database: PostgreSQL
- Dev Tools: nodemon, dotenv
βββββββββββββββββββ
β React Frontend β (Port 3000)
β (Tier 1) β
ββββββββββ¬βββββββββ
β HTTP/REST
β
ββββββββββΌβββββββββ
β Node.js Backend β (Port 5000)
β (Tier 2) β
ββββββββββ¬βββββββββ
β SQL
β
ββββββββββΌβββββββββ
β PostgreSQL β (Port 5432)
β (Tier 3) β
βββββββββββββββββββ
- β Product catalog display
- β RESTful API architecture
- β Database connection with PostgreSQL
- β CORS-enabled backend
- β Environment-based configuration
- β Responsive UI design
- β Error handling
- β Hot reload for development
node -v
npm -v
psql --version
git --versiongit clone <repository-url>
cd <project-folder># Start PostgreSQL
# Linux: sudo systemctl start postgresql
# macOS: brew services start postgresql
# Windows: Start via Services
# Create database
psql -U postgres
CREATE DATABASE ecommerce;
\q# Backend
cd backend
npm install
# Frontend (in new terminal)
cd frontend
npm installbackend/.env:
PORT=5000
DB_HOST=localhost
DB_USER=postgres
DB_PASS=your_postgres_password
DB_NAME=ecommercefrontend/.env:
REACT_APP_API_URL=http://localhost:5000cd backend
npm start
# or with auto-reload: npm run devExpected: β
Database connected! π Backend on http://localhost:5000
cd frontend
npm startExpected: Browser opens at http://localhost:3000
project-root/
βββ backend/
β βββ index.js # Express server
β βββ package.json # Backend dependencies
β βββ .env # Environment variables
β βββ node_modules/
βββ frontend/
β βββ public/
β β βββ index.html
β βββ src/
β β βββ App.js # Main component
β β βββ App.css
β β βββ index.js
β β βββ index.css
β βββ package.json # Frontend dependencies
β βββ .env
β βββ node_modules/
βββ .gitignore
βββ README.md
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | / |
Health check | { message, database_time } |
| GET | /api/products |
Get products | { products: [...] } |
curl http://localhost:5000/api/productsResponse:
{
"products": [
{ "id": 1, "name": "Laptop", "price": 999.99 },
{ "id": 2, "name": "Mouse", "price": 29.99 }
]
}# Kill process on port 5000
# Linux/Mac: lsof -ti:5000 | xargs kill -9
# Windows: netstat -ano | findstr :5000- Check PostgreSQL is running
- Verify credentials in
backend/.env - Test:
psql -U postgres -d ecommerce -c "SELECT NOW();"
- Ensure
app.use(cors())in backend - Check
REACT_APP_API_URLin frontend/.env
rm -rf node_modules package-lock.json
npm install- Add authentication (JWT)
- Implement shopping cart
- Add product CRUD operations
- Create admin dashboard
- Add payment integration
- Implement search/filters
- Add tests
- Deploy to production
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
MIT License - see LICENSE file for details
Happy Coding! π# π 3-Tier E-Commerce Application
A full-stack e-commerce application built with React, Node.js/Express, and PostgreSQL.
- Overview
- Architecture
- Features
- Prerequisites
- Installation
- Running the Application
- API Endpoints
- Troubleshooting
This is a modern 3-tier web application demonstrating best practices for full-stack development. The application features a React frontend, RESTful API backend, and PostgreSQL database.
- Frontend: React 18, Axios, CSS3
- Backend: Node.js, Express.js, pg (node-postgres)
- Database: PostgreSQL
- Dev Tools: nodemon, dotenv
βββββββββββββββββββ
β React Frontend β (Port 3000)
β (Tier 1) β
ββββββββββ¬βββββββββ
β HTTP/REST
β
ββββββββββΌβββββββββ
β Node.js Backend β (Port 5000)
β (Tier 2) β
ββββββββββ¬βββββββββ
β SQL
β
ββββββββββΌβββββββββ
β PostgreSQL β (Port 5432)
β (Tier 3) β
βββββββββββββββββββ
- β Product catalog display
- β RESTful API architecture
- β Database connection with PostgreSQL
- β CORS-enabled backend
- β Environment-based configuration
- β Responsive UI design
- β Error handling
- β Hot reload for development
node -v
npm -v
psql --version
git --versiongit clone <repository-url>
cd <project-folder># Start PostgreSQL
# Linux: sudo systemctl start postgresql
# macOS: brew services start postgresql
# Windows: Start via Services
# Create database
psql -U postgres
CREATE DATABASE ecommerce;
\q# Backend
cd backend
npm install
# Frontend (in new terminal)
cd frontend
npm installbackend/.env:
PORT=5000
DB_HOST=localhost
DB_USER=postgres
DB_PASS=your_postgres_password
DB_NAME=ecommercefrontend/.env:
REACT_APP_API_URL=http://localhost:5000cd backend
npm start
# or with auto-reload: npm run devExpected: β
Database connected! π Backend on http://localhost:5000
cd frontend
npm startExpected: Browser opens at http://localhost:3000
project-root/
βββ backend/
β βββ index.js # Express server
β βββ package.json # Backend dependencies
β βββ .env # Environment variables
β βββ node_modules/
βββ frontend/
β βββ public/
β β βββ index.html
β βββ src/
β β βββ App.js # Main component
β β βββ App.css
β β βββ index.js
β β βββ index.css
β βββ package.json # Frontend dependencies
β βββ .env
β βββ node_modules/
βββ .gitignore
βββ README.md
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | / |
Health check | { message, database_time } |
| GET | /api/products |
Get products | { products: [...] } |
curl http://localhost:5000/api/productsResponse:
{
"products": [
{ "id": 1, "name": "Laptop", "price": 999.99 },
{ "id": 2, "name": "Mouse", "price": 29.99 }
]
}# Kill process on port 5000
# Linux/Mac: lsof -ti:5000 | xargs kill -9
# Windows: netstat -ano | findstr :5000- Check PostgreSQL is running
- Verify credentials in
backend/.env - Test:
psql -U postgres -d ecommerce -c "SELECT NOW();"
- Ensure
app.use(cors())in backend - Check
REACT_APP_API_URLin frontend/.env
rm -rf node_modules package-lock.json
npm install- Add authentication (JWT)
- Implement shopping cart
- Add product CRUD operations
- Create admin dashboard
- Add payment integration
- Implement search/filters
- Add tests
- Deploy to production
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
MIT License - see LICENSE file for details
Happy Coding! π