This API stores and provides info on properties in the system.
https://drive.google.com/file/d/1z7HNq0GZu8D9aZtlstdQ1auVQ6XAa3eJ/view?usp=sharing
- Ruby 3.3.1
- Geocoder
- Postgres
- PostGIS
- OpenStreetMaps
- Redis (for caching)
- Supabase (for user authentication and image storage)
gem install bundler
Redis is used for caching data records retrieved in API queries. The Cachable module in app/models/concerns/cachable.rb handles the caching logic.
Supabase is used for user authentication and image storage. User data is back-filled into the main application (/api/users/create) after successful creation in Supabase.
For scaling in production, it may be beneficial to keep the user database and properties database separate for horizontal scalability. We can use Elasticsearch as a separate search index to offload search volume to an isolated service (whose results we can then cache in Redis for optimal search performance across the network).
Incorporating Elasticsearch for search functionality is outside the scope of this test project, but an example of how to incorporate it can be found in apt-rentals/app/models/concerns/searchable.rb, along with an example bounding box geo-query.
Multiple clients can be added to the package at react/packages/package.json
.
Currently, a web client is available at react/packages/apt
. This can be extended into its own repo in the form of a Git submodule.
Ruby 3.3.1 is required to run the REST API service.
To run the client, make sure you have Node & Yarn installed in your system. Recommended node version >=v20.9.0 and yarn v1.22.19. You check your ones by running these commands-
ruby -v
yarn -v
RVM installation is recommended for ruby version management.
Then set up Rails:
bundle install
rails db:create db:migrate
If it's not installed in your system then please install them by checking official documentation of,
# in workspace root folder
bundle
rails db:setup db:migrate
cd react/packages && yarn
$ bundle exec rspec spec/
To run the API:
rails s -p 3005
To run the web client:
cd react/packages && yarn start:apt
Concurrently run an instance of the API service and web client:
bash start-server.sh