Kontact is a simple MERN (MongoDB, Express, React, Node.js) stack CRUD application for managing contacts.
Before you begin, ensure you have met the following requirements:
Clone the repository:
git clone https://github.com/imkrrish/mern-kontact-app.git
cd mern-kontact-app
-
Navigate to the backend directory:
cd backend
-
Install dependencies:
npm install
-
Set up environment variables:
Create a .env file in the backend directory with following environment variables to your .env file:
MONGODB_URI=mongodb://127.0.0.1:27017/Kontact NODE_ENV=dev PORT=5000 RATE_LIMIT_TIME=3000 RATE_LIMIT_REQUEST=100
-
Start the development server:
npm run start:dev
-
In a new terminal, navigate back to the project root folder (where the frontend folder is located) and Install frontend dependencies:
cd frontend npm install
-
Set up environment variables: Create a .env.local file in the frontend directory with following environment variables to your .env file:
NEXT_PUBLIC_API_BASE_URL=http://localhost:5000
-
Start the development server:
npm run dev
Access the frontend application at http://localhost:3000
The backend API is available at http://localhost:5000
- GET
/api/contacts
- Retrieve all contacts. - GET
/api/contacts/:id
- Retrieve a specific contact by ID. - POST
/api/contacts
- Create a new contact. - PUT
/api/contacts/:id
- Update an existing contact. - DELETE
/api/contacts/:id
- Delete a contact.
-
To retrieve contacts sorted by name in ascending order:
/api/contacts?sortBy=name&sortOrder=ASC
-
To filter contacts by name:
/api/contacts?name=anyname
npm run build
: Build the TypeScript code.npm start
: Start the production server.npm run lint
: Run ESLint to lint TypeScript files.npm run lint-and-fix
: Run ESLint with automatic fixes.npm run prettier-format
: Format TypeScript files using Prettier.npm test
: Run tests (if available).
npm run build
: Build the Next.js application.npm run start
: Start the production Next.js server.npm run lint
: Run ESLint to lint TypeScript and React files.
Contributions are welcomed!