Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 78 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,88 @@
# Help Center API Assignment
Card Search Application
# Overview

## Instructions
This project is a simple card search application that allows users to search for cards based on their titles. The project is divided into two main folders: frontend and backend. The frontend handles the user interface and interactions, while the backend manages the card data and provides an API for adding and retrieving cards.

## Project Structure

- `frontend`: Contains the React application for the frontend.
- `backend`: Contains the Node.js/Express application for the backend.

# Getting Started

Follow these steps to set up and run the project locally.

1. **Clone the Repository**

First, clone the repository to your local machine using Git:

```bash
git clone <repository-url>
```

Replace `<repository-url>` with the actual URL of your Git repository.

2. **Set Up the Frontend**

Navigate to the frontend folder and install the necessary dependencies:

```bash
cd frontend
npm install
```

3. **Set Up the Backend**

Navigate to the backend folder and install the necessary dependencies:

1. **Clone the Repository:**
```bash
git clone https://github.com/iAmritMalviya/fullstack-assignment
cd fullstack-assignment
cd ../backend
npm install
```

2. **Frontend:**
- Create a React app in the `frontend` folder.
- Follow the instructions in `frontend.md` to complete the frontend.
4. **Create the .env File**

In the backend folder, create a `.env` file by referring to the `.env.sample` file. Add the required environment variables as specified in the sample file.

5. **Run the Applications**

Now that everything is set up, you can run both the frontend and backend applications.

To run the frontend:

```bash
cd ../frontend
npm run dev
```

To run the backend:

```bash
cd ../backend
npm run dev
```

6. **Add Cards via Postman**

To start using the search functionality, you need to add some cards to the backend using Postman or any other API testing tool.

Open Postman and send a POST request to `http://localhost:3000/cards`.

Use the following JSON structure to add a card:

```json
{
"title": "Sample Card Title",
"description": "Sample Card Description"
}
```

3. **Backend:**
- Create a Node.js app in the `backend` folder.
- Follow the `backend.md` instructions to complete the backend.
Add multiple cards to test the search functionality.

4. **Push Your Work:**
- Push both the frontend and backend apps to the same repository.
- Make sure the repository is public.
7. **Enjoy the Application**

5. **Submit Your Work:**
- Paste the GitHub repository link in the Google form you received after pushing your code.
Once the frontend and backend are running, you can access the application in your browser and use the search functionality to find cards by their titles.

---
# Conclusion

With everything set up, you can now enjoy searching for cards in the application. Feel free to add more cards via Postman to test the application's features further.# Assignment
1 change: 1 addition & 0 deletions backend/.env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGO_URI="mongodb://127.0.0.1:27017/"
130 changes: 130 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
10 changes: 10 additions & 0 deletions backend/db/connect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import mongoose from "mongoose";

export const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGO_URI + "Project");
console.log("MongoDB Connected");
} catch (error) {
console.log(error);
}
};
18 changes: 18 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import express from "express";
import { connectDB } from "./db/connect.js";
import Card from "./router/Card.js";
import cors from "cors";

const app = express();
const PORT = 3000;

app.use(express.json());
app.use(cors());

//Routes
app.use("/", Card);

app.listen(PORT, () => {
connectDB();
console.log("Server is running 😎 ", PORT);
});
16 changes: 16 additions & 0 deletions backend/model/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import mongoose, { Schema } from "mongoose";

const CardSchema = new Schema({
title: {
type: String,
required: true,
},
description: {
type: String,
required: true,
},
});

const Card = new mongoose.model("Card", CardSchema);

export default Card;
Loading