Giter Site home page Giter Site logo

helio3197 / book-a-lawyer-app-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from richardoppiyo/book-a-lawyer-app-backend

0.0 0.0 0.0 243 KB

A React/Redux | Ruby-on-Rails full-stack app for managing appointments with lawyers.

Home Page: https://book-a-lawyer-app.herokuapp.com/

License: MIT License

Ruby 99.57% HTML 0.43%
api api-rest authentication authorization cancancan devise-token-auth jwt-authentication postgresql ruby ruby-on-rails

book-a-lawyer-app-backend's Introduction

Book a lawyer App

This repository is a Ruby on Rails developed backend API only application named "Book a lawyer App". The purpose of the project is to automate the law services. The Application allows an authenticated user to log in to the system, get a list of all available lawyers whose can be bookeed for a specified amount. The lawyers' bio has the contact details, location, pricing per hour of the lawyer from which a user gets more insights. It also has dedicated pages to see a user's reservations and a reserve form. An admin user has the right to add/remove a lawyer from the database and hence can see the Manage tab.

Entity relationship diagram

Diagram

Front End repository

Link to the front end repository

Kanban board

Built With

  • Ruby version 3.1.2
  • Rails 7.0.3
  • PostgreSQL v 14.4
  • Devise
  • Cancancan
  • JWT Auth

Hosting services

  • The project is hosted on Heruku
https://book-a-lawyer-backend.herokuapp.com/
  • AWS S3 is used as the production storage service.

Configuration and set-up

  • Kindly ensure the following environments have been installed on you system:

    • Ruby
    • PostgreSQL
    • Rails
  • Cloning the repository

    • git clone https://github.com/richardoppiyo/book-a-lawyer-App-backend.git
      
  • Navigate to the project's root folder:

    • cd book-a-lawyer-App-backend
      
  • Install dependencies:

    • bundle install
      
  • Add the master key to the project:

    • Create a new file called: master.key in ./config directory
      • touch ./config/master.key
        
    • Add the development secret key d6f114bd6f255f293dcf131f49fe7079 on the new created master.key file
      • echo "d6f114bd6f255f293dcf131f49fe7079" >> master.key
        
  • Create the database:

    • rails db:create
      
  • Run migrations:

    • rails db:migrate
      

Usage

  • Run the server on the specified port:
rails s --port=3000
  • Or use the deployed API server:
https://book-a-lawyer-backend.herokuapp.com/
  • Available endpoints: Sessions and authentication
    • POST /users/sign_in:
      • Creates a new user session
      • Accepts a JSON string or FormData object in this format:
        user: {
          email: string,
          password: string,
        }
        
      • Responds in JSON:
        {
          result: 'success',
          user: user_object,
        }
        
      • Returns a JWT auth token in the response's header.
    • POST /users:
      • Create a new user
      • Accepts a JSON string or FormData object in this format:
        {
          user: {
            name: string
            email: string,
            phone: string,
            password: string,
            password_confirmation: string,
            avatar: File image/ jpg, png, gif # optional, only as FormData object
          },
        }
        
      • Responds in JSON:
        {
          result: 'success',
          user: user_object,
        }
        
      • Returns a JWT auth token in the response's header.
    • DELETE /users/sign_out:
      • Destroy the user's session
      • Requires the auth token in the request's header.
      • Responds in JSON:
        { result: 'success' }
        
    • DELETE /users:
      • Destroy the user's account
      • Requires the auth token in the request's header.
      • Responds in JSON:
        { result: 'success' }
        
    • PATCH /users:
      • Updates the user's account
      • Requires the auth token in the request's header.
      • Accepts a JSON string or FormData object in this format:
        {
          user: {
            name: string
            email: string,
            phone: string,
            password: string,
            password_confirmation: string,
            avatar: File: image/jpg, png, gif # optional, only as FormData object
          },
        }
        
      • Responds in JSON:
        {
          result: 'success',
          user: user_object,
        }
        
  • Available endpoints: Lawyers
    • GET /api/v1/lawyers:
      • Return the list of lawyers:
      • Requires the auth token in the request's header.
      • Return a JSON string in this format:
        {
          lawyers: [
            {
              "id": int,
              "name": string,
              "phone": string,
              "email": string,
              "location": string,
              "rates": number,
              "bio": string,
              "created_at": datetime_string,
              "updated_at": datetime_string,
              "avatar_url": string,
            },
            ...
          ]
        }
        
    • GET /api/v1/lawyers/:id:
      • Returns a specific lawyer:
      • Requires the auth token in the request's header.
      • Return a JSON string in this format:
        {
          lawyer: {
            "id": int,
            "name": string,
            "phone": string,
            "email": string,
            "location": string,
            "rates": number,
            "bio": string,
            "created_at": datetime_string,
            "updated_at": datetime_string,
            "avatar_url": string,
          }
        }
        
    • [admin] POST /api/v1/lawyers:
      • Creates a new lawyer
      • Requires the auth token in the request's header.
      • Accepts a FormData object in this format:
        {
          lawyer: {
            id: int,
            name: string,
            phone: string,
            email: string,
            location: string,
            rates: number,
            bio: string,
            created_at: datetime_string,
            updated_at: datetime_string,
            avatar: File image/ jpg, png, gif,
          }
        }
        
      • Responds in JSON:
        {
          result: 'success',
          lawyer: lawyer_object,
        }
        
    • [admin] DELETE /api/v1/lawyers/:id:
      • Destroys a lawyer item
      • Requires the auth token in the request's header.
      • Responds in JSON:
        { result: 'success' }
        
    • [admin] PATCH /api/v1/lawyers/:id:
      • Updates a lawyer
      • Requires the auth token in the request's header.
      • Accepts a FormData object in this format:
        {
          lawyer: {
            id: int,
            name: string,
            phone: string,
            email: string,
            location: string,
            rates: number,
            bio: string,
            created_at: datetime_string,
            updated_at: datetime_string,
            avatar: File image/ jpg, png, gif,
          }
        }
        
      • Responds in JSON:
        {
          result: 'success',
          lawyer: lawyer_object,
        }
        
  • Available endpoints: Reservations
    • GET /api/v1/reservations:
      • Returns a list of reservations for the signed in user
      • Requires the auth token in the request's header.
      • Return a JSON string in this format:
        {
          "reservations": [
            {
                "id": number,
                "reservationdate": datetime_string,
                "is_active": boolean,
                "duration": number,
                "created_at": datetime_string,
                "updated_at": datetime_string,
                "user_id": number,
                "lawyer_id": number,
            },
            ...
          ]
        }
        
    • POST /api/v1/reservations:
      • Creates a reservations for the signed in user
      • Requires the auth token in the request's header.
      • Accepts a JSON object in this format:
        {
          reservation: {
            id: int,
            reservationdate: date,
            is_active: bolean,
            duration: int,
            lawyer_id: int,
          }
        }
        
      • Responds in JSON:
        {
          result: 'success',
          reservation: reservation_object,
        }
        
    • DELETE /api/v1/lawyers/:id:
      • Destroys a reservation for the signed in user
      • Requires the auth token in the request's header.
      • Responds in JSON:
        { result: 'success' }
        
    • PATCH /api/v1/lawyers/:id:
      • Updates a reservation for the signed in user
      • Requires the auth token in the request's header.
      • Accepts a JSON object in this format:
        {
          reservation: {
            id: int,
            reservationdate: date,
            is_active: bolean,
            duration: int,
            lawyer_id: int,
          }
        }
        
      • Responds in JSON:
        {
          result: 'success',
          reservation: reservation_object,
        }
        
        
        

Authors

๐Ÿ‘ค Richard Opiyo

๐Ÿ‘ค Kenny Salazar

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a โญ๏ธ if you like this project!

Acknowledgments

  • Microverse,
  • Our coding partners, and
  • Stand-up team members

๐Ÿ“ License

This project is MIT licensed.

book-a-lawyer-app-backend's People

Contributors

helio3197 avatar richardoppiyo 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.