docs/1.23/understand-prisma/prisma-introduction-what-why-how-j9ff.mdx
import Collapse from 'components/Markdown/Collapse'
export const meta = { title: "Prisma Introduction: What, Why & How", position: 10, description: 'Learn about Prisma's use cases, main benefits and how it fits into your stack.' }
Prisma is a data layer that replaces traditional ORMs in your application architecture.
The data layer consists of several components:
Prisma is open-source and can be used as a standalone infrastructure component hosted on your favorite cloud provider. Prisma Cloud is an application (used through a CLI & web interface) that provides tools and services around Prisma. When you're using Prisma, usage of Prisma Cloud is optional.
The goal of Prisma Cloud is to ease the workflows in Prisma projects. It features a data browser, a deployment history (soon with automatic rollbacks), various team collaboration options as well as cloud provider integrations to make it easy for developers to setup and maintain their Prisma servers.
Get started with Prisma Cloud here.
</Collapse>Prisma is useful in any context where you're working with databases.
Prisma is the perfect tool for building GraphQL servers. The Prisma client is compatible with the Apollo ecosystem, has default support for GraphQL subscriptions and Relay-style pagination, provides end-to-end type safety and comes with a built-in dataloader to solve the N+1 problem.
Prisma is a great fit for building REST APIs where it can be used in place of traditional ORMs. It provides many benefits such as type-safety, a modern API and flexible ways for reading and writing relational data.
Prisma has an extremely flexible API which makes it a great fit for a variety of use cases. Whenever you need to talk to one or more databases, Prisma will be of great help by simplifying database workflows.
Prisma's overall goal is to remove complexity from common database workflows and simplify data access in your applications:
Some databases, such as RethinkDB or DynamoDB provide a realtime API out-of-the box. Such an API lets clients subscribe to any changes happening in the database. The vast majority of conventional databases however does not offer such a realtime API, and implementing it manually gets very complex.
Prisma offers a realtime API for every supported database, letting you subscribe to any database event, such as creating, updating or deleting data.
Programming in a type safe way is the default for modern application development. Here are some of the core benefits type safety provides:
End-to-end type safety refers to having type safety across the entire stack, from client to database. An end-to-end type safe architecture might look as follows:
When developing application servers, most complexity lies in implementing a safe and well-organized database access with respect to synchronization, query optimization/performance and security. This becomes even more complicated when multiple databases are involved.
One common solution to this problem is the introduction of a dedicated data access layer (DAL) that abstracts away the complexities of database access. The DAL's API is consumed by the application server, allowing API developers to simply think about what data they need instead of worrying about how to securely and performantly retrieve it from the database.
Using a DAL ensures a clear separation of concerns and therefore improves maintainability and reusability of your code. Having some sort of database abstraction (be it a simple ORM library or a standalone infrastructure component) is best practice for smaller sized applications as well as for applications running at scale. It ensures the application server can talk to your database(s) in a secure and performant way.
Prisma is an auto-generated DAL following the same principles as industry-leading DALs (such as Twitter's Strato or Facebook's TAO) while still being accessible for smaller applications.
Prisma lets you start your project with a clean architecture from the beginning and saves you from writing the boilerplate that is otherwise required to glue together database and application server.
Prisma is a standalone infrastructure component that sits on top of your database. You're then using a Prisma client (which is available in various languages) in your application server to connect to Prisma.
This enables you to talk to your database(s) through a simple and modern API ensuring highly performant and secure database access.