This repo is a template for a strongly typed full-stack monorepo with NextJS.
The template provides the architecture for--
- Using
next
with a separate API, idiomatically leveragingnext
's nativefetch
integration to cache API calls. - Using
prisma
,fastify
+zod
, andopenapi-typescript
to statically type from the database to the front-end. - Creating a minimalist 3-tier architecture, like NestJS but without the boilerplate and maximalism.
- Dependency Injection without the complexity of a full-blown DI framework.
- Using
async_hooks
to create request-scoped "services". - Using closures to create singleton "services".
- Using
- Using
fastify
to mimicnestjs
controllers but with the minimalism ofexpress
.
- Dependency Injection without the complexity of a full-blown DI framework.
zod
- minimalist but full-powered validation library used wherever possible, especially at the API layerfastify
- likeexpress
, but withzod
validation and type safetyprisma
- ORM with a minimalist schema modeling language, easy-to-use migrations, and type generationnext
- React framework providing front-end architecture, caching, authentication, etc., but with limitations for server-side codeopenapi-typescript
- generates typescript types for a OpenAPI specs derived from ourfastify
APIfetch
- integrates withnextjs
to cache API calls- PostgreSQL - the best database for
prisma
See the READMEs in each project for more information.
- NVM
- VS Code (Install all recommended extensions)
- Run
nvm use --lts
to use a consistent node version. - In
app
andapi
, create a .env file matching the schemas in src/config.ts. - In
app
andapi
, runnpm install
. - In
api
, runnpx prisma migrate reset
to reset the db. - In
api
, runnpm run gen
. - In
api
, rundocker compose up
. - In
app
andapi
, runnpm run dev
.