GithubHelp home page GithubHelp logo

vovoka / bookmap_2020 Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 2.99 MB

Books P2P Marketplace optimized by users' locations. It's much easier to buy used books if it's owner lives nearby.

Home Page: https://bookmap-2020.herokuapp.com/

License: MIT License

Python 66.20% HTML 31.67% CSS 1.69% Dockerfile 0.09% Shell 0.36%
folium-maps flask sqlalchemy-python

bookmap_2020's Introduction

BookMap

Pet project for learning purposes.

General idea - create P2P book marketplace focused on users location (to make easy to get).

Demo refresh if 'internal server error', free Heroku plan is not reliable for the load. Main view:
GitHub Logo
Book Page:
GitHub Logo
Add a book instance (book is found by isbn at google books) :
GitHub Logo

Tech stack

Development

  • Rename .env.dev-sample to .env.dev.
  • Rename Docker.dev to Docker.
  • Update the environment variables in the docker-compose.yml and .env.dev files.
  • docker-compose up -d --build  # Build the images and run the containers
    docker-compose exec web python manage.py create_db # Create new empty database
    docker-compose exec web python manage.py seed_db # Fill db with fake users, books, book instances

hint: if you want to have Admin access quick then login with your google account (via browser) before seed_db. This way your User has id=1 and Admin access.

Production (not fully tested)

Uses gunicorn + nginx.

  • Rename .env.prod-sample to .env.prod and .env.prod.db-sample to .env.prod.db.

  • Update the environment variables.

  • Build the images and run the containers:

    $ docker-compose -f docker-compose.prod.yml up -d --build
    $ docker-compose -f docker-compose.prod.yml exec web python manage.py create_db
    $ docker-compose -f docker-compose.prod.yml exec web python manage.py seed_db

    Test it out at http://localhost:1337. No mounted folders. To apply changes, the image must be re-built.

Notes

  • Main objects are Book (has title, author, isbn etc.) and derived object BookInstance (i.e. instance of a Book, it has it's own price, condition, owner location). For example Book 'Tom Sawyer' might has some BookInstance offered from different Users, with different price, condition and location.
  • When a user wants to add new Book the script:
    • checks by isbn if such Book is already exist in local DB,
    • check (by google books API) if Google Books has an informatinon about the book with the isbn. If Google books has the information that the info (isbn, title, authors, cover) offered to the User for use.
    • Otherwise User is welcomed to add a Book in fully manual mode. When Book is created in DB, User can to add BookInstance.
  • .env also contains mail settings vars. It's used to send email-notifications to Users. Currently a notification sent in two cases:
    • User got a private message from other User;
    • Users BookInstance reach 'expired' state (30 days from publishing by deafault) and have to be re-activated manually by User.
  • Google's SMTP server requires the configuration of "less secure apps". See https://support.google.com/accounts/answer/6010255?hl=en
  • BookInstance expiration check is made as cron task with BackgroundScheduler()
  • Map view is centered by User location which is received by IP from ipapi service.
  • Users with Adiministrator privileges able to manage the DB data with Flask-Admin interface.
  • First created User (User.id == 1) has Admin access (i.e. has access to http://127.0.0.1:5000/admin/). It's for dev conviniency only. Fix it with modified 'create_db' by adding new admin?

TODO (unsorted ideas possible next steps and known bugs):

  • Refactor to made the code more concise :)
  • Add change user_name during initializating new account only?
  • Clasterize book instances by location with h3?
  • If noone or only you (as User) is a BookInstance owner then you can manage the related Book attributes (title, cover etc.). How to? -> add book.is_editable
  • Add cron job to clear tmp folder (if many files found there).
  • Add 'blame for the book (incorrect/ violent data)'
  • Add 'offer book cover' (if no bookcover currently) -> 'Offer better book cover'(?)
  • Data caching?
    • Do not render _map.html for each User, render it with Scheduller in thread only if Book were added/removed ... or by time.
    • Hide 'new book' button for users who are not allow_to_create_a_book() any more (Limits included already). Store var 'show_add_new_book' in session?
  • Gmail allows to send 100-150 messages daily. If out of the limit -> look at SendGrid или MailChimp.
  • Add footer
  • Messages view as threads (it's about indentation in html)
  • Separate css from html (now some mess is there).
  • Rename BookInstance.Description to BookInstance.Comment. It's better name for it.
  • Cover with tests.

bookmap_2020's People

Contributors

vovoka avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.