Skip to content

BILLION is a cutting-edge Node.js server that revolutionizes billing for businesses, offering user-friendly APIs, tax integration, and efficient management of products, services, and invoices.

License

Notifications You must be signed in to change notification settings

Tanmay000009/BILLsolutION

Repository files navigation

BILLsolutION

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.

Resources

Built With

NodeJS TypeScript Postgres TypeORM Firebase Docker Postman Jest Babel Prettier

Getting Started

Important Notes

  • 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 in src/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@123
email: testadmin@billion.com
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. (Take sample.env as a reference)

Prerequisites

Installation

  1. Clone the repo

    git clone https://github.com/Tanmay000009/BILLsolutION
  2. Setup .env with sample.env as reference

Running Server Locally

  1. Install NPM packages

    npm install

Commands

  • 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 sure synchronize: true)

  • The application will be accessible at http://localhost:3000.

Using Docker Compose

  1. Make sure you have Docker and Docker Compose installed on your system.
  2. Clone the repository.
  3. Navigate to the root directory of the project.
  4. 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.

Using Docker Image

  1. Make sure you have Docker installed on your system.
  2. Clone the repository.
  3. Navigate to the root directory of the project.
  4. Take reference from the .env.example file to create the environment file .env and update the environment variables as needed.
  5. 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>
  1. 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>
  1. If you are facing permission issues, run the following command:
chmod +x run.sh
  1. The application will be accessible at http://localhost:3000.

(back to top)

Testing

npm run test

Checklist

Must haves

  • 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

Good to haves

  • 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.

(back to top)

Quick Answers to Key Questions

  1. 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.

  2. 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.

  3. 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.

  4. 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.

(back to top)

Module Description

Auth

  • 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

Cart

  • 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

Order

  • 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

Product

  • 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

Service

  • 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

User

  • 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

(back to top)

Contact

Tanmay Vyas

GitHub LinkedIn Gmail Resume

About

BILLION is a cutting-edge Node.js server that revolutionizes billing for businesses, offering user-friendly APIs, tax integration, and efficient management of products, services, and invoices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages