This project consists of a Flask backend and a React frontend to display job listings. The frontend fetches data from the backend using REST API endpoints.
- Prerequisites
- Backend Installation
- Frontend Installation
- Installation Using Docker(optional)
- Steps To Make Production Ready
Before you begin, make sure you have the following software installed on your system:
- Python (for the Flask backend) Download Python
- Node.js (for the React frontend) Download Node.js
- npm (Node Package Manager, installed automatically with Node.js)
Clone the repository to your local machine:
git clone https://github.com/arepala-uml/jobtarget-project
Move to the project directory:
cd jobtarget-project
Follow these steps to create and activate a virtual environment for the backend server:
-
cd server
-
python3 -m venv venv
-
- On macOS/Linux:
source venv/bin/activate
- On Windows:
venv\Scripts\activate
Your terminal should now show that the virtual environment is active(indicated as (venv) at the beginning of the prompt).
- On macOS/Linux:
-
pip install -r requirements.txt
This will install all the dependencies required for backend server.
By default, the Flask backend will run on port 8000. If you want to change the port, you can specify the new port in the .env file.
FLASK_APP_PORT=8000 # Default port assigned is 8000, you can change it here
If you don’t modify the .env file, the backend will use the default port 8000.
python app.py
In flask, Default port is set to 8000
** Run with gunicorn **
gunicorn -w 4 --bind 0.0.0.0:8000 app:app
- -w : number of worker
http://localhost:8000
The backend will be available at above link (or the port you’ve specified in .env)
To get all the jobs http://localhost:8000/api/jobs
To get a jobs with <job_id> http://localhost:8000/api/jobs/<job_id>
Navigate to the ui/
directory
cd jobtarget-project/
cd ui/
Install the necessary dependencies for React:
npm install
This installs all the required React libraries from package.json
Open .env
file in the ui/ folder to specify the backend hostname and port:
REACT_APP_BACKEND_HOST=localhost
REACT_APP_BACKEND_PORT=8000 # Default is 8000, you can change it here to match your backend
This will allow the React app to communicate with the backend on the port you’ve specified.
Run the React frontend development server:
npm start
The frontend will be available at http://localhost:3000
.
Dont follow the below steps if you have already followed the Backend and Frontend installation. Please do the below steps if you want to deploy as containerized applications.
Before you start, you need to have the following software installed:
After installing, check for version
docker --version
docker-compose --version
docker-compose down
docker-compose up -d
Access the application at http://localhost:3000
To make this application production-ready, we should implement below things:
- For persistent data storage, we need to integrate a relational (Ex: MySQL) or NoSQL database (Ex: MongoDB) to replace the static jobs.json file.
- Need to have secure communication by enforcing HTTPS for both frontend and backend, using SSL/TLS certificates.
- We need to containerize our application to make it production ready and I already did that in this project. But, I did not configure the supervisord and we need to have this because it ensures that all services run smoothly and automatically restart in case of failures.
- We need to deploy the application in scalable environments like Kubernetes with auto-scaling to handle varying traffic loads.
- We need to have automated CI/CD pipelines using Jenkins to automate process of build,test and deploy of our app.
- We need to have proper monitoring of the application like using tools like Prometheus, Grafana.
- We need to write unit tests for both the frontend and backend to ensure the correctness of individual components using modules like pytest.
- We need to have TypeScript into the React frontend for better type safety and easily can identify type errors during development.