Local Development Setup
Local Development Setup
This guide provides step-by-step instructions to set up the Synthesis application on your local machine for development and testing.
Prerequisites
Before you begin, ensure you have the following installed:
- Git: For cloning the repository.
- Node.js (v18.x or later): The JavaScript runtime environment. We recommend using a version manager like
nvm. - npm, Yarn, or pnpm: A package manager for Node.js. (npm is included with Node.js)
npm(Node Package Manager)yarn(Runnpm install -g yarn)pnpm(Runnpm install -g pnpm)
- Docker & Docker Compose: For running a local PostgreSQL database.
- Google AI Studio Account & Gemini API Key: Synthesis relies on the Google Gemini API for its AI capabilities.
- Get started with Google AI Studio to generate an API key.
Getting Started
Follow these steps to get the project up and running:
-
Clone the Repository
Open your terminal and clone the Synthesis repository:
git clone https://github.com/omkarspace/synthesis.git cd synthesis -
Install Dependencies
Install the project dependencies using your preferred package manager:
# Using npm npm install # Using Yarn yarn install # Using pnpm pnpm install
Environment Configuration
Synthesis requires specific environment variables to connect to the database and the Gemini API.
-
Create an Environment File
Create a
.envfile in the root of the project by copying the example:cp .env.example .env -
Configure Environment Variables
Open the newly created
.envfile and fill in the following variables:DATABASE_URL: This is the connection string for your PostgreSQL database.GEMINI_API_KEY: Your API key obtained from Google AI Studio.
Your
.envfile should look something like this:# Database connection string (PostgreSQL) DATABASE_URL="postgresql://user:password@localhost:5432/synthesis?schema=public" # Google Gemini API Key GEMINI_API_KEY="YOUR_GEMINI_API_KEY_HERE" # Next.js Public URL (optional, defaults to localhost:3000 in dev) NEXT_PUBLIC_APP_URL="http://localhost:3000"Important: Replace
"YOUR_GEMINI_API_KEY_HERE"with your actual Gemini API key.
Database Setup (PostgreSQL with Docker)
We'll use Docker Compose to easily spin up a local PostgreSQL instance.
-
Start the Database Container
From the project root, start the PostgreSQL container:
docker compose up -d postgresThis command starts a PostgreSQL container in the background. The
DATABASE_URLin your.envfile should match the credentials configured indocker-compose.yml(default:user:password@localhost:5432/synthesis). -
Run Prisma Migrations
Once the database container is running, apply the Prisma schema and migrations:
npx prisma migrate dev --name initThis command will:
- Create the database schema.
- Apply any pending migrations.
- Generate the Prisma client.
-
Generate Prisma Client
Ensure the Prisma client is generated for your application to interact with the database:
npx prisma generate
Running the Application
With all prerequisites and configurations in place, you can now run the Synthesis application.
-
Start the Development Server
# Using npm npm run dev # Using Yarn yarn dev # Using pnpm pnpm devThe application will start on
http://localhost:3000(or another port if 3000 is occupied). -
Access the Application
Open your web browser and navigate to
http://localhost:3000.You should see the Synthesis dashboard, ready for you to create new projects and upload documents.
Optional: Test Gemini API Key
You can quickly verify your GEMINI_API_KEY using a simple script provided:
node test-api.js
This script will attempt to make a call to the Gemini API and report success or failure.
Troubleshooting
Error: PrismaClientKnownRequestError/ Database Connection:- Ensure your Docker container for PostgreSQL is running (
docker ps). - Verify
DATABASE_URLin.envmatches the Docker Compose configuration (username, password, port, database name). - Confirm
npx prisma migrate devran successfully.
- Ensure your Docker container for PostgreSQL is running (
Error: GEMINI_API_KEY is not set!or AI features not working:- Double-check that
GEMINI_API_KEYis correctly set in your.envfile and that there are no leading/trailing spaces or incorrect characters. - Verify your API key is active and has sufficient quotas on Google AI Studio.
- Run
node test-api.jsto isolate the API key issue.
- Double-check that
- File Upload Errors:
- The application creates an
uploadsdirectory in the project root to store uploaded files. Ensure your user has write permissions to the project directory.
- The application creates an
- Module Not Found Errors:
- Run
npm install(oryarn install/pnpm install) again to ensure all dependencies are installed. - Run
npx prisma generateto ensure the Prisma client is up-to-date.
- Run