This guide will help you set up the project on your local machine. Please follow the instructions carefully to ensure a smooth setup experience.
Note: This project is currently in a semi-public alpha phase. If you encounter any issues or have questions, feel free to raise an issue on GitHub.
- Prerequisites
- Clone the Repository
- Set Up Environment Variables
- Configure Cloud Services
- Run the Application
- Accessing the Application
- Troubleshooting
- Additional Resources
Before setting up KoalaCards, ensure that your system meets the following prerequisites.
KoalaCards requires Node.js to run. It's recommended to use the latest Long-Term Support (LTS) version.
-
Download Node.js:
Visit the official Node.js website and download the installer for your operating system.
-
Install Node.js:
Run the downloaded installer and follow the on-screen instructions.
-
Verify Installation:
Open your terminal or command prompt and run:
node -v npm -v
You should see the installed versions of Node.js and npm.
v22.x.x 10.x.x
Note: KoalaCards has been tested with Node.js v22. It's recommended to use this version to avoid compatibility issues.
Docker is essential for containerizing the application and its dependencies.
-
Download Docker:
Visit the official Docker website and download Docker Desktop for your operating system.
-
Install Docker:
Run the downloaded installer and follow the installation prompts.
-
Verify Installation:
Open your terminal or command prompt and run:
docker --version
You should see the installed Docker version.
Docker version 24.x.x, build xxxxxxx
Docker Compose is used to manage multi-container Docker applications.
-
Check if Docker Compose is Installed:
Docker Desktop typically includes Docker Compose. Verify by running:
docker-compose --version
You should see the installed Docker Compose version.
docker-compose version 2.x.x, build xxxxxxx
-
If Not Installed, Install Docker Compose:
Follow the official Docker Compose installation guide for your operating system.
TailScale is used for secure networking and is required for magic link sign-in functionality in KoalaCards.
Note: If you intend to use the magic link sign-in feature, installing TailScale is mandatory. Otherwise, it's optional.
-
Download TailScale:
Visit the official TailScale website and download the appropriate installer for your operating system.
-
Install TailScale:
Run the downloaded installer and follow the installation prompts.
-
Authenticate TailScale:
After installation, launch TailScale and follow the on-screen instructions to authenticate and connect to your TailScale network.
To get started, clone the KoalaCards repository from GitHub.
-
Open Terminal or Command Prompt:
-
Clone the Repository:
git clone [email protected]:RickCarlino/KoalaCards.git
Note: Ensure you have SSH access to GitHub. If you prefer HTTPS, use:
git clone https://github.com/RickCarlino/KoalaCards.git
-
Navigate to the Project Directory:
cd KoalaCards
Environment variables are crucial for configuring the application. Follow these steps to set them up.
-
Copy the Example Environment File:
cp example.env .env
-
Open the
.env
File:Use your preferred text editor to open the
.env
file.nano .env
Replace
nano
with your editor of choice (e.g.,vim
,code
for VS Code). -
Fill Out the Required Environment Variables:
Update the
.env
file with your specific configurations. Below are the key variables you need to set:# Database Configuration POSTGRES_USER=prisma POSTGRES_PASSWORD=your_password POSTGRES_DB=prisma_dev POSTGRES_URI=postgres://prisma:your_password@db:5432/prisma_dev # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key # Google Cloud Configuration GOOGLE_APPLICATION_CREDENTIALS=./path-to-your-gcs-credentials.json
Security Tip: Never commit your
.env
file to version control. Ensure it's listed in your.gitignore
. -
Save and Close the
.env
File:If using
nano
, pressCTRL + O
to save andCTRL + X
to exit.
KoalaCards integrates with external cloud services like OpenAI and Google Cloud. Follow the steps below to configure these services.
-
Create an OpenAI Account:
If you don't have one, sign up at OpenAI.
-
Generate an API Key:
- Navigate to the API Keys section in your OpenAI dashboard.
- Click on "Create new secret key".
- Copy the generated API key.
-
Update the
.env
File:Open the
.env
file and set theOPENAI_API_KEY
:OPENAI_API_KEY=sk-your-openai-api-key
Security Tip: Keep your API keys secure and avoid sharing them publicly.
-
Create a Google Cloud Account:
If you don't have one, sign up at Google Cloud.
-
Create a New Project:
- Navigate to the Google Cloud Console.
- Click on "Select a project" and then "New Project".
- Enter a project name and click "Create".
-
Enable Required APIs:
- Go to APIs & Services > Library in the Google Cloud Console.
- Search for and enable the following APIs:
- Cloud Speech-to-Text API
- Cloud Text-to-Speech API
-
Create a Service Account:
- Navigate to APIs & Services > Credentials.
- Click on "Create Credentials" and select "Service Account".
- Enter a name and description for the service account.
- Assign the necessary roles (e.g., "Cloud Speech Client", "Cloud Text-to-Speech Client").
- Click "Done".
-
Generate a JSON Key for the Service Account:
- In the Service Accounts list, find your newly created service account.
- Click on the three dots under Actions and select "Manage Keys".
- Click "Add Key" > "Create new key" > "JSON" > "Create".
- A JSON file will be downloaded to your machine. Keep this file secure.
-
Update the
.env
File:Place the downloaded JSON credentials file in the project directory (e.g.,
./credentials/gcs.json
) and update the.env
file:GOOGLE_APPLICATION_CREDENTIALS=./credentials/gcs.json
Security Tip: Do not commit your credentials file to version control. Ensure it's listed in your
.gitignore
.
With all configurations in place, you can now run KoalaCards using Docker Compose.
-
Ensure Docker is Running:
Make sure Docker Desktop is up and running on your machine.
-
Build and Start the Services:
From the project root directory, run:
docker-compose up -d --build
-d
: Runs the containers in detached mode (in the background).--build
: Rebuilds the images if there are any changes in theDockerfile
or dependencies.
-
Verify the Services are Running:
docker-compose ps
You should see both
app
anddb
services running. -
Apply Database Migrations:
The
entrypoint.sh
script automatically handles migrations when theapp
container starts. To manually run migrations, you can execute:docker-compose exec app npx prisma migrate deploy
-
Access Prisma Studio (Optional):
Prisma Studio provides a visual interface to interact with your database.
docker-compose exec app npx prisma studio
Open the provided URL in your browser to access Prisma Studio.
Once the application is running, you can access it via your web browser.
-
Open Your Browser:
-
Navigate to:
http://localhost:3000
If you encounter any issues during setup or while running the application, consider the following steps:
-
Check Container Logs:
View logs for all services:
docker-compose logs -f
To view logs for a specific service (e.g.,
app
):docker-compose logs -f app
-
Restart Services:
Sometimes, restarting the services can resolve transient issues.
docker-compose restart
-
Rebuild Containers:
If you've made changes to the
Dockerfile
or dependencies, rebuild the containers.docker-compose up -d --build
-
Verify Environment Variables:
Ensure that all required environment variables in the
.env
file are correctly set and that sensitive information like API keys and credentials are accurate. -
Check Docker Resources:
Ensure that Docker has sufficient resources (CPU, memory) allocated. You can adjust these settings in Docker Desktop under Settings > Resources.
-
Ensure Network Connectivity:
If using TailScale, verify that it's properly installed and connected. This is essential for the magic link sign-in feature.
-
Reset Migrations (Development Only):
If migrations are out of sync, you can reset them. Warning: This will delete all data in the database.
docker-compose exec app npx prisma migrate reset
-
Seek Help:
If problems persist, raise an issue on GitHub with detailed information about the issue.
- Docker Documentation: https://docs.docker.com/
- Prisma Documentation: https://www.prisma.io/docs/
- OpenAI API Reference: https://platform.openai.com/docs/api-reference
- Google Cloud Speech-to-Text: https://cloud.google.com/speech-to-text/docs
- Google Cloud Text-to-Speech: https://cloud.google.com/text-to-speech/docs
- TailScale Documentation: https://tailscale.com/kb/
These instructions may be out of date. Please raise an issue if things don't work!