The backend is a .NET 9 ASP.NET API, using a PostgresSQL package.
AppContextDb.cs is a class that makes full use of Microsoft's .NET Database context. It is configured to use PostgresSQL through Program.cs.
DbInitialiser.cs is a static class that ensures databases, tables and dummy data exists. It is always called on Startup from Program.cs
Takes no parameters and simply calls the DI instance of AppContext, it returns a List of Products.
This is a function that takes a Product in its body. It modifies the Product object to set DateAdded to DateTime.UTCNow;
It then calls the DI instance of AppContext, and saves the product.
On success, It returns a JSON object with the ID of the product.
The backend tests involve testing the two endpoints.
It ensures both endpoints will carry out their expected behaviour by using an In-Memory collection to mock the AppDbContext
The frontend is a Next.js 14 React application located in frontend/product-dashboard. It provides a dashboard for viewing and analyzing products from the backend API.
- Product Table: Displays a sortable and filterable table of products.
- Stock Chart: Visualizes stock per category using a bar chart (Chart.js).
- API Integration: Fetches product data from the backend API using Axios.
- Responsive UI: Styled with Tailwind CSS.
The frontend uses the following environment variable:
NEXT_PUBLIC_API_URL: The base URL for the backend API (e.g.,http://localhost:8080/api).
- Docker
In the root folder, there is a docker compose file and a .env file which provides variables for the database, frontend and backend. Adjust this .env file to your needs.
Do not commit this env file, it is to be removed for any production releases.
From the terminal run:
docker-compose up --build