This is a Next.js project bootstrapped with create-t3-app
.
First, run the development server:
pnpm i && pnpm dev
Open http://localhost:3000 with your browser to see the results.
We try to keep this project as simple as possible, so you can start with just the scaffolding we set up for you, and add additional things later when they become necessary.
If you are not familiar with the different technologies used in this project, please refer to the respective docs.
To interact with AWS resources locally, configure AWS SSO for the desired environment.
Ensure you have the following installed:
To assist with the creation of a SSO profile, please refer to the Makefile
:
Usage: make <target> profile=<profile> env=<environment (dev,qa,prod)>
Targets:
login Log in using AWS SSO
dev Run development server
seed Run database seed
migration Run database migration
studio Open Prisma Studio
- Run the following command to configure AWS SSO for your desired environment:
This sets the default
profile
andenvironment
respectively:nucleus
,dev
make dev
This opens your browser to configure/login to AWS SSO. Upon success, you will be given temporary credentials using the configured role.
- Run the following command to create a
new
AWS SSO profile for a specific environment. The process will attempt to login to exisitng profile, if exist, or prompt otherwise.
make dev profile=<profile> env=<environment>
- Follow the prompts to set up the correct AWS and IAM role.
SSO session name (Recommended): <profile>-<env>
SSO start URL [None]: https://awsinnovationrefunds.awsapps.com/start
SSO region [None]: us-east-1
# Choose from available AWS accounts and roles.
CLI default client Region [None]: us-east-1
CLI default output format [None]: json
- Update your
.env
file with the name of the profile you just created.
AWS_PROFILE=<profile>-<env>
AWS_S3_BUCKET=<bucket>
Prisma is the database toolkit used in this project, providing a seamless and type-safe way to interact with the database. Here are some key points for using Prisma effectively in the application.
The Prisma Client is auto-generated based on the database shema defined in schema.prisma
. It provides a type-safe API for the database queries, making it easier to work with the data in a type-safe manner.
// pages/api/users
import { db } from "@/server/db";
export default async function handler(req: NextApiRequest, res: NextApiResponse<User[]>) {
const users = await db.user.findMany();
res.status(200).json(users);
}
Prisma supports advanced query features such as filtering, sorting, and pagination. Leverage these features to efficiently retrieve and manipulate data from the database.
import { db } from "@/server/db";
await prisma.$transaction(async (tx) => {
// 1. Create a new user ...
const user = await db.user.create({
data: {
email: "[email protected]",
name: "Nikolas Burk",
},
});
// 2. ... then load the number of users in the database ...
const count = await prisma.user.count();
// 3. ... and use the `count` as information in a new query
await prisma.post.create({
data: {
title: `I am user #${count} in the database.`,
authorId: user.id,
},
});
});
For more advanced features, visit Prisma playground
Utilize Prisma's support for defining and querying relationships between models. This allows us to model complex data structures and retrieve related data seamlessly.
model Post {
id Int @id @default(autoincrement())
title String
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId Int
}
const publishedAuthors = await prisma.user.findMany({
include: {
posts: {
where: {
published: true,
/**
* Feel free to uncomment the lines below to add more filters to your query
*/
// title: {
// contains: 'Prisma'
// }
},
},
},
});
Prisma supports migrations to manage changes to the database schema. As the project evolves, use migrations to update the database schema without losing data.
npx prisma migrate dev # To apply migrations in development
npx prisma migrate deploy # To apply migrations in production
Below, you can find git conventions that should be followed within the whole repository.
- Follow the Conventional Commits
strategy according to this pattern:
type(optional scope): write short message in lower case and imperative
- Commit types are following:
feat
- feature developmentfix
- bug fixrefactor
- refactoringdocs
- documentationtest
- testschore
- grunt tasks (no production code change)style
- code style change
- Examples:
feat(company-info): add delete button
chore: setup repository
- Start branch with the same type as for commit messages, described above.
- Follow the type with slash and short description of the change in
lowercase
andkebab-case
. - Examples:
feat/delete-button
chore/repository-setup
Follow our deployment guides for Vercel, Netlify and Docker for more information.
To learn more about the T3 Stack, take a look at the following resources:
- Documentation
- Learn the T3 Stack β Check out these awesome tutorials
You can check out the create-t3-app GitHub repository β your feedback and contributions are welcome!
Happy coding! π