chriscoderdr / morro-ride-sharing

1 stars 1 forks source link

Morro Taxi - Developer Documentation

Table of Contents


Overview

Morro Taxi is a ride-sharing application that allows users to request rides, track their drivers, and get real-time location updates. This README provides instructions for setting up the development environment and running the project locally.

Tech Stack

Prerequisites

Installation

1. Clone the Repository

git clone https://github.com/chriscoderdr/morro-ride-sharing.git
cd morro-taxi

2. Install Dependencies

We’re using Yarn Workspaces to manage dependencies in the monorepo. Run the following command in the root directory:

yarn install

3. Configure Environment Variables

Each app (API and mobile apps) has its own .env file with specific configurations. Below are the details for each:

API (apps/api/.env)

# Mapbox
MAPBOX_ACCESS_TOKEN=<your_mapbox_access_token>

# MQTT
MQTT_BROKER_URL=<mqtt_broker_url>
MQTT_PORT=8883
MQTT_TOPIC_RIDE_REQUESTS=/drivers/$driver_id$/location
MQTT_TOPIC_DRIVER_LOCATION=/drivers/$driver_id$/location

# Database
DATABASE_URL=postgres://username:password@localhost:5432/morro_taxi

# API Base URL
API_BASE_URL=http://localhost:3000

Rider App (apps/rider-app/.env)

# Mapbox
EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN=<your_mapbox_access_token>

# MQTT
EXPO_PUBLIC_MQTT_BROKER_URL=<mqtt_broker_url>
EXPO_PUBLIC_MQTT_PORT=8883
EXPO_PUBLIC_MQTT_TOPIC_RIDE_REQUESTS=/drivers/$driver_id$/location
EXPO_PUBLIC_MQTT_TOPIC_DRIVER_LOCATION=/drivers/$driver_id$/location

# API
EXPO_PUBLIC_MORRO_API_BASE_URL=http://localhost:3000

Driver App (apps/driver-app/.env)

# Mapbox
EXPO_PUBLIC_MAPBOX_ACCESS_TOKEN=<your_mapbox_access_token>
EXPO_PUBLIC_MAPBOX_SEARCH_ACCESS_TOKEN=<your_mapbox_access_token>

# MQTT
EXPO_PUBLIC_MQTT_BROKER_URL=<mqtt_broker_url>
EXPO_PUBLIC_MQTT_PORT=8883
EXPO_PUBLIC_MQTT_TOPIC_RIDE_REQUESTS=/drivers/$driver_id$/location
EXPO_PUBLIC_MQTT_TOPIC_DRIVER_LOCATION=/drivers/$driver_id$/location

# API
EXPO_PUBLIC_MORRO_API_BASE_URL=http://localhost:3000

Adjust each .env file to include the proper credentials and keys for the services.

4. Start Docker Services

The project uses Docker for PostgreSQL, Redis, and MQTT services. Start the services by running:

docker-compose up

Running the Project

1. Backend (Koa API)

yarn workspace api run dev

The API server will start at http://localhost:3000.

2. Rider and Driver Mobile Apps (React Native with Expo)

Running the Apps with Expo

To start the Expo development server and open the apps in an emulator or physical device:

You can also use Expo’s run commands to run the apps on specific platforms:

npx expo run:android       # Runs on Android
npx expo run:ios           # Runs on iOS (macOS only)

Running the iOS Apps

In Xcode, open the workspaces for each project:

Once opened, you can build and run the apps directly on an iOS simulator or connected iOS device.

Running the Android Apps

The Android apps can be compiled using Gradle commands:

Make sure you have Gradle, Java, and Android SDK installed and configured, as these are required for building Android projects.

Testing

Project Structure

Here’s a high-level overview of the project structure:

/morro-taxi
├── apps
│   ├── api                # Backend code (Koa)
│   ├── rider-app          # Rider mobile app (React Native)
│   ├── driver-app         # Driver mobile app (React Native)
├── packages
│   ├── morro-taxi-rn-components  # Shared UI components
│   └── utils              # Shared utilities and configuration
├── docker-compose.yml     # Docker configuration
├── .env                   # Environment variables
└── README.md

Additional Notes

Known Issues

Deployment Optimizations

When deploying the project to a server, the following directories can be deleted to improve yarn install times:

Since the project uses Yarn Workspaces, deleting these folders will reduce install times without affecting other packages in the workspace.

Contributing

When contributing, please adhere to the commit message format and PR guidelines:

  1. Commit Message Format: Use feat(#issue): message for commits.
  2. PR Titles: Include the user story or feature name in the title.