Coder Social home page Coder Social logo

emadbinabid / newstore Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 85 KB

Newstore is a JSON API that aggregates news and blog articles from various popular third party APIs built with Django, DRF, and PostgreSQL.

Python 98.10% TSQL 0.62% Batchfile 1.27%
python django django-rest-framework postgresql reddit-api newsapi-python

newstore's Introduction

Newstore

Newstore is a JSON API that aggregates news and blog articles from various popular third party APIs built with Django, DRF, and PostgreSQL.

Newstore uses a relatively older version of Django i.e. v2.2.13. If you already have this version of Django installed then well and good. Else it is recommeded to create a Python virtual environment to contribute to this task. You can create your own virtual environment as follows: python -m venv [path at which you want to create the virtual environment]

For instance the command python -m venv env will create a virtual environment in ./env.

Once the environment is set up, you just need to navigate to ./Scripts and run activate.bat in command line to activate the virtual environment.

Dependencies

  • django v2.2.13
  • djangorestframework
  • psycopg2
  • praw
  • newsapi-python

To install these dependencies, run the envsetup.bat file located inside ./setup.

Setting up Database

Newstore uses PostgreSQL database. To install PostgreSQL, please visit: https://www.postgresql.org/download/.

To create Newstore database locally, run the dbsetup.bat file located inside ./setup. Before executing this file, make sure that you have postgres as one of the users of your PostgreSQL instance. If not abided, the command might break for now.

Newstore runs on PostgreSQL user postgres with password password on localhost:5432 as default. You may change these settings in ./config/dbconfig.py.

Newstore, by default, stores the history of news that are accumulated over time. You can turn off this functionality by setting is_news_history_table_active to False in appconfig.py.

General Configurations

Apart from dbconfig.py, ./config contains three other configuration files to manage app, Reddit API, and NewsAPI.

redditapiconfig.py

Contains client_id and client_secret required to connect with Reddit API.

newsapiconfig.py

Contains API key to connect with NewsAPI.

appconfig.py

Contains general app configuration and settings. You may change these settings to customise the app behaviour.

Logs

All the generated logs of Newstore are stored in ./logs. When the server is up and running, the logs get written to app.log file whereas the logs of unit tests are stored in a separate file test.log.

Endpoints

  • GET /news, GET /news?query=somekeyword

    • Usage: This endpoint works as a standalone endpoint as well as accepts a query parameter query to search for news against specific keyword. It fetches and returns news from all the supported sources.
  • GET /sources

    • Usage: It fetches and returns all the news sources that are supported by Newstore.

Every endpoint requires an API token that must be provided in the request header against the key Authorization. In our promotional stages, we have given free API token to our clients as wErdTg123STELLICgF5GhK.

Postman Collection

To save your time creating dummy requests, we have already come to your rescue. You can find a full-fledged ready Postman collection at ./scripts/Newstore.postman_collection.json containing requests against all the supported endpoints so far. We will keep on updating it as the product grows.

Unit Testing

Run python manage.py test in the root directory to run all the unit tests. Logs of unit tests can be found in ./logs/test.log.

Future Directions

We plan to add a following set of functionalities in the coming versions of Newstore. Stay connected.

  • Save logs to DB
  • Add a scheduler that deletes the expired records from database
  • Integration testing

Running the App

To run this app, navigate to the project's root directory and run python manage.py runserver in the terminal. Your application should be up and running at localhost:8000.

Contact

For queries and concerns, feel free to open the issue on this repository or email the author at [email protected]

newstore's People

Contributors

emadbinabid avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.