This is the Lekki property API. An API application built with ruby on the rails framework. It exposes 3 endpoints for creating, updating and fetching real estate properties. The specifications of these endpoints are documented with the swagger editor and hosted at "https://chijiokeorabueze.github.io/Lekki_Property_Api_Spec/". In addition, the raw file of this documentation can be found in at public/lekki_properties_api.yaml. This can be viewed and edited by importing the file to a swagger editor ("https://editor.swagger.io/").
- Ruby version - 3.1.4
- Rails version - 7.0.5
The only real dependency of this application is docker and docker-compose. This is because the application was built and contanerized with docker and docker-compose. This implies that running the application will require a computer capable of virtualization with an installation of both docker and docker-compose. visit the docker page "https://www.docker.com/" to download and install these tools if they are not yet installed.
This application uses the Geoapify Geocoding API for address validation. Running the application will require setting up a Geoapify account and getting an api key. To do this visit the geopify website "https://www.geoapify.com/pricing" sign up for the free account and create a project. This will give an api key for making api calls. This value will be configured as part of the environment variables.
Configurations to be carried before running this application includes setting up the database environment variables. This can be done in the .env file. For development, The application comes with an embedded postgres database which runs as a seperate container. In addition to this, the API key for the Geoapify Geocoding service also needs to be set.
The list of environment variables to set includes the following:
-
DB_HOST => This is the database host name. It should be the name of the database container outlined in the docker-compose file (for dev environment). It defaults to "localhost" if not provided.
-
DB_USERNAME => The user name of database to connect with for dev environment. Defaults to the current set username of the docker compose file.
-
DB_PASSWORD => The password of database to connect with for dev environment. Defaults to the current set password on the docker compose file.
-
DB_PORT => The port of database to connect to. Defaults to 5432 for all environments.
-
DB_DEV => Data base name for dev server. Defaults to a preset name if not provided.
-
DB_NAME => Data base name for production server. Defaults to a preset name if not provided.
-
LEKKI_PROPERTY_API_DATABASE_USERNAME => Database username for production server. Must be provided when running production server.
-
LEKKI_PROPERTY_API_DATABASE_PASSWORD => Database password for production server. Must be provided when running production server.
-
GEOPIFY_API_KEY => Geopify api key for address validation.
Once these variables has been set. The database can either be created manually or by running docker-compose run api rake db:create
on a terminal at the root directory fo this project. After this is done, run docker-compose run api rake db:migrate
to run data migrations and initialize the database.
To start the application simply run docker-compose up
on a terminal at the root directory fo this project. This will start the application on "http://localhost:3000".
Proceed to make requests with "/api/v1" attached to the base url e.g "http://localhost:3000/api/v1/properties"