Table of Contents
Agora Work offers individuals and organisations the ability to book a co-working space or private office on-demand, supporting the transition to work from anywhere. The related info, including how to deploy locally, how the system is designed, and what is built atop (in terms of custom features) will be discussed below
This segment provides a detailed description of the system design for a Agora Work, which is hosted on the Sharetribe backbone. The system will allow users to rent out work spaces or provide workspaces to other users, similar to Airbnb.
The system will consist of a web-based front-end, a server-side application, and a database to store all the information related to the items and services being rented. The front-end will allow users to view available workspaces, make reservations, and communicate with each other. The server-side application will handle user authentication, payment processing, listing processing/retrieval, and data management. The database will store information such as user profiles, listings, and reservation details.
Users will be able to sign up for the system using email and password, or by connecting with their existing social media accounts. The system will also have a secure password storage mechanism to ensure the protection of user data.
Users will be able to list their workspaces for rent. They will be able to provide detailed information such as the location description, rental cost, availability dates, and images. The system will also have a search feature that allows users to search for a workspace based on location, date, and number of people.
Users will be able to make reservations against listings by selecting the date/location they want to rent, and then making a payment through the system. The system will send notifications to both the renter and the owner when a reservation is made, and also provide a means for them to communicate with each other.
The system will use a secure payment gateway to process payments from renters to owners. The payment gateway will handle the transfer of funds and provide a receipt for both the renter and owner.
The system will store all the information related to users, listings and reservations in a database. The database will be optimized for fast retrieval of information, and will be backed up regularly to ensure data integrity.
The system will use secure socket layer (SSL) encryption for all communications between the front-end and server-side application to ensure the protection of sensitive data. The database will also be secured to prevent unauthorized access to user information.
File/Folder | Purpose |
---|---|
app/ | Contains the controllers, models, views, helpers, mailers, channels, jobs, and assets for your application. You'll focus on this folder for the remainder of this guide. |
bin/ | Contains the rails script that starts your app and can contain other scripts you use to set up, update, deploy, or run your application. |
config/ | Contains configuration for your application's routes, database, and more. This is covered in more detail in Configuring Rails Applications. |
config.ru | Rack configuration for Rack-based servers used to start the application. For more information about Rack, see the Rack website. |
db/ | Contains your current database schema, as well as the database migrations. |
Gemfile Gemfile.lock |
These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. For more information about Bundler, see the Bundler website. |
lib/ | Extended modules for your application. |
log/ | Application log files. |
public/ | Contains static files and compiled assets. When your app is running, this directory will be exposed as-is. |
Rakefile | This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile , you should add your own tasks by adding files to the lib/tasks directory of your application. |
README.md | This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on. |
storage/ | Active Storage files for Disk Service. This is covered in Active Storage Overview. |
test/ | Unit tests, fixtures, and other test apparatus. These are covered in Testing Rails Applications. |
tmp/ | Temporary files (like cache and pid files). |
vendor/ | A place for all third-party code. In a typical Rails application this includes vendored gems. |
.gitattributes | This file defines metadata for specific paths in a git repository. This metadata can be used by git and other tools to enhance their behavior. See the gitattributes documentation for more information. |
.gitignore | This file tells git which files (or patterns) it should ignore. See GitHub - Ignoring files for more information about ignoring files. |
.ruby-version | This file contains the default Ruby version. |
Installing Lib V8-315 On M1 Macbooks may run into this issue:
Configuaring MySQL post installation: sudo mysql -u root ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test'; Change 'Test' To any password and then enter that password in database.yml file
To make landing Page Changes edit the css file in assets/stylesheets/custom_landing_page_css and the html file in views/homepage/home.html.erb
This system design document provides a high-level overview of the features and architecture of an Airbnb-like, workspace reservation platform, specifically Agora Work. The system will provide a platform for users and organizations to rent out workspaces to each other, and will have features such as user authentication, payment processing, listing management, and data management.
To get the project going locally, please see the Sharetribe section below
Sharetribe develops advanced marketplace software for every business life cycle stage.
Sharetribe Go gives you the complete feature set to launch a marketplace for rentals, services, events, or products. The platform is source-available under the Sharetribe Community Public License.
To launch your marketplace in minutes without touching code or worrying about hosting and backups, head to the SaaS version of Sharetribe Go.
If you're looking for a customizable and extendable marketplace solution, check out Sharetribe Flex. Flex is an API-based marketplace solution designed with a developers-first mindset. It allows you to develop your marketplace with the programming language of your choice, build a mobile app, design a customized transaction flow, and easily integrate third party services.
- Technology stack
- Installation
- Payments
- Custom Landing Page
- Versioning
- Changes
- Upgrade
- Contribute
- Release
- Translation
- Bug tracker
- Documentation
- Community forum
- License
- Ruby 2.6
- Ruby on Rails 5.2.3
- MySQL 5.7
- React + jQuery
- Node.js 10.15 (for compiling JavaScript assets)
- "what you see is what you get" Editor Mercury
- Deploy: Custom Script (not using Mina or Cap3)
- Server: Heroku
- Image hosting: Amazon S3
- Background job: delayed_job
- Gems:
- devise | Authentication
- omniauth-facebook | Third party login: Facebook
- haml and ERB | HTML templating
- mysql2 | MySQL library for Ruby
- paperclip | Image upload management
- passenger | Web application server
- react_on_rails | Integration of React + Webpack + Rails
- factory_girl, capybara, rspec-rails, cucumber-rails, selenium-webdriver | Testing
Before you get started, the following needs to be installed:
- Ruby. Version 2.6.5 is currently used and we don't guarantee everything works with other versions. If you need multiple versions of Ruby, RVM or rbenv is recommended.
- RubyGems
- Bundler:
gem install bundler
- Node. Version 10.15 is currently used and we don't guarantee everything works with other versions. If you need multiple versions of Node, consider using n, nvm, or nenv.
- Git
- A database. Only MySQL 5.7 has been tested, so we give no guarantees that other databases (e.g. PostgreSQL) work. You can install MySQL Community Server two ways:
- If you are on a Mac, use homebrew:
brew install mysql
(highly recommended). Also consider installing the MySQL Preference Pane to control MySQL startup and shutdown. It is packaged with the MySQL downloadable installer, but can be easily installed as a stand-alone. - Download a MySQL installer from here
- If you are on a Mac, use homebrew:
- Sphinx. Version 2.1.4 has been used successfully, but newer versions should work as well. Make sure to enable MySQL support. If you're using OS X and have Homebrew installed, install it with
brew install sphinx --with-mysql
- Imagemagick. If you're using OS X and have Homebrew installed, install it with
brew install imagemagick
-
Get the code. Clone this git repository and check out the latest release:
git clone git://github.com/sharetribe/sharetribe.git cd sharetribe git checkout latest
-
Install the required gems by running the following command in the project root directory:
bundle install
Note:
libv8
might fail to build with Clang 7.3, in that case you can try installing V8 manually:brew tap homebrew/versions brew install v8-315 gem install libv8 -v '3.16.14.13' -- --with-system-v8 gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 bundle install
-
Install node modules:
npm install
-
Create a
database.yml
file by copying the example database configuration:cp config/database.example.yml config/database.yml
-
Add your database configuration details to
config/database.yml
. You will probably only need to fill in the password for the database(s). -
Create a
config.yml
file by copying the example configuration file:cp config/config.example.yml config/config.yml
-
Create and initialize the database:
bundle exec rake db:create db:structure:load
-
Run Sphinx index:
bundle exec rake ts:index
Note: If your MySQL server is configured for SSL, update the
config/thinking_sphinx.yml
file and uncomment themysql_ssl_ca
lines. Configure correct SSL certificate chain for connection to your database over SSL. -
Start the Sphinx daemon:
bundle exec rake ts:start
-
Start the development server:
foreman start -f Procfile.static
-
Invoke the delayed job worker in a new console (open the project root folder):
bundle exec rake jobs:work
Congratulations! Sharetribe should now be up and running for development purposes. Open a browser and go to the server URL (e.g. http://lvh.me:3000 or http://lvh.me:5000). Fill in the form to create a new marketplace and admin user. You should be now able to access your marketplace and modify it from the admin area.
Use Mailcatcher to receive sent emails locally:
-
Install Mailcatcher:
gem install mailcatcher
-
Start it:
mailcatcher
-
Add the following lines to
config/config.yml
:development: mail_delivery_method: smtp smtp_email_address: "localhost" smtp_email_port: 1025
-
Open
http://localhost:1080
in your browser
To update your local database schema to the newest version, run database migrations with:
bundle exec rake db:migrate
Tests are handled by RSpec for unit tests and Cucumber for acceptance tests.
Remember to follow all the steps listed in the Setting up the development environment paragraph before running tests because some tests depend on webpack assets.
-
Navigate to the root directory of the sharetribe project
-
Initialize your test database:
bundle exec rake test:prepare
This needs to be rerun whenever you make changes to your database schema.
-
If Zeus isn't running, start it:
zeus start
-
To run unit tests, open another terminal and run:
zeus rspec spec
-
To run acceptance tests, open another terminal and run:
zeus cucumber
Note that running acceptance tests is slow and may take a long time to complete.
To automatically run unit tests when code is changed, start Guard:
bundle exec guard
Some components are created with React (see documentation) and they need to be built with Webpack. We have Foreman Procfiles that can be used to run both Rails and Webpack:
-
React component static build
foreman start -f Procfile.static
-
React component & hot loading styleguide (http://localhost:9001/)
foreman start -f Procfile.hot
-
If you need to debug the Rails parts of Sharetribe with Pry, it's not possible with Foreman due to a known compatibility issue. In this case we recommend running Rails with old-fashioned
rails server
and React builds with Foreman in a separate terminal. That way yourbinding.pry
calls open nicely in the same window with the Rails process. -
React component static build, React client only
foreman start -f Procfile.client-static
-
React component & hot loading styleguide (http://localhost:9001/), React client only
foreman start -f Procfile.client-hot
Before starting these steps, perform steps 1-5 from above.
-
Set
secret_key_base
Generate secret key
rake secret
Add the following lines to
config/config.yml
:production: secret_key_base: # add here the generated key
(You can also set the
secret_key_base
environment variable, if you don't want to store the secret key in a file) -
Create the database:
RAILS_ENV=production bundle exec rake db:create
-
Initialize your database:
RAILS_ENV=production bundle exec rake db:structure:load
-
Run Sphinx index:
RAILS_ENV=production bundle exec rake ts:index
-
Start the Sphinx daemon:
RAILS_ENV=production bundle exec rake ts:start
-
Precompile the assets:
RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile
-
Invoke the delayed job worker:
RAILS_ENV=production bundle exec rake jobs:work
-
In a new console, open the project root folder and start the server:
bundle exec rails server -e production
The built-in WEBrick server (which was started in the last step above) should not be used in production due to performance reasons. A dedicated HTTP server such as unicorn is recommended.
It is not recommended to serve static assets from a Rails server in production. Instead, you should use a CDN (Content Delivery Network) service, such as Amazon CloudFront. To serve the assets from the CDN service, you need to change the asset_host
configuration in the the config/config.yml
file to point your CDN distribution.
You need to configure a couple scheduled tasks in order to properly run your marketplace in production. See the Scheduled tasks documentation.
For production use we recommend you to upgrade only when new version is released and not to follow the master branch.
-
In your database, change the value of the
domain
column in thecommunities
table to match the hostname of your domain. For example, if the URL for your marketplace is http://mymarketplace.myhosting.com, then the domain ismymarketplace.myhosting.com
. -
Change the value of the
use_domain
column totrue
(or1
) in thecommunities
table. -
If you wish to enable HTTP Strict Transport Security (recommended), set also the
hsts_max_age
column incommunities
table to a non-zero number of seconds. For instance31536000
(1 year).
If you want to use S3 to host your images, you need to do a bit more configuration.
-
Create a IAM role which has full S3 access. Save the AWS access and secret keys.
-
In the S3 console, create two buckets, one for upload and one for permanent storage. For example
your-sharetribe-images
andyour-sharetribe-images-tmp
. -
Set the upload bucket (
your-sharetribe-images-tmp
) to have an expiration (for example, of 14 days) using lifecycle management -
Set the following configuration in your sharetribe
config.yml
:s3_bucket_name: "your-sharetribe-images"
s3_upload_bucket_name: "your-sharetribe-images-tmp"
-
Add your AWS keys to the sharetribe app. The best way to do that is via environment variables, rather than checking them into your
config.yml
. Set theaws_access_key_id
andaws_secret_access_key
environment variables to the values for the IAM user. -
(Optional) When you enable S3, uploaded images are linked directly to the S3 bucket. If you want to serve these assets through CDN, you can set the
user_asset_host
configuration option in addition toasset_host
inconfig/config.yml
.
Here's a sample CORS configuration that allows anyone to post to your bucket. Note that you may want to lock down the origin host more tightly, depending on your needs.
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
- if you are having trouble uploading, look at the request using browser devtools and see what error statuses and messages are being sent.
- double check that your AWS keys are being correctly set.
- if you can upload images successfully, but the images aren't processed, make sure that the delayed-job worker is running.
Default configuration settings are stored in config/config.default.yml
. If you need to change these, use the config/config.yml
file to override the defaults. You can also set configuration values to environment variables.
React components can be created using hot module replacement HMR technique in Styleguide (http://localhost:9001/) path in local development environment. Webpack is used to bundle React components for deployments and hot loading. Related webpack configs can be found from folder sharetribe/client/
Use these instructions to set up and deploy Sharetribe for production in different environments. They have been put together by the developer community, and are not officially maintained by the Sharetribe core team. The instructions might be somewhat out of date.
If you have installation instructions that you would like to share, don't hesitate to share them at the Sharetribe community forum.
- Deploying Sharetribe to Heroku by svallory
- How to install Sharetribe on Centos 7.x by Arek Hukalowicz
PayPal and Stripe are the two available payment gateways integrated.
PayPal payments are only available on marketplaces hosted at Sharetribe.com due to special permissions needed from PayPal. We hope to add support for PayPal payments to the source available version of Sharetribe Go in the future.
Stripe can be used in the source available version, as long as your country and currency are supported.
Starting from release 7.2.0, Stripe is supported.
Stripe API keys will be encrypted when stored so it is important to configure your own random encryption key.
You should fill the app_encryption_key
variable in the config/config.yml
file with a long random string, unique to your project.
Stripe can be configured from the admin panel, in the "Payment settings" section. Instructions on how to get Stripe API keys can be found there.
If Stripe isn't automatically enabled in the admin panel after upgrading to 7.2.0, you should run the following commands in your Rails console, where <ID>
is your marketplace ID (probably 1
):
TransactionService::API::Api.processes.create(community_id: <ID>, process: :preauthorize, author_is_seller: true)
and
TransactionService::API::Api.settings.provision(community_id: <ID>, payment_gateway: :stripe, payment_process: :preauthorize, active: true)
.
Sharetribe Go includes a Custom Landing Page add-on and editor. You can learn more about it here.
The Custom Landing Page Editor should be available automatically, from v9.1.0. If this is not the case, you can find plenty of useful information in the Landing Pages for Idiots Like Me post written by Jeremy D Evans.
Sharetribe follows Semantic Versioning where possible.
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make incompatible API changes,
- MINOR version when you add functionality in a backwards-compatible manner, and
- PATCH version when you make backwards-compatible bug fixes.
See the document How Sharetribe applies Semantic Versioning to read more how Semantic Versioning is applied in practice.
See CHANGELOG.md for detailed list of changes between releases.
See UPGRADE.md for information about actions needed when upgrading.
For production use we recommend you to upgrade only when new version is released and not to follow the master branch.
Would you like to make Sharetribe better?
See CONTRIBUTING.md for the steps to contribute.
See RELEASE.md for information about how to make a new release.
Sharetribe uses WebTranslateIt (WTI) for translations. If you'd like to translate Sharetribe to your language or improve existing translations, please ask for a WTI invitation. To get an invite, send an email to info@sharetribe.com and mention that you would like to become a translator.
All language additions and modifications (except for English) should be done through the WTI tool. We do not accept Pull Requests that add or modify languages (except English).
Browse open issues and submit new ones in Github Issues.
We are dedicating the Github Issue only for bugs in the Sharetribe codebase. For general questions, start a new thread in the Community forum instead of opening a new Issue.
After you have opened a new issue, the team will handle it according to these instructions: How to handle Github Issues
More detailed technical documentation is located in docs/
The Sharetribe Community forum is located at https://www.sharetribe.com/community/.
The forum is a great place to ask support and help for example with issues during the installation.
Sharetribe Go is source-available under the Sharetribe Community Public License. See LICENSE for details.
- Add Landing Page
- Add customized search bar (number of guests provided as option
- Add Payment processing for booking
- Add Weekly, Monthly, Daily booking options
- Customize Landing Page
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Mustafa Ali - mustafa.abdi.ali@gmail.com
Project Link: https://github.com/mufasali/Agora
Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!