Getting Started
Relevant source files
The following files were used as context for generating this wiki page:This guide provides comprehensive instructions for setting up the Analog project for local development. Analog is an open-source calendar application designed to provide a seamless and powerful user experience. Following these steps will result in a fully functional local instance, including the web frontend, backend services, and a PostgreSQL database.
The setup process involves cloning the repository, installing dependencies using Bun, configuring environment variables for services like Google and Microsoft OAuth, setting up a PostgreSQL database with Docker, and running the development server. This guide is based on the official project documentation and is intended for developers looking to contribute or run their own instance of Analog. For more details on how to contribute, see the Contributing section.
Sources: README.md:2-3, README.md:12-14
Prerequisites
Before you begin, ensure you have the following software installed on your machine. These tools are essential for managing dependencies, running the application, and orchestrating the database service.
| Tool | Description | Installation Guide |
|---|---|---|
| Bun | A fast JavaScript runtime, package manager, bundler, and test runner. | bun.sh/docs/installation |
| Docker Desktop | Required for running the PostgreSQL database in a container. | docker.com/products/docker-desktop |
Sources: README.md:18-23
Local Development Setup
This section walks through the entire process of setting up the Analog project on your local machine.
The following diagram illustrates the overall setup flow.
This diagram shows the step-by-step process for getting the Analog application running locally.
Sources: README.md:12-81, CONTRIBUTING.md:7-70
1. Clone Repository & Install Dependencies
First, clone the Analog repository from GitHub to your local machine and navigate into the project directory. Then, use Bun to install all the necessary dependencies defined in the package.json files across the monorepo workspaces.
# Clone the repository
git clone https://github.com/analogdotnow/analog.git
cd analog
# Install dependencies
bun install
Sources: README.md:27-35, CONTRIBUTING.md:10-20
2. Configure Environment Variables
The project uses environment variables for configuration. Copy the example file to create your local configuration.
cp .env.example .env
You must then edit the newly created .env file to provide secrets for authentication and API access. The file contains default values for DATABASE_URL and BETTER_AUTH_URL.
| Variable | Description | How to Generate - |
|---|---|---|
BETTER_AUTH_SECRET | A secure secret for the authentication service. | Run openssl rand -hex 32 in your terminal. - |
GOOGLE_CLIENT_ID | Google OAuth Client ID. | Create a project in the Google Cloud Console and follow the Better Auth documentation. |
GOOGLE_CLIENT_SECRET | Google OAuth Client Secret. | From the same Google Cloud project credentials. - |
MICROSOFT_CLIENT_ID | Microsoft OAuth Client ID. (Optional) | Register an application in the Microsoft Azure Portal. - |
MICROSOFT_CLIENT_SECRET | Microsoft OAuth Client Secret. (Optional) | From the same Azure App registration. - |
GOOGLE_MAPS_API_KEY | Google Places API Key. | In the Google Cloud project, enable the "Places API (New)" and create an API key. - |
Sources: README.md:37-43, CONTRIBUTING.md:22-30
3. Set Up OAuth Providers
Analog uses Better Auth for handling OAuth, primarily with Google and optionally with Microsoft.
Google OAuth Setup
This is required for core calendar functionality.
This diagram shows the sequence of actions for setting up Google OAuth.
Steps:
- Create a project in the Google Cloud Console.
- Set up Google OAuth credentials by following the Better Auth documentation.
- Enable the Google Calendar API for your project.
- In the OAuth consent screen settings under the "Audience" tab, add your Google account email(s) to the 'Test users' list.
- Set the
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETin your.envfile.
Sources: README.md:47-59, CONTRIBUTING.md:34-48
Microsoft OAuth Setup (Optional)
Follow these steps if you need to integrate with Microsoft calendars.
- Navigate to Microsoft Entra ID → App registrations in the Microsoft Azure Portal.
- Register a new application.
- Set the redirect URI to
http://localhost:3000/api/auth/callback/microsoft. - Copy the Application (client) ID to
MICROSOFT_CLIENT_IDin your.envfile. - Under Certificates & secrets, create a new client secret and copy its value to
MICROSOFT_CLIENT_SECRET. - Under API permissions, add the following delegated permissions from Microsoft Graph:
Calendars.ReadCalendars.ReadWriteUser.Readoffline_access
Sources: README.md:61-70, CONTRIBUTING.md:50-61
4. Database Setup
Analog uses a PostgreSQL database, which can be easily run using Docker and Docker Compose.
-
Start the Database Container:
This command reads thedocker-compose.ymlfile and starts the PostgreSQL service in the background.bun run docker:upSources: package.json:8, README.md:76-80
-
Initialize the Database:
Once the container is running, this command will push the database schema (defined with Drizzle ORM) to the PostgreSQL instance.bun run db:pushSources: package.json:13, README.md:83-86, CONTRIBUTING.md:65-66
5. Run the Application
With the environment and database configured, you can now start the Next.js development server.
bun run dev
The application will be running and accessible at http://localhost:3000. The dev script uses turbo to run the development servers for all workspaces in the monorepo.
Sources: README.md:90-94, CONTRIBUTING.md:69-70, package.json:6
Project Structure and Tech Stack
Analog is a monorepo managed with turbo. The main application is a Next.js app located in apps/web. It communicates with a tRPC API defined in packages/api.
This diagram provides a high-level overview of the project's architecture.
Sources: package.json:18-22, README.md:96-98, apps/web/package.json, packages/api/package.json
Tech Stack
The project utilizes a modern web development stack:
| Category | Technology - |
|---|---|
| Web | Next.js, TypeScript, Tailwind v4, Bun, tRPC, TanStack Query, shadcn/ui - |
| Database | Drizzle with PostgreSQL - |
| Authentication | Better Auth for Google OAuth - |
Sources: README.md:96-98
Key Scripts
The root package.json contains several scripts, orchestrated by turbo, to manage the development lifecycle.
| Script | Description - |
|---|---|
bun run dev | Starts the development server for all workspaces. The web app runs on localhost:3000. - |
bun run build | Builds all workspaces for production. - |
bun run docker:up | Starts the PostgreSQL database container in detached mode using docker compose. - |
bun run db:push | Pushes the Drizzle ORM schema to the running database instance. - |
Sources: package.json:5-14
Contributing
Contributions to Analog are welcome. The process involves forking the repository, creating a feature branch, making changes, and then opening a pull request. It is important to follow the conventional commit message format. For more detailed instructions, please refer to the CONTRIBUTING.md file.
Sources: CONTRIBUTING.md