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
101 changes: 82 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,90 @@
# Help Center API Assignment
# Help Card Application

## Instructions
This application consists of a React frontend and an Express backend, designed to manage and display help cards.

1. **Clone the Repository:**
```bash
git clone https://github.com/iAmritMalviya/fullstack-assignment
cd fullstack-assignment
```
## Table of Contents
1. [Frontend](#frontend)
2. [Backend](#backend)
3. [Getting Started](#getting-started)
4. [API Routes](#api-routes)
5. [Environment Variables](#environment-variables)
6. [FAQ](#faq)

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

3. **Backend:**
- Create a Node.js app in the `backend` folder.
- Follow the `backend.md` instructions to complete the backend.
The frontend is built with React and provides a user interface for searching and displaying help cards.

4. **Push Your Work:**
- Push both the frontend and backend apps to the same repository.
- Make sure the repository is public.
### Key Features
- Search functionality for cards using titles
- Responsive list view of help cards
- Create a card
- Delete a card with its title

5. **Submit Your Work:**
- Paste the GitHub repository link in the Google form you received after pushing your code.
### Project Structure
- `src/api`: Contains API integration logic
- `src/components`: React components including Home, CardList, Navbar and Footer

---
### State Management
- Utilizes React hooks (`useState`, `useEffect`) for local state management

## Backend

The backend is an Express server that handles API requests and interacts with a MongoDB database.

### Key Features
- RESTful API for CRUD operations on help cards
- MongoDB integration for data persistence
- Custom error handling and response formatting

### Project Structure
- `routes`: Defines API routes
- `controllers`: Contains logic for route handlers
- `models`: Defines MongoDB schemas

## Getting Started

To run this project locally, follow these steps:

1. Clone the repository
2. Navigate to the backend folder:
cd backend
npm install
npm run dev
3. In a new terminal, navigate to the frontend folder:
4. The backend will be running on `http://localhost:8000`
5. Access the frontend through the URL provided in the terminal

## API Routes

- `POST /cards`: Create a new help card
- `GET /cards`: Retrieve all help cards
- `GET /cards/:title`: Retrieve a specific help card by title
- `DELETE /cards/:title`: Delete a specific help card by title

## Environment Variables

Create a `.env` file in the backend directory with the following content:
PORT=8000
MONGODB_URI=your_mongodb_connection_string
CORS_ORIGIN=*

Note: The MongoDB URI will be updated within 2-3 days.

## FAQ

1. How can you implement shared functionality across a component tree?

Shared functionality can be implemented using:
- Context API
- Custom Hooks
- Higher-Order Components (HOCs)
- Render Props

2. Why is the `useState` hook appropriate for handling state in a complex component?

`useState` is appropriate because:
- It allows state management in functional components
- Provides a simple API for state updates
- Can manage multiple independent states
- Integrates well with other hooks
- Helps in breaking down complex state logic
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.*
Loading