Welcome to the Stationery Shop repository! This document provides an overview of the project, and setup instructions.
- Introduction
- Getting Started
- Architecture Overview
- Features
- API Modules Overview
- Database Details
- Development Standards
- Contact
This project is a backend/server-side application for a stationery shop e-commerce site built using Node.js, Express.js, Mongoose, and TypeScript following a modular monolithic architecture.
-
Product Module: Manages the product add, update, delete, and retrieve products.
-
Order Module: Handles order placement, stock updates, and calculate revenue.
-
Backend: Node.js, Express.js, Mongoose, TypeScript
-
Database: MongoDB
- Clone the repository:
git clone https://github.com/Emam-Bokhari/Stationery-Shop.git
cd Stationery-Shop
- Install dependencies:
npm install
- Start the server:
npm run start:dev
Create a .env
file with the following keys:
NODE_ENV=development
PORT=3000
DATABASE_URL=mongodb+srv://stationery-shop:[email protected]/stationery-shop-DB?retryWrites=true&w=majority&appName=Cluster0
├── dist/ # Complied Code
│ ├── app/
│ ├── app.js
│ └── server.js
├── src/ # Source code
│ ├── app/ # Main application logic
│ │ ├── config/ # Configurations
│ │ └── modules/ # Modularized application features
│ │ │ ├── order/ # Order module
│ │ │ │ ├── order.controller.ts
│ │ │ │ ├── order.interface.ts
│ │ │ │ ├── order.model.ts
│ │ │ │ ├── order.route.ts
│ │ │ │ ├── order.service.ts
│ │ │ │ └── order.validation.ts
│ │ │ ├── product/ # Product module
│ │ │ │ ├── product.controller.ts
│ │ │ │ ├── product.interface.ts
│ │ │ │ ├── product.model.ts
│ │ │ │ ├── product.route.ts
│ │ │ │ ├── product.service.ts
│ │ │ │ └── product.validation.ts
│ ├── app.ts # Application entry point
│ └── server.ts # Main server file
├── .gitignore
├── .prettierignore
├── .prettierrc
├── .README.md # Documentation file
├── .eslint.config.mjs
├── .package-lock.json
├── .package.json
├── .tsconfig.json # TypeScript configuration file
└── .vercel.json # Configuration file for deploying
Each module is feature-specific, containing:
-
Controller: Responsible for handling incoming requests (
req
) and sending appropriate responses (res
). -
Interface: Defines types and interfaces using
TypeScript
for strong type-checking. -
Model: Creates and manages
Mongoose models
for MongoDB collections. -
Service: Contains the business
logic
for the application. -
Route: Defines endpoints grouped by feature modules.
-
Validation: Uses
Zod
for validating user input to ensure data integrity.
-
Product Management:
-
Add Product: Ability to add new products to the inventory.
-
Update Product: Edit product details such as name, price, description, and stock.
-
Delete Product: Remove products from the inventory.
-
Find All Products: Retrieve a list of all products.
-
Find Product by ID: Retrieve product details by its unique identifier.
-
-
Order Management:
-
Create Order: Customers can place orders for products.
-
Calculate Revenue: The system automatically calculates the total revenue generated from orders.
-
-
Description: Handle product related operations
-
Endpoints:
GET /api/products
GET /api/products/:productId
POST /api/products
PUT /api/products/:productId
DELETE /api/products/:productId
-
Description: Order related operations
-
Endpoints:
POST /api/orders
GET /api/orders/revenue
MongoDB Collections:
-
products: Stroe products data.
-
orders: Store orders data
-
ESLint: Enforces coding standards.
-
Prettier: Ensures consistent formatting.
npm run lint
npm run format
feat
: Introduces new features..fix
: Resolves bugs.config
: Updates configurations or settings.docs
: Updates or adds documentation.
Any queries, contact with me:
-
Email: [email protected]
-
Whats App: Contact Me on WhatsApp
-
Phone: +880 131 57-73 424