BILLION is a sophisticated billing system crafted with Node.js and powered by PostgreSQL for efficient invoicing, seamless payments, and precise financial management. Leveraging the capabilities of TypeORM and TypeScript, it provides a user-friendly API for creating accounts, managing cart items, viewing accurate tax breakdowns, and confirming orders. The project is also seamlessly integrated with Postman for thorough testing and validation.
- Seed the database before starting the server. It will create an admin account, a few accounts for testing, and some products and services.
npm run seed
When seeding the database, make sure to turn
synchronize: true
insrc/utils.datasource.ts
- Seeding the database will create an admin account with the following credentials:
email: [email protected]
password: Billion@123
- Seeding also creates a few accounts for testing purposes. The credentials are:
email: [email protected]
password: Billion@123
email: [email protected]
password: Billion@123
-
Keep your Firebase service-account JSON file as
serviceAccount.json
in the root directory. -
Create a new app in Firebase Project, and add its config credentials to your
.env
. (Takesample.env
as a reference)
- Node.js (v20.3.0)
- PostgreSQL (Local/Cloud)
- Postman (Optional)
- Firebase
- Docker (Optional)
-
Clone the repo
git clone https://github.com/Tanmay000009/BILLsolutION
-
Setup
.env
withsample.env
as reference
-
Install NPM packages
npm install
-
npm run start:dev
- Start the development server. -
npm run build
- Build the project. -
npm run start
- Start the production server. -
npm run test
- Run tests. -
npm run seed
- Seed the database. (Make suresynchronize: true
) -
The application will be accessible at
http://localhost:3000
.
- Make sure you have Docker and Docker Compose installed on your system.
- Clone the repository.
- Navigate to the root directory of the project.
- Run the following command to build and start the application in Docker containers:
docker-compose up -d
OR
./compose.sh
If you are facing permission issues, run the following command:
chmod +x compose.sh
The application will be accessible at http://localhost:3000.
- Make sure you have Docker installed on your system.
- Clone the repository.
- Navigate to the root directory of the project.
- Take reference from the
.env.example
file to create the environment file.env
and update the environment variables as needed. - Seed the database using Dockerfile.dev:
./seed.sh
OR
Build the Docker image using the current directory as the build context
docker build -t <image-name>:<tag> .
Run the Docker container interactively, mapping the required port (3000 in this case) and using the .env file from the host machine as a volume inside the container
docker run -it -p 3000:3000 --env-file .env <image-name>:<tag>
After the seeding process is done, remove the Docker image
docker rmi <image-name>:<tag>
- Run the following command to build the Docker image:
./run.sh
OR
Build the Docker image using the current directory as the build context
docker build -t <image-name>:<tag> .
Run the Docker container interactively, mapping the required port (3000 in this case) and using the .env file from the host machine as a volume inside the container
docker run -it -p 3000:3000 --env-file .env <image-name>:<tag>
- If you are facing permission issues, run the following command:
chmod +x run.sh
- The application will be accessible at http://localhost:3000.
npm run test
- Create an account.
- Fetch all products and service information with their prices.
- Add a product or service to the cart.
- Remove a product or service from the cart.
- Clear the cart.
- View total bill (should include price, quantity, and tax on each item as well as total value of selected items)
- Confirm the order
- Additional API for admin to see all the orders.
- Appropriate test cases to simulate practical scenarios that you would want to test the system for.
-
Why not add a constraint for Unique Names for Products and Services?
Billion can be a B2C, or a marketplace. So to accommodate both concepts it's not enforced.
-
Why is the invoice reprocessed when creating an order?
It is to calculate Tax and Prices in real-time, as there might be updation, and currently, checkout sessions aren't accommodated.
-
Why use Firebase for authentication?
BILLION employs the robust security features provided by Firebase authentication. Firebase offers industry-standard security protocols, including secure password hashing, OAuth2-based authentication, and user identity management.
-
Why is the server configured using Firebase Client and Firebase Admin?
As the server is currently a standalone server, without any Client app, to support login and other Client functionalities which Firebase only provides in
firebase
(Client package) both are used.
- Create an account.
POST /auth/signup
- Create an Admin account.
POST /auth/signup/admin
Access: Admin
- Login to an account.
POST /auth/signin
- Forgot Password.
POST /auth/forgot-password/:email
- Update Password.
POST /auth/update-password
- Get Cart Items.
GET /cart
Access: User/Admin
- Add Items to Cart.
POST /cart
Access: User/Admin
- Update Items in Cart.
PUT /cart
Access: User/Admin
- Remove Items from Cart.
DELETE /cart
Access: User/Admin
- Clear Cart.
PUT /cart
Access: User/Admin
- Get Orders for User.
GET /order
Access: User
- Get All Orders.
GET /order/admin
Access: Admin
- Generate Invoice.
POST /order/invoice
Access: User/Admin
- Create Order.
POST /order/create
Access: User/Admin
- Process Order. (Mark order as COMPLETED or FAILED)
PUT /order/process
Access: Admin
- Cancel Order.
PUT /order/:id/cancel
Access: User
- Get All Products.
GET /product
Access: User/Admin
- Get Product by ID.
GET /product/:id
Access: User/Admin
- Create Product.
POST /product
Access: Admin
- Update Product.
PUT /product/:id
Access: Admin
- Delete Product.
DELETE /product/:id
Access: Admin
- Get All Services.
GET /service
Access: User/Admin
- Get Service by ID.
GET /service/:id
Access: User/Admin
- Create Service.
POST /service
Access: Admin
- Update Service.
PUT /service/:id
Access: Admin
- Delete Service.
DELETE /service/:id
Access: Admin
- Get User Details.
GET /user
Access: User/Admin
- Update User Details.
PUT /user
Access: User/Admin
- Make User Admin.
PUT /user/:email/admin
Access: Admin
Tanmay Vyas