{"id":15023842,"url":"https://github.com/dodycode/nextjs-trpc-boilerplate","last_synced_at":"2025-04-12T06:32:22.020Z","repository":{"id":257088651,"uuid":"857295127","full_name":"dodycode/nextjs-trpc-boilerplate","owner":"dodycode","description":"my personal t3 stack app boilerplate that using repository pattern","archived":false,"fork":false,"pushed_at":"2025-02-22T04:18:41.000Z","size":1813,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T02:03:48.193Z","etag":null,"topics":["drizzle","drizzle-orm","nextjs","reactjs","repository-pattern","shadcn","shadcn-ui","shadcnui","t3-stack","t3-stack-template"],"latest_commit_sha":null,"homepage":"","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/dodycode.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-14T09:16:08.000Z","updated_at":"2025-02-22T04:18:41.000Z","dependencies_parsed_at":"2024-09-14T20:05:23.086Z","dependency_job_id":"13b60186-f23c-4fb3-865b-f2840db359a4","html_url":"https://github.com/dodycode/nextjs-trpc-boilerplate","commit_stats":null,"previous_names":["dodycode/nextjs-trpc-boilerplate"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodycode%2Fnextjs-trpc-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodycode%2Fnextjs-trpc-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodycode%2Fnextjs-trpc-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dodycode%2Fnextjs-trpc-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dodycode","download_url":"https://codeload.github.com/dodycode/nextjs-trpc-boilerplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248529831,"owners_count":21119580,"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":["drizzle","drizzle-orm","nextjs","reactjs","repository-pattern","shadcn","shadcn-ui","shadcnui","t3-stack","t3-stack-template"],"created_at":"2024-09-24T19:59:30.206Z","updated_at":"2025-04-12T06:32:21.976Z","avatar_url":"https://github.com/dodycode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next JS Boilerplate with tRPC + Repository Design Pattern\n\nA customized version of the [T3 Stack App](https://create.t3.gg/) that I use in my daily work.\n\nFeel free to fork and customize it to suit your needs.\n\n## Features\n\n- **Next.js 15**: Next 15 with Server Actions \u0026 React 19\n- **TypeScript**: For type-safe JavaScript development\n- **tRPC**: End-to-end typesafe APIs\n- **Drizzle ORM**: TypeScript ORM for SQL databases\n- **Auth.JS (formerly known as NextAuth.js)**: Authentication for Next.js\n- **Zod**: Runtime type checking and validation\n- **shadcn/ui**: Beautifully designed components built with Radix UI and Tailwind v4!\n- **Repository Pattern**: For clean separation of data access logic\n- **Service Layer**: Business logic abstraction\n- **Tailwind CSS**: Utility-first CSS framework\n- **ESLint**: For identifying and fixing code quality issues\n- **Prettier**: For consistent code formatting\n\n## Project Structure\n\n![trpc-nextjs](https://github.com/user-attachments/assets/51542592-adc5-422a-a465-d824f529500d)\n\n## Getting Started\n\n1. Clone the repository:\n\n```\n\ngit clone https://github.com/dodycode/nextjs-trpc-boilerplate.git\ncd nextjs-trpc-boilerplate\n\n```\n\n2. Install dependencies:\n   Using pnpm (recommended):\n\n```\n\npnpm install\n\n```\n\nOr using npm:\n\n```\n\nnpm install\n\n```\n\n3. Set up your environment variables:\n\n- Copy `.env.example` to `.env`\n- Update the necessary variables in `.env`\n\n4. Set up the database:\n   First, start the database container:\n\n```\n\n./start-database.sh\n\n```\n\nThen, generate the database schema:\nUsing pnpm:\n\n```\n\npnpm db:generate\n\n```\n\nOr using npm:\n\n```\n\nnpm run db:generate\n\n```\n\nNow, create the initial migration and apply it:\nUsing pnpm:\n\n```\n\npnpm db:migrate\n\n```\n\nOr using npm:\n\n```\n\nnpm run db:migrate\n\n```\n\n5. Start the development server:\n   Using pnpm:\n\n```\n\npnpm dev\n\n```\n\nOr using npm:\n\n```\n\nnpm run dev\n\n```\n\nThe server should now be running on `http://localhost:3000`.\n\n## Database Management\n\nThis project uses Drizzle ORM for database management. Here are the available scripts and when to use them:\n\nUsing pnpm:\n\n- `pnpm db:generate`: Generate Drizzle migration files (run this after making changes to your schema)\n- `pnpm db:migrate`: Run Drizzle migrations (use this for the initial setup and when you want to apply migrations)\n- `pnpm db:push`: Push schema changes to the database (use this during development to quickly apply schema changes)\n- `pnpm db:studio`: Open Drizzle Studio for database management\n\nUsing npm:\n\n- `npm run db:generate`: Generate Drizzle migration files\n- `npm run db:migrate`: Run Drizzle migrations\n- `npm run db:push`: Push schema changes to the database\n- `npm run db:studio`: Open Drizzle Studio for database management\n\n### Workflow for Schema Changes\n\n1. Make changes to your schema in `/src/server/db/schema/`\n2. Run `pnpm db:generate` or `npm run db:generate` to create a new migration\n3. Run `pnpm db:push` or `npm run db:push` to apply the changes to your development database\n\nFor production or when you need to keep track of migrations:\n\n1. Make changes to your schema\n2. Run `pnpm db:generate` or `npm run db:generate`\n3. Run `pnpm db:migrate` or `npm run db:migrate` to apply the migrations\n\nRemember to commit the generated migration files to your version control system.\n\n## API Structure\n\nThe project uses tRPC for API routes, with a repository pattern and service layer:\n\n- `src/server/api/routers/your-route-name`: will contains tRPC router, repository classes for data access, service classes for business logic.\n\nExample usage in a tRPC router:\n\n```typescript\nimport { createTRPCRouter, publicProcedure } from \"@/server/api/trpc\";\n\nimport { yourService } from \"./yourmodel.service\";\n\nexport const yourRouter = createTRPCRouter({\n  getData: publicProcedure.query(async () =\u003e {\n    const service = new YourService();\n    return service.getData();\n  }),\n});\n```\n\nYou can check my user and post router as reference.\n\n## Authentication\n\nThis project uses Auth.js for authentication. Configure your providers in `src/server/auth/config.ts`.\n\n## UI Components\n\nThe project uses shadcn UI components. You can find and customize these components in `src/components/ui/`.\n\n## Scripts\n\nUsing pnpm:\n\n- `pnpm dev`: Start the development server\n- `pnpm build`: Build the application for production\n- `pnpm start`: Start the production server\n- `pnpm lint`: Run ESLint to check for code quality issues\n\nUsing npm:\n\n- `npm run dev`: Start the development server\n- `npm run build`: Build the application for production\n- `npm start`: Start the production server\n- `npm run lint`: Run ESLint to check for code quality issues\n\n## Docker Database Setup\n\nThe project includes a `start-database.sh` script to set up a Docker container for the database. This script:\n\n1. Checks for Docker Compose installation\n2. Sets up environment variables from your `.env` file\n3. Offers to generate a random password if you're using the default\n4. Starts the database container\n\nTo use it, ensure you have Docker installed and run:\n\n```\n./start-database.sh\n```\n\n## Preview\n\n- Auth Pages\n  ![Image](https://github.com/user-attachments/assets/acb4176e-aa65-4d23-be27-e0603197224a)\n\n- Protected Pages\n  ![Image](https://github.com/user-attachments/assets/14bfdfa5-f70b-461b-aa20-c1aeabec5d49)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodycode%2Fnextjs-trpc-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdodycode%2Fnextjs-trpc-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdodycode%2Fnextjs-trpc-boilerplate/lists"}