This a sales manager application to manage the revenue data
Below image shows the schema diagram for the sales management application
Make sure you have the following installed:
- Node.js (LTS version)
- Yarn
- PostgreSQL
Place your seed.csv file and any other csv files inside the data
folder
-
Clone the repository:
git clone https://github.com/Sathish-Kumar-R6/sales-management.git
-
Install the dependencies:
cd sales-management yarn
-
Create a
.env
file in the root directory and add the following: Replace username and password with your fieldsDATABASE_URL=postgresql://<username>:<password>@localhost:5432/sales_db?schema=public PORT=3000 HOST=localhost NODE_ENV=development
-
Run Prisma to generate the database tables:
yarn prisma:generate
-
Push the schema to your PostgreSQL database:
yarn db:push
-
Seed the database: Remember before running this command make sure you have seed.csv file inside
data/seed.csv
yarn seed
-
To generate swagger doc first and start the development server, use the following command:
yarn doc:generate yarn dev
The app will be running at http://localhost:3000.
-
Swagger UI:
- The Swagger UI will be available at http://localhost:3000/api-docs.
- It will display the auto-generated API documentation based on your routes and annotations.
-
Upload CSV to Refresh Data
- Route:
POST /api/refresh
- Description: Specify a CSV file path to reload data to db.
- Scheduler: This api also automatically triggers everyday at 00:00 with the specified path to csv file
- Route:
-
Get Revenue Details with Filters
- Route:
GET /api/revenue-details
- Description: Apply filters and retrieve the sales revenue details.
- Query Parameters:
start_date
: (Optional) Start date for revenue data.end_date
: (Optional) End date for revenue data.region
: (Optional) Filter by region.product_id
: (Optional) Filter by product.
- Route: