Skip to content

aldomatus/django-rooms-project

Repository files navigation


Header

A REST api made with Django Rest Framework in which you can practice the methods: GET, POST, PUT and DELETE, of a tasks list application. This API will be connected to the postgres database.

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact

About The Project

This project is made with the intention of create a REST API to book rooms and events

  • Add the list of requirements in a requirements.txt file
  • Create a REST API with the methods: GET, POST, PUT and DELETE
  • Test endpoints

Built With

Major technologies

Frameworks and Libraries

Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Django Rest Framework

Django REST framework is a powerful and flexible toolkit for building Web APIs.

To check your rest api

Insomnia

With their streamlined API client, you can quickly and easily send REST, SOAP, GraphQL, and GRPC requests directly within Insomnia. Link to visit insomnia website: - Link

Header

Postman

Postman is a collaboration platform for API development. Postman's features simplify each step of building an API and streamline collaboration so you can create better APIs—faster. Link to visit postman website: - Link

Header

Getting Started

Prerequisites

For this project you need to have the postgres database installed. If you have not installed it yet, you can create a dockerfile to run your database, you can work with its graphical interface or from the console, both ways will serve you. Let's create a database from the terminal:

  1. open a terminal and type the following code to install postgres
   docker run --name events -p 5433:5432 -e POSTGRES_USER=postgresUser -e POSTGRES_PASSWORD=postgresPW -e POSTGRES_DB=events -d postgres

.env file 🌍 (Example)

DATABASE_HOST=192.168.0.116
DATABASE_USER=postgresUser
DATABASE_PASSWORD=postgresPW
DATABASE_NAME=events
DATABASE_PORT=5433

Description of the REST API code

Installation

  1. Clone the repo

    git clone git@github.com:aldomatus/django-rooms-project.git
    
  2. If you want, you can use a Dockerfile to run the project 🐳 otherwise follow the steps from 3

    docker build -t events_backend:latest .; docker run --rm -it --env-file=.env -v ${PWD}:/usr/src/app -p 8000:8000 --name events_backend events_backend:latest
    
  3. inside our dir we create a virtual environment to have our libraries together.

    3.1 To download the library that allows us to create virtual environments

    sudo apt-get install python3-venv
    

    3.2. Create the virtual environment

    python3 -m venv env_dir
    

    3.3. Activate the virtual environment we go to the created folder and inside the terminal we write:

    source env_dir/bin/activate
    
  4. Once the virtual environment is activated, we return to the folder where the requirements.txt file is and to install our libraries we must type the following line. (if you are using python 3 you only must type python3)

    python -m pip install -r requirements.txt
    
  5. we run the server with...

    python manage.py runserver
    
  6. If all goes well, our application should already be executing the manage.py file with python using the postgres database, now we just have to check by entering the following link in our browser:

    http://localhost:8000/
    
  7. You should have a response like this:

    {
       "message": "Welcome to my API"
    }
    

Usage

Inside the repository there is a file called api.postman collection.json with which the tests can be done towards the endpoints

Entity relationship model

For the construction of the database, the relationship entity model was made with which the relationships between each table were deduced.

Header

Requirements:

  1. The business can create a room with M capacity
       {
        "is_available": 1,
        "capacity_of_users": 10,
        "busy_places": 0
       }
    Response example:
      Status: 201 Created
      {
       "capacity_of_users": 10,
       "busy_places": 0,
       "is_available": true
      }

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Aldo Matus - Linkedin Facebook

Project Link: Repository

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published