sainRaghuveer / Goldstone-assignment

Simple react application where we can see user data in form of table and we can update it that will be happen in MongoDB database as well as User side. We can export user data in Csv file.

Home Page:https://goldstone-assignment-raghuveersain.vercel.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Goldstone User Management Application

This project is a user management application that allows you to fetch user data from an external API, edit user information, and export user data to a CSV file. It consists of microservices for handling data operations, a frontend built with React and Chakra UI for user interaction, and a MongoDB database for storing user information.

Use Case

  1. Accessing User API:

    • To fetch user data, use the following API endpoint: https://gorest.co.in/public-api/users
    • Please ensure that you are logged in with your Gmail ID to obtain the required API token.
  2. Storing User Data:

    • When you receive a successful API response, store the user data in the User Master table within the MongoDB database.
    • Each user object received from the API should map to a record in the User Master table.
    • Store the following fields for each user: Id, name, email, gender, status, Created_at, and Updated_at.
  3. Editing User Data:

    • Create an edit screen in the frontend where users can update their information.
    • When a user modifies their data and submits the changes, make a request to the web service to update the corresponding record in the database.
  4. Exporting User Data:

    • Implement a microservice responsible for exporting the User Master data to a single-sheet CSV file.
    • This CSV file should contain all the user records stored in the database.

Technology Stack

  • Frontend: React JS with Chakra UI
  • Backend/Microservice: Node.js with Express.js
  • Database: MongoDB

Project Structure

The project follows a client-server architecture, with the frontend and backend components separated.

  • The frontend code is located in the frontend directory.
  • The backend code is located in the backend directory.

Setup Instructions

  1. Clone the Repository:

    git clone https://github.com/sainRaghuveer/Goldstone-assignment.git
  2. Backend Setup

    • Navigate to the backend directory:
    cd backend
    • Install the dependencies:
    npm install
    • Start the backend server:
    npm run server
    or
    npm start
  3. Frontend Setup

    • Navigate to the Frontend directory:
    cd frontend
    • Install the dependencies:
    npm install
    • Start the backend server:
    npm start
  4. Access the Application:

Open your web browser and visit http://localhost:3000 to access the user management application.

Folder structure and schema structure and endpoints

1. Backend folder structure

MVC Structure

├── index.js
├── configs
|    └── db.js
├── models
|    └── user.model.js
├── routes
|    └── user.route.js
|    └── exportCSV.route.js
├── middleware
|    └── 
├──controllers
|    └── user.controller.js
|    └── exportCSV.controller.js

Note:

  • Before doing anything first create .env file and put port , mongoURl.
  • port is for listening the server.
  • mongoURl is for running database and store your data in database so put your mongo link.

Schema Design


User Schema

{
    name: {
        type: String,
        required: true
    },
    email: {
        type: String,
        required: true
    },
    gender: {
        type: String,
        enum:{
            values:["male", "female"],
            message:"Choose your gender only male or female"
        }
    },
    status: {
        type: String,
        enum:{
            values:["active", "inactive"],
            message:"Choose your status only active or inactive"
        }
    }
}

Endpoints

METHOD ENDPOINT DESCRIPTION STATUS CODE
POST /api/user/userdata This endpoint should allow users to add the data. 200
GET /api/user/data This endpoint should allow users to view the data od user 200
PATCH /api/user/:id This endpoint should allow users to edit own data by their id. 200
GET /api/export-csv This endpoint should allow users to download the content in csv file all data 200

Backend Deployed Link


Render Deployed link of Application


2. Frontend folder structure

├── public
|    └── favicon.ico
|    └── index.html
|    └── logo192.png
|    └── logo512.png
|    └── manifest.json
├── src
|    └── components 
|    |      └── Navbar.jsx  
|    |      └── StatusMenu.jsx  
|    |      └── UserCard.jsx  
|    |      └── UserUpdateModal.jsx  
|    └── customHook
|    |      └── UseToast.jsx       
|    └── pages 
|    |      └── Home.jsx   
|    └── routes
|    |      └── AllRoutes.jsx  
|    └── styles
|    |      └── Home.css  
|    └── App.css
|    └── App.js
|    └── App.test.js
|    └── index.css
|    └── index.js
|    └── logo.svg
|    └── reportWebVital.js
|    └── setupTests.js
├── styles
|    └── index.css
|    └── product.css

Note : Don't Change any file name or do not delete any files


API endpoints with Base Url

BaseUrl : https://goldstone-assignment-backend.onrender.com/


METHOD ENDPOINT DESCRIPTION STATUS CODE
POST `${BaseUrl}/api/user/userdata` This endpoint should allow users to add the data. 200
GET `${BaseUrl}/api/user/data` This endpoint should allow users to view the data od user 200
PATCH `${BaseUrl}/api/user/:id` This endpoint should allow users to edit own data by their id. 200
GET `${BaseUrl}/api/export-csv` This endpoint should allow users to download the content in csv file all data 200

BaseUrl : https://upforce-backend.onrender.com


Frontend Deployed Link


Vercel Frontend deployed link


Additional Information

  • The database connection details are specified in the backend code (backend/index.js). Make sure to update the connection URI if necessary.
  • For detailed information about the API routes, request/response examples, and available endpoints, refer to the API documentation provided by Postman.
  • Screenshots of the frontend webpages can be found in the screenshots.

ScreenShots


Home Page

image

Status Menu: Where you can change your status directly by selecting status

image

Action Menu: Here you can update all data of the user

image

Export data in CSV: By clicking this Export as Csv button data will get downloaded in your device

image

Dark Mode: You can enjoy dark mode these as well

image

About

Simple react application where we can see user data in form of table and we can update it that will be happen in MongoDB database as well as User side. We can export user data in Csv file.

https://goldstone-assignment-raghuveersain.vercel.app/


Languages

Language:JavaScript 86.4%Language:CSS 7.5%Language:HTML 6.1%