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 git@github.com: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
.envFile:Use your preferred text editor to open the
.envfile.nano .env
Replace
nanowith your editor of choice (e.g.,vim,codefor VS Code). -
Fill Out the Required Environment Variables:
Update the
.envfile 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 # Optional Reader integration: Instapaper INSTAPAPER_CONSUMER_KEY=your_instapaper_consumer_key INSTAPAPER_CONSUMER_SECRET=your_instapaper_consumer_secret
INSTAPAPER_CONSUMER_KEYandINSTAPAPER_CONSUMER_SECRETare optional. If they are not set, only/reader/instapaperactions are disabled.Security Tip: Never commit your
.envfile to version control. Ensure it's listed in your.gitignore. -
Save and Close the
.envFile:If using
nano, pressCTRL + Oto save andCTRL + Xto exit.
KoalaCards integrates with external cloud services like OpenAI, Google Cloud, and Google OAuth. 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
.envFile:Open the
.envfile 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
.envFile:Place the downloaded JSON credentials file in the project directory (e.g.,
./credentials/gcs.json) and update the.envfile:GOOGLE_APPLICATION_CREDENTIALS=./credentials/gcs.json
Security Tip: Do not commit your credentials file to version control. Ensure it's listed in your
.gitignore.
KoalaCards supports Google Sign-In as an authentication method. Follow these steps to set it up:
-
Use the Same Google Cloud Project:
Use the same project you created in the previous step or create a new one specifically for authentication.
-
Configure OAuth Consent Screen:
- In the Google Cloud Console, go to APIs & Services > OAuth consent screen.
- Select the appropriate user type (External for testing or Internal for organization-only use).
- Fill in the required information:
- App name: KoalaCards
- User support email: Your email address
- Developer contact information: Your email address
- Click Save and Continue.
- Add the necessary scopes (typically
.../auth/userinfo.emailand.../auth/userinfo.profile). - Click Save and Continue and complete the setup.
-
Create OAuth Client ID:
- Go to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Select Web application as the application type.
- Add a name for your OAuth client.
- Add your domain to Authorized JavaScript origins (e.g.,
http://localhost:3000for local development). - Add your callback URL to Authorized redirect URIs (e.g.,
http://localhost:3000/api/auth/callback/googlefor local development). - Click Create.
- Note your Client ID and Client Secret.
-
Update the
.envFile:Add the Google OAuth credentials to your
.envfile:GOOGLE_CLIENT_ID="your-client-id" GOOGLE_CLIENT_SECRET="your-client-secret"
Note: For production, make sure to update the authorized origins and redirect URIs with your production domain.
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 theDockerfileor dependencies.
-
Verify the Services are Running:
docker-compose ps
You should see both
appanddbservices running. -
Apply Database Migrations:
The
entrypoint.shscript automatically handles migrations when theappcontainer starts. To manually run migrations, you can execute:docker-compose exec app npx prisma migrate deployFor hosted environments (for example Northflank), prefer running migrations in a separate deploy/release step:
npm run db:migrate:deploy
Then run the app with:
npm run start:no-migrate
-
Access Prisma Studio (Optional):
Prisma Studio provides a visual interface to interact with your database.
docker-compose exec app npx prisma studioOpen 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
Dockerfileor dependencies, rebuild the containers.docker-compose up -d --build
-
Verify Environment Variables:
Ensure that all required environment variables in the
.envfile 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!