This is a web application that displays random user information retrieved from a PostgreSQL database. The backend is developed using R with the Ambiorix and the frontend is built with React.
The application fetches random user data from the Random User API every 10 seconds and stores it in a PostgreSQL database. The frontend periodically retrieves the stored data from the backend server and displays count of people registered in a year.
Before running the project, ensure that you have the following installed:
- R (v4.0 or above)
- Node.js (v12 or above)
- PostgreSQL database
-
Configure the database connection:
- Open the
config.yaml
file located in thebackend
directory. - Update the database configuration settings according to your PostgreSQL setup.
- Open the
-
Install the required R packages:
- Open an R terminal and run the following command:
install.packages(c("ambiorix", "httr", "RPostgres", "jsonlite", "DBI", "httpuv", "future", "coro"))
- Open an R terminal and run the following command:
-
Start the backend server:
- In the R terminal, navigate to the
backend
directory. - Run the following command:
Rscript app.R
- The backend server will start running on
http://127.0.0.1:1000
.
Note: The necessary database tables will be created automatically when the backend server starts.
- In the R terminal, navigate to the
-
Install the required dependencies:
- Open a terminal and navigate to the
frontend/my-app
directory. - Run the following command to install the dependencies:
npm install
- Open a terminal and navigate to the
-
Start the frontend development server:
- In the terminal, run the following command:
npm start
- The frontend application will be accessible at
http://localhost:3000
.
- In the terminal, run the following command:
- The backend server periodically fetches random user data from the Random User API every 10 seconds.
- The fetched data is stored in the PostgreSQL database.
- The frontend application sends requests to the backend server every 10 seconds to retrieve the stored user data.
- The retrieved data is displayed in a tabular format along witha a bar chart in the frontend application.
Backend:
- R
- ambiorix (web framework)
- PostgreSQL (database)
Frontend:
- React