{"id":19341013,"url":"https://github.com/belovetech/bookshelf","last_synced_at":"2026-04-08T22:32:40.882Z","repository":{"id":111327864,"uuid":"502738651","full_name":"belovetech/bookshelf","owner":"belovetech","description":"This is a simple bookshelf flask application. The project's goal is to test general knowledge of PostgreSQL, database interaction with the server, and many other things.","archived":false,"fork":false,"pushed_at":"2022-06-13T09:45:02.000Z","size":41153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T08:36:08.096Z","etag":null,"topics":["flask","postgresql","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/belovetech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-12T22:07:36.000Z","updated_at":"2023-04-09T12:44:59.000Z","dependencies_parsed_at":"2023-05-23T13:46:26.922Z","dependency_job_id":null,"html_url":"https://github.com/belovetech/bookshelf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/belovetech/bookshelf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belovetech%2Fbookshelf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belovetech%2Fbookshelf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belovetech%2Fbookshelf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belovetech%2Fbookshelf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/belovetech","download_url":"https://codeload.github.com/belovetech/bookshelf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/belovetech%2Fbookshelf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31577444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","postgresql","python"],"created_at":"2024-11-10T03:28:55.804Z","updated_at":"2026-04-08T22:32:40.867Z","avatar_url":"https://github.com/belovetech.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Local Development\n\nThe instructions below are meant for the local setup only. The classroom workspace is already set for your to start practicing.\n\n#### Pre-requisites\n\n- Developers using this project should already have Python3, pip and node installed on their local machines.\n\n- **Start your virtual environment**\n  From the backend folder run\n\n```bash\n# Mac users\npython3 -m venv venv\nsource venv/bin/activate\n# Windows users\n\u003e py -3 -m venv venv\n\u003e venv\\Scripts\\activate\n```\n\n- **Install dependencies**\u003cbr\u003e\n  From the backend folder run\n\n```bash\n# All required packages are included in the requirements file.\npip3 install -r requirements.txt\n# In addition, you will need to UNINSTALL the following:\npip3 uninstall flask-socketio -y\n```\n\n### Step 0: Start/Stop the PostgreSQL server\n\nMac users can follow the commands below:\n\n```bash\nwhich postgres\npostgres --version\n# Start/stop\npg_ctl -D /usr/local/var/postgres start\npg_ctl -D /usr/local/var/postgres stop\n```\n\nWindows users can follow the commands below:\n\n- Find the database directory, it should be something like that: _C:\\Program Files\\PostgreSQL\\13.2\\data_\n- Then, in the command line, execute the folllowing command:\n\n```bash\n# Start the server\npg_ctl -D \"C:\\Program Files\\PostgreSQL\\13.2\\data\" start\n# Stop the server\npg_ctl -D \"C:\\Program Files\\PostgreSQL\\13.2\\data\" stop\n```\n\nIf it shows that the _port already occupied_ error, run:\n\n```bash\nsudo su -\nps -ef | grep postmaster | awk '{print $2}'\nkill \u003cPID\u003e\n```\n\n### Step 1 - Create and Populate the database\n\n1. **Verify the database username**\u003cbr\u003e\n   Verify that the database user in the `/backend/books.psql`, `/backend/models.py`, and `/backend/test_flaskr.py` files must be either the `student` or `postgres` (default username). FYI, the classroom workspace uses the `student`/`student` user credentials, whereas, the local implementation can use the dafault `postgres` user without a password as well. (See the `/backend/setup.sql` for more details!)\n\n2. **Create the database and a user**\u003cbr\u003e\n   In your terminal, navigate to the _/nd0044-c2-API-Development-and-Documentation-exercises/1_Requests_Starter/backend/_ directory, and run the following:\n\n```bash\ncd nd0044-c2-API-Development-and-Documentation-exercises/1_Requests_Starter/backend\n# Connect to the PostgreSQL\npsql postgres\n#View all databases\n\\l\n# Create the database, create a user - `student`, grant all privileges to the student\n\\i setup.sql\n# Exit the PostgreSQL prompt\n\\q\n```\n\n3. **Create tables**\u003cbr\u003e\n   Once your database is created, you can create tables (`bookshelf`) and apply contraints\n\n```bash\n# Mac users\npsql -f books.psql -U student -d bookshelf\n# Linux users\nsu - postgres bash -c \"psql bookshelf \u003c /path/to/exercise/backend/books.psql\"\n\n```\n\n**You can even drop the database and repopulate it, if needed, using the commands above.**\n\n### Step 2: Complete the ToDos and Start the backend server\n\nNavigate to the `/backend/flaskr/__init__.py` file, and finish all the `@TODO` thereby building out the necessary routes and logic to get the backend of your app up and running.\n\nOnce you've written your code, start your (backend) Flask server by running the command below from the `/backend/` directory.\n\n```\nexport FLASK_APP=flaskr\nexport FLASK_ENV=development\nflask run\n```\n\nThese commands put the application in development and directs our application to use the `__init__.py` file in our flaskr folder. Working in development mode shows an interactive debugger in the console and restarts the server whenever changes are made. If running locally on Windows, look for the commands in the [Flask documentation](http://flask.pocoo.org/docs/1.0/tutorial/factory/).\n\nThe application will run on `http://127.0.0.1:5000/` by default and is set as a proxy in the frontend configuration. Also, the current version of the application does not require authentication or API keys.\n\n### Step 3: Start the frontend\n\n(You can start the frontend even before the backend is up!)\nFrom the `frontend` folder, run the following commands to start the client:\n\n```\nnpm install // only once to install dependencies\nnpm start\n```\n\nBy default, the frontend will run on `localhost:3000`. Close the terminal if you wish to stop the frontend server.\n\n---\n\n## Additional information\n\n#### Running Tests\n\nIf any exercise needs testing, navigate to the `/backend` folder and run the following commands:\n\n```bash\npsql postgres\ndropdb bookshelf_test\ncreatedb bookshelf_test\n\\q\npsql bookshelf_test \u003c books.psql\npython test_flaskr.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelovetech%2Fbookshelf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbelovetech%2Fbookshelf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbelovetech%2Fbookshelf/lists"}