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 seedWhen seeding the database, make sure to turn
synchronize: trueinsrc/utils.datasource.ts
- Seeding the database will create an admin account with the following credentials:
email: admin@billion.com
password: Billion@123- Seeding also creates a few accounts for testing purposes. The credentials are:
email: testuser@billion.com
password: Billion@123email: testadmin@billion.com
password: Billion@123-
Keep your Firebase service-account JSON file as
serviceAccount.jsonin the root directory. -
Create a new app in Firebase Project, and add its config credentials to your
.env. (Takesample.envas 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
.envwithsample.envas 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.examplefile to create the environment file.envand 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/adminAccess: 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 /cartAccess: User/Admin - Add Items to Cart.
POST /cartAccess: User/Admin - Update Items in Cart.
PUT /cartAccess: User/Admin - Remove Items from Cart.
DELETE /cartAccess: User/Admin - Clear Cart.
PUT /cartAccess: User/Admin
- Get Orders for User.
GET /orderAccess: User - Get All Orders.
GET /order/adminAccess: Admin - Generate Invoice.
POST /order/invoiceAccess: User/Admin - Create Order.
POST /order/createAccess: User/Admin - Process Order. (Mark order as COMPLETED or FAILED)
PUT /order/processAccess: Admin - Cancel Order.
PUT /order/:id/cancelAccess: User
- Get All Products.
GET /productAccess: User/Admin - Get Product by ID.
GET /product/:idAccess: User/Admin - Create Product.
POST /productAccess: Admin - Update Product.
PUT /product/:idAccess: Admin - Delete Product.
DELETE /product/:idAccess: Admin
- Get All Services.
GET /serviceAccess: User/Admin - Get Service by ID.
GET /service/:idAccess: User/Admin - Create Service.
POST /serviceAccess: Admin - Update Service.
PUT /service/:idAccess: Admin - Delete Service.
DELETE /service/:idAccess: Admin
- Get User Details.
GET /userAccess: User/Admin - Update User Details.
PUT /userAccess: User/Admin - Make User Admin.
PUT /user/:email/adminAccess: Admin
Tanmay Vyas