ElectroDrizzle is a modern, full-stack application demonstrating the power of Drizzle ORM, Next.js, and ElectricSQL in a monorepo setup. It showcases local-first development with offline capabilities, seamless database operations, and a robust API.
This project is a monorepo setup using Drizzle ORM, Next.js, and a custom API. It demonstrates a full-stack application with a PostgreSQL database, ElectricSQL for running PGLite in the browser & syncing it with a remote db
The project is organized as a monorepo with the following main components:
apps/
api/
: Hono API servernextjs/
: Next.js frontend application
packages/
db/
: Database schema and migrationstsconfig/
: Shared TypeScript configurations
- Drizzle ORM: Used for database operations and schema management.
- Next.js Frontend: React-based frontend with server-side rendering capabilities.
- Hono API: Custom API for backend operations.
- ElectricSQL Integration: Enables local-first development with offline capabilities.
- PostgreSQL Database: Main database for the application.
- Docker Setup: Includes configurations for PostgreSQL, Redis, and ElectricSQL.
- Node.js (version specified in package.json)
- pnpm (package manager)
- Docker and Docker Compose
-
Clone the repository:
git clone https://github.com/LeonAlvarez/ElectroDrizzle cd drizzle_monorepo
-
Install dependencies:
pnpm install
-
Set up environment variables: Create a
.env
file in the root directory and add necessary variables (refer todocker-compose.yml
for database-related variables). -
Start the Docker services:
pnpm run docker:up
-
Run database migrations:
pnpm run db:migrate
-
Seed the database (if needed):
pnpm run db:seed
-
Start the API server:
pnpm run start:api
-
Start the Next.js frontend:
pnpm run start:next
-
Open
http://localhost:3000
in your browser to view the application.
- API Development: The API is located in
apps/api/
. Usepnpm run dev
in this directory for development. - Frontend Development: The Next.js app is in
apps/nextjs/
. Usepnpm run dev
for development mode. - Database Changes: Make schema changes in
packages/db/schema/
and runpnpm run db:generate
to create new migrations.
- Schema defined using Drizzle ORM
- Migrations handled by Drizzle Kit
- Includes seeding script for initial data
- Hono framework
- Endpoints for users and posts
- Next.js application with App Router
- Integrates ElectricSQL for local-first capabilities
- Custom components like
PgRepl
for database interaction
- The project is set up to be deployed on Vercel (for Next.js frontend)
- API can be deployed to any Node.js hosting service
- Ensure proper environment variables are set in production
Please read CONTRIBUTING.md
for details on our code of conduct and the process for submitting pull requests.
This project is licensed under the ISC License - see the LICENSE
file for details.