This is a fully-featured Role based( User, Admin ) E-Commerce Application built with TypeScript, Express.js, PostgreSQL, and Prisma. This project is designed for scalability and robustness, simplifying online store operations with efficient product listings, user management, and order processing.The codebase is feature-based Architecure (Design Pattern), organized for modularity and maintainability.
- User authentication and authorization
- Product listing and management
- Shopping cart functionality
- Order processing and management
- Backend:
- TypeScript
- Express.js
- PostgreSQL
- Prisma
- Tools and Libraries:
- Nodemon
- Zod
- Swagger
- ESLint (for code linting)
- Prettier (for code formatting)
- Node.js (version v20.14.0)
- PostgreSQL (version 16)
Tip
Database Schema Files : Database Schema
-
Clone the repository:
git clone https://github.com/theeeep/practical-round-task.git cd practical-round-task
-
Install dependencies:
npm install
-
Set up the Database and Environment file:
-
Create a PostgreSQL database
-
Update the
.env
file with your database connection details:DATABASE_URL=postgresql://user:password@localhost:5432/ecommerce-backend?schema=public"
- Update the
.env
file with your PORT:
PORT=YOUR_PORT
- Update the
.env
file with your jwt secret:
JWT_SECRET=YOUR_SECRET_KEY
- Update the
-
-
Run the Prisma migrations to set up the database schema:
npx prisma migrate dev
-
Start the development server:
npm run start:dev
npm start:dev
: Starts the development servernpm run start:prod
: Builds the project for productionnpm run build
: Starts the built projectnpm test
: Runs tests using Jest
Note
Access the Swagger UI for API Documentation at http://localhost:3000/api-docs
├── Readme.md
├── collection.json
├── collection.yml
├── eslint.config.mjs
├── jest.config.ts
├── nodemon.json
├── openapi.json
├── package-lock.json
├── package.json
├── prisma
│ ├── migrations
│ └── schema.prisma
├── src
│ ├── app.ts
│ ├── config
│ │ ├── config.ts
│ │ └── db.config.ts
│ ├── errorHandler.ts
│ ├── exceptions
│ │ ├── badRequests.ts
│ │ ├── internalException.ts
│ │ ├── notFound.ts
│ │ ├── root.ts
│ │ ├── unauthorized.ts
│ │ └── validation.ts
│ ├── features
│ │ ├── auth
│ │ │ ├── authController.ts
│ │ │ └── authRouter.ts
│ │ ├── cart
│ │ │ ├── cartController.ts
│ │ │ └── cartRouter.ts
│ │ ├── orders
│ │ │ ├── orderController.ts
│ │ │ └── orderRouter.ts
│ │ ├── products
│ │ │ ├── productController.ts
│ │ │ └── productRouter.ts
│ │ ├── userAddress
│ │ │ ├── addressController.ts
│ │ │ └── addressRouter.ts
│ │ └── users
│ │ ├── userController.ts
│ │ └── userRouter.ts
│ ├── middlewares
│ │ ├── admin.ts
│ │ ├── auth.ts
│ │ └── errors.ts
│ ├── rootRouter.ts
│ ├── schema
│ │ ├── cart.schema.ts
│ │ └── users.schema.ts
│ ├── server.ts
│ └── types
│ └── express.d.ts
├── tsconfig.build.json
└── tsconfig.json
For any inquiries or support, feel free to contact me at itz.deeepak@gmail.com or open an issue on GitHub.