This project is created from Dren Mullafetahu as a test application for Innoscripta.
In order to run the application you have two options:
You can run the apps (Front end and Backend seperately)
- Create a copy of
.env
file from.env.example
file and replace your configurations. - Run
composer install
. - Run
php artisan migrate
to create the tables and the database. - Run
php artisan serve
- Run
npm install
to install the dependencies. - Run
npm start
to start the app. - Open http://localhost:3000 to view it in your browser.
Note: The apps run by default port:3000 for front-end and port:8000 for backend.
If you want to change them you can change it on router.jsx for front-end and php artisan serve --port:xxxx
by adding a port flag on backend.
- Copy
.env.example
to.env
(on backend Folder) - On your terminal go to the root of the project (news-app) and run
docker-compose up --build -d
to create the docker containers. This will create 3 containers 1 for backend 1 for front-end and one for mysql . - Run
docker ps
to list the created containers. - Find and copy the
<your_db_containerId>
It should be something like (news-app-master-db-1
). - On .env file locate
DB_HOST=127.0.0.1
and replace withDB_HOST=<your_db_containerId>
- Inside backend container (
docker exec -it <your_backend_containerId> bash
) runphp artisan migrate
to create the database and the tables inside and exit. - Run again
docker-compose up --build -d
to rebuild. - Run
docker compose up
to start the apps. - Visit http://localhost:3000 to view it in your browser.
Note:
- I use Mac M1 Silicone chip on my computer, therefore I am required to use a different
db: platform:
configuration for my db Platform. If you use a different Intel chip or PC please changedb: platform: linux/x86_64
ondocker-compose.yaml
to your preference.
News-app is created with Laravel on backend and reactjs on front-end with axios as a promise-based HTTP Client.
It uses News API-s from:
- NewsAPI.org
- Guardian
- New York Times
Other:
- composer.
- mysql.
Notes:
- NewsApi limits to only 100 requests per day for development use.
- You must include the API_Keys from
.env.example
to.env
on backend folder.
- Register by creating an account.
- You can choose your Favourite Categories and Sources to make it personalized. Your selections are saved in the database for next time.
- You can Search all the articles from 3 different sources on the header search.
- On search page you have filters by date and source.
- Authentication is made with Laravel Oauth.
- User is created in database by registering.
- Validation is added to Login and Register.
- After Registration an ACCESS_TOKEN is set to Session storage. On logout it's deleted.
- On home page when the prefered categories and Source are seletected, an axios request is made to backend routes and then the api calls to collect news data which are called from backend. Also selected categories and source are saved to database for the personalized feed.
- Same goes for search. User searches, the input goes to backend routes and then the api calls are made from the selected filters.
- SearchParams are used to make the searches and filters.
- Logout destroys the token.
Dren Mullafetahu ❤️