Welcome to CartApp, a project consisting of a backend powered by MongoDB and .NET, and a next.js frontend built with a shopping cart feature. Follow the steps below to set up and run the project successfully.
This repo is built by us students at Istanbul Technical University as a term project for Object Oriented Programming with C# class.
- Open a terminal or command prompt.
- Clone the repository:
git clone https://github.com/zaferemre/CartApp-MTH404.git
- Navigate to the cloned directory:
cd CartApp-MTH404
- Initialize and update the submodule:
git submodule update --init --recursive
-
Install MongoDB Compass
Download and install MongoDB Compass, a GUI for MongoDB. -
Create a Database and Cluster
- Open MongoDB Compass.
- Create a new database named
CartApp
. - Within this database, create a cluster (collection) also named
CartApp
.
-
Configure Database Connection
- Navigate to the
appsettings.json
file in the backend directory. - Locate the
ConnectionStrings
section:"ConnectionStrings": { "MongoDb": "mongodb://localhost:27017/CartApp" }
- Replace
"mongodb://localhost:27017/CartApp"
with your own MongoDB connection string if it differs.
- Navigate to the
- Open MongoDB Compass.
- Navigate to the
CartApp
database and itsCartApp
cluster. - Import the provided
CartApp.Items.json
file into the collection:- Click Import Data.
- Select the
CartApp.Items.json
file. - Click Import to add the items to the database.
- Open a terminal or command prompt in the project’s root directory.
- Start the backend server:
dotnet run
- Navigate to the
shopping-cart
directory:cd CartAPP-MTH404/shopping-cart
- Start the development server:
npm run dev
- Once the server is running, it will generate a localhost URL (e.g.,
http://localhost:3000
). Open this link in your browser to use the application.
- Ensure both the backend and frontend are running.
- Use the frontend link (
http://localhost:3000
) to access the application. - Interact with the app to test its features, such as adding items to the shopping cart.
- Ensure your MongoDB service is running locally.
- If you encounter any issues with the connection string, double-check your MongoDB setup and adjust the
appsettings.json
file accordingly. - For any issues with dependencies, use:
npm install
inside theshopping-cart
folder to install frontend dependencies.dotnet restore
inside the backend folder to restore .NET dependencies.
Enjoy exploring CartApp! 😊