This repo is a template for a strongly typed full-stack monorepo with NextJS.
The template provides the architecture for--
- Using
nextwith a separate API, idiomatically leveragingnext's nativefetchintegration to cache API calls. - Using
prisma,fastify+zod, andopenapi-typescriptto 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_hooksto create request-scoped "services". - Using closures to create singleton "services".
- Using
- Using
fastifyto mimicnestjscontrollers 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 withzodvalidation 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 ourfastifyAPIfetch- integrates withnextjsto 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 --ltsto use a consistent node version. - In
appandapi, create a .env file matching the schemas in src/config.ts. - In
appandapi, runnpm install. - In
api, runnpx prisma migrate resetto reset the db. - In
api, runnpm run gen. - In
api, rundocker compose up. - In
appandapi, runnpm run dev.