Table of Contents
This is a application that allows you to save news articles you'd like to read later so you can visit them at your convenience.(https://news-app-pga.herokuapp.com/)
- JS Library/Framework: React
- Ways of Interaction:
- By mouse
- By keyboard
- By screenReader(Application fully navigable using a screenReader)
- Architectural Pattern: MVC
- Integration with a PostGreSQL database hosted on Heroku that allows create, read, update and delete options via RESTful API's
- Usage of over 5 MUI components
- Usage of 5 reusable components in controls
- Backend: PostGreSQL, Node.js
- Frontend: TypeScript, HTML, CSS
- Reusable Components: Application made use of reusable components to reduce the size of the code base and allow for a centralized point of design decisions. Reusable Components Used: Tab.tsx, Button.tsx, Newslet.tsx, NewsList.tsx, Input.tsx
- Aria Labels: Made use of aria-labels to allow screen reader to correctly read components on the page to vision impaired users.
- Aria Roles: Used aria-roles to allow screen readers to see non-button clickable elements.
- Tab-Index: Use to make entire application navigable using just keyboard for users without mouse access.
- onKeyUp: Used to distinguish between key presses while using my application. Users can navigate with 'tab' and select with 'enter'.
MVC architecture
- MODEL The Model Layer(server/models/model.js) sits directly on top of the database and doesn't need to know what information is coming from the database.
- CONTROLLERS The controllers consume API's exposed by the model. and don't need to know what those api's do.
- VIEWS The server exposes APIs that are consumed by the UI on the frontend to render information.
- Semantic HTML tags: Made use of HTML elements like footer and header that have semantic meaning that correlate their usage with their names.
- h1 tags: properly nested h1 tags to allow for easy reading using a screen reader.
I separated my UI components based on their function.
My Reusables were in isolated in the controls folder, the header of the page in the header folder, the footer in the footer folder.
I isolated other parts like the util functions and the hooks. This made my code easy to navigate.
First Contentful Paint: 897ms; 92%
Speed Index: 1.3s; 90%
Largest Contentful Paint: 937ms; 96%
Time to Interactive: 1.4s; 99%
Cumulative Layout shift: 0.00; 100%
Accessibility: 100%
- API Documentation
-
Create routes
- POST /user
- POST /favorite
-
Read routes
- GET /business
- GET /world
- GET /tech
- GET /favorite
-
Update routes
- PUT /username
-
Delete routes
- DELETE /favorite
-
Description: Adds user to the database if user is new.
-
Status:
200 OK
if success500 Failed
if failed to create user
-
Request Body Parameters:
Parameter Type Description username String user's name to be stored - Request Body Example:
{ username: 'phiAgent' }
- Description: Returns news articles in the category of business from database.
- Status:
200 OK
if success500 Failed
if failed to fetch
-
Description: Updates user's name in the database.
-
Status:
200 OK
if success500 Failed
if failed to update username.
-
Request Body Parameters:
Parameter Type Description oldUsername String user's old name newUsername String user's new name - Request Body Example:
{ oldUsername: 'phiAgent', newUsername: 'Obede' }
-
Description: Deletes a favorite from the database.
-
Status:
200 OK
if success500 Failed
if failed to delete.
-
Request Body Parameters:
Parameter Type Description userID number id of user trying to unfavorite a news article newsID number id of news article being unfavorited - Request Body Example:
{ userID: 1, newsID: 1 }
Application was built mainly on 2 branches: master and feBuild. One branch was the development branch that I continually compared with and merged with the master branch.
- Clone the repo
git clone https://github.com/PhiAgent/News-App.git
- Checkout the feBuild out branch. The master branch is optimized for deployment and won't work out of the box for your local.
git checkout feBuild
- Install NPM packages
npm install
- Create a config.js file in database with your local psql connection details like this database/psql/config.js:
module.exports = {
host: "localhost",
user: "your name",
database: "news_app",
password: "",
port: 5432,
max: 30,
idleTimeoutMillis: 1,
};
- Open psql in your terminal and run the command below to populate your database, don't include the quotes around the command:
'\i database/schema.sql'
- Build the front end of the application by running this in the terminal:
npm run build-dev
- Now start your server by running in your terminal:
npm start
- Open localhost http://localhost:5000/ in your browser and witness the application
See the open issues for a full list issues.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request