{"id":21590241,"url":"https://github.com/corbado/nextjs-prisma-example","last_synced_at":"2025-07-22T10:39:49.812Z","repository":{"id":257759161,"uuid":"852254308","full_name":"corbado/nextjs-prisma-example","owner":"corbado","description":"User management system built with Next.js 14, Prisma ORM, and MongoDB. Includes API routes, React state management, and error handling. Perfect for full-stack development with Prisma and MongoDB integration.","archived":false,"fork":false,"pushed_at":"2024-09-18T07:26:12.000Z","size":74,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T16:22:30.410Z","etag":null,"topics":["crud-operation","fullstack-development","mongodb","nextjs14","orm","prisma","prisma-orm","routes-api","tailwindcss","user-management"],"latest_commit_sha":null,"homepage":"https://www.corbado.com/blog/nextjs-prisma","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/corbado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-04T13:49:27.000Z","updated_at":"2025-01-10T10:46:42.000Z","dependencies_parsed_at":"2024-09-18T14:21:57.936Z","dependency_job_id":null,"html_url":"https://github.com/corbado/nextjs-prisma-example","commit_stats":null,"previous_names":["corbado/nextjs-prisma-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corbado%2Fnextjs-prisma-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corbado%2Fnextjs-prisma-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corbado%2Fnextjs-prisma-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/corbado%2Fnextjs-prisma-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/corbado","download_url":"https://codeload.github.com/corbado/nextjs-prisma-example/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244198406,"owners_count":20414443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crud-operation","fullstack-development","mongodb","nextjs14","orm","prisma","prisma-orm","routes-api","tailwindcss","user-management"],"created_at":"2024-11-24T16:17:12.763Z","updated_at":"2025-03-18T10:14:08.851Z","avatar_url":"https://github.com/corbado.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next.js Prisma User Management App with MongoDB\n\nThis project demonstrates a user management system built with **Next.js 14**, **Prisma**, and **MongoDB**. The app provides a form to add new users and displays a list of existing users, leveraging Prisma's ORM capabilities for database interaction.\n\n## Features\n\n- **Next.js 14**: Server-side rendering (SSR) and API routes.\n- **Prisma ORM**: Integrated with MongoDB to manage user data.\n- **MongoDB**: For data storage.\n- **Tailwind CSS**: For minimal and responsive design.\n- **Docker**: For containerizing the app and its services.\n\n## API Endpoints\n\n- **GET** `/api/getListUsers`: Fetch all users.\n- **POST** `/api/createUser`: Create a new user with `name` and `email` in the request body.\n\n## Prisma Schema\n\nThe `User` model is defined in the Prisma schema:\n\n```prisma\nmodel User {\n  id    String @id @default(auto()) @map(\"_id\") @db.ObjectId\n  name  String\n  email String @unique\n}\n```\n\n## Running the Application with Docker\n\n**1. Start the Containers**\n\nTo start the MongoDB and Next.js containers, run the following command:\n\n```\ndocker-compose up --build\n ```\nThis will:\n\n* Build and start the MongoDB container on port 27017.\n* Build and start the Next.js app on port 3000.\n* Generate the Prisma Client inside the Next.js app Docker container. \n\n**2. Initialize MongoDB Replica Set**\n\nOnce the containers are running, you must initialize the MongoDB replica set. In a new terminal, run these commands:\n\n\n2.1 Access the MongoDB shell inside the running container:\n    \n```\ndocker exec -it mongodb mongosh\n```\n\n2.2 Initiate the replica set by running the following command inside the MongoDB shell:\n\n```\nrs.initiate()\n```\n\n2.3 Verify the replica set status (optional but recommended):\n\n```\nrs.status()\n```\n\nOnce the replica set is initialized, Prisma can connect to the database.\n\n**3. Access the application**\n\nAfter initializing the MongoDB replica set, you can access the Next.js app in your browser at: `http://localhost:3000`.\n\nThen, add new users via the form and view the user list below it.\n\n## Useful commands\n\n\n\n* List the running Docker containers\n\n```\ndocker ps\n```\n\n* Stop and remove containers and volumes:\n\n```\ndocker-compose down -v\n```\n\n* Prisma Migrate\n\nIf you make changes to your Prisma schema, you’ll need to reflect those changes in your database:\n\n```\nnpx prisma db push\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorbado%2Fnextjs-prisma-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorbado%2Fnextjs-prisma-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorbado%2Fnextjs-prisma-example/lists"}