Welcome to the Invoice Dashboard! This project is built using Fastify for the backend, Prisma for database management, and PostgreSQL as the database. The backend is responsible for managing invoice data and serves API routes for handling invoices.
Make sure you have the following tools installed on your machine:
- Node.js (v14 or above)
- PostgreSQL
- npm (comes with Node.js)
- Prisma (installed through npm)
- Postman (to test API endpoints)
-
Clone the repository:
git clone <repository-url> cd invoice-dashboard
-
Install dependencies:
npm install
-
Create the PostgreSQL database: Ensure you have PostgreSQL running locally or within your environment. Create a database named
invoiceDB. -
Set up environment variables: Create a
.envfile in the root directory and add the following:DATABASE_URL="postgresql://<your_user>:<your_password>@localhost:5432/invoiceDB?schema=public"Replace <your_user> and <your_password> with your PostgreSQL username and password.
-
Run Prisma migrations: After setting up the environment variables, apply the database schema by running:
npx prisma migrate dev --name init
-
Generate Prisma Client: Ensure the Prisma Client is generated and synced with the schema:
npx prisma generate
To run the Fastify server locally:
npx ts-node src/server.tsRunning the Frontend Navigate to the client folder:
cd clientInstall client dependencies:
npm installStart the React development server:
npm run devThe frontend will be available at http://localhost:5173.
🛠️ API Endpoints Upload an Invoice File You can upload an invoice PDF file using Postman:
Open Postman and create a new POST request.
Set the request URL to:
http://localhost:3000/api/upload-invoiceIn the Body tab, select form-data and add a key called file. Select the PDF file you want to upload as the value.
Send the request. If the upload is successful, you should receive a 201 Created status and the invoice data.