A full stack ecommerce application with a React frontend, an Express API, and a PostgreSQL database managed through Prisma.
- Frontend: React 18, Vite, React Router, Axios, Tailwind CSS
- Backend: Node.js, Express, TypeScript, Prisma
- Database: PostgreSQL
- Authentication: JSON Web Tokens
Install these tools before starting:
- Git
- Node.js 20 or newer
- npm
- PostgreSQL
Verify the installations:
git --version
node --version
npm --version
psql --versiongit clone https://github.com/Dev22603/ecommerce.git
cd ecommerceUsing the PostgreSQL command line:
createdb ecommerceIf createdb is unavailable, open psql or pgAdmin and create a database named ecommerce.
cd Backend
npm installCreate a local environment file.
macOS or Linux:
cp .env.example .envWindows PowerShell:
Copy-Item .env.example .envOpen Backend/.env and update the database credentials and JWT secret:
PORT=5000
NODE_ENV=development
LOG_LEVEL=INFO
DATABASE_URL=postgresql://postgres:your-password@localhost:5432/ecommerce
JWT_SECRET=replace-with-a-long-random-secret
API_URL=http://localhost:5000/api
FRONTEND_URL=http://localhost:5173Apply the database migration and load sample categories and products (seed does not create users):
npm run db:generate
npm run db:migrate:prod
npm run db:seedStart the API:
npm run devThe API runs at http://localhost:5000. Check it at http://localhost:5000/health.
Open a second terminal from the repository root:
cd Frontend
npm install
npm run devOpen http://localhost:5173, then create an account with the signup page. The seed data only includes categories and products.
Run backend commands from Backend:
npm run dev # Start the API with file watching
npm run build # Compile TypeScript
npm start # Run the compiled API
npm run db:generate # Regenerate the Prisma client
npm run db:migrate # Create and apply a development migration
npm run db:migrate:prod # Apply existing migrations
npm run db:seed # Insert sample categories and products
npm run db:studio # Open Prisma StudioRun frontend commands from Frontend:
npm run dev # Start the Vite development server
npm run build # Create a production build
npm run lint # Run ESLint
npm run preview # Preview the production buildecommerce/
|-- Backend/
| |-- prisma/ Database schema, migrations, and seed data
| `-- src/ Express API, services, repositories, and middleware
|-- Frontend/
| |-- router/ Application routing
| `-- src/ React components, pages, context, and API services
`-- README.md
Confirm PostgreSQL is running and that DATABASE_URL in Backend/.env contains the correct username, password, host, port, and database name.
Confirm the backend is running on port 5000 and FRONTEND_URL is set to http://localhost:5173.
Run:
cd Backend
npm run db:generateStop the process using port 5000 or 5173. If you change the backend port, update the frontend API URLs as well.