Development setup
Prerequisites
- Node.js >= 20
- Bun >= 1.3.14 (the only supported package manager)
- PostgreSQL >= 13, or Docker for the quick-start path
Clone and install
git clone https://codefloe.com/flexcal/flexcal.gitcd flexcalbun installOn Windows, clone from Git Bash with admin privileges so symlinks are created:
git clone -c core.symlinks=true https://codefloe.com/flexcal/flexcal.gitEnvironment
cp .env.example .envGenerate the two mandatory secrets and put them in .env:
# NEXTAUTH_SECRETopenssl rand -base64 32# CALENDSO_ENCRYPTION_KEY, must be 32 bytes for AES256openssl rand -base64 24:::note[Windows]
Replace the packages/prisma/.env symlink with a real copy, otherwise Prisma fails with
unexpected character / in variable name:
rm packages/prisma/.env && cp .env packages/prisma/.env:::
Quick start
bun run dx starts a local Postgres in Docker, applies migrations and seeds test users.
It needs Docker and Docker Compose.
bun run dxSeeded users, password equal to the username unless noted:
| Password | Role | |
|---|---|---|
free@example.com | free | Free user |
pro@example.com | pro | Pro user |
trial@example.com | trial | Trial user |
admin@example.com | ADMINadmin2022! | Admin |
onboarding@example.com | onboarding | Onboarding incomplete |
Sign in at http://localhost:3000.
Run bun run db-studio and open http://localhost:5555 to see the full list of
seeded users.
Manual setup
If you already run PostgreSQL, skip dx and wire it up yourself.
-
Point
DATABASE_URLat your database:DATABASE_URL='postgresql://<user>:<pass>@<db-host>:<db-port>/<db-name>'To create a local database from scratch: install PostgreSQL, run
createdb <name>, then confirm the connection details with\conninfoinsidepsql -h localhost -U postgres -d <name>. -
Copy
.env.appStore.exampleto.env.appStoreand paste the sameDATABASE_URLinto it. -
Apply the schema (
packages/prisma/schema.prisma):Terminal window bun run --cwd packages/prisma db-migrate -
Start MailHog to catch outgoing mail. Required when
E2E_TEST_MAILHOG_ENABLEDis1:Terminal window docker run -d -p 8025:8025 -p 1025:1025 mailhog/mailhog -
Run the dev server:
Terminal window bun run dev -
Seed dummy users if you want them:
Terminal window bun run --cwd packages/prisma db-seed
Everyday commands
# type-check the whole monorepobun run type-check:ci --force# lint and format with Biomebunx biome check --write .# unit testsTZ=UTC bun run test# regenerate Prisma types after a schema changebun run prisma generateTips
Give Node a bigger heap; the build is memory-hungry:
export NODE_OPTIONS="--max-old-space-size=16384"Turn up tRPC logging with NEXT_PUBLIC_LOGGER_LEVEL in .env. See
Configuration → Logging for the levels.
Project layout
| Path | Contents |
|---|---|
apps/web | The Next.js application |
packages/prisma | Schema and migrations |
packages/trpc | tRPC API layer |
packages/features | Framework-agnostic feature code: services, repositories, types |
packages/ui | Shared UI components |
packages/app-store | Third-party integrations |
packages/lib | Shared utilities |
packages/i18n | Translation source strings |