Skip to content

Commit 5ff46a1

Browse files
committed
Init Collab
0 parents  commit 5ff46a1

File tree

267 files changed

+24335
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+24335
-0
lines changed

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dockerfile
2+
.dockerignore
3+
node_modules
4+
npm-debug.log
5+
README.md
6+
.next
7+
.git

.env.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
2+
3+
FOLDER_DATA=data
4+
5+
BETTER_AUTH_SECRET=.....# openssl rand -base64 32
6+
BETTER_AUTH_URL=http://localhost:3000
7+
8+
GROQ_API_KEY=.......

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
42+
43+
prisma/generated
44+
45+
data/*
46+
!data/.gitkeep
47+
48+
!/drino-preview/
49+
50+
.idea/

Dockerfile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# syntax=docker.io/docker/dockerfile:1
2+
3+
FROM node:18-alpine AS base
4+
5+
# Install dependencies only when needed
6+
FROM base AS deps
7+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
8+
RUN apk add --no-cache libc6-compat
9+
WORKDIR /app
10+
11+
# Install dependencies based on the preferred package manager
12+
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
13+
RUN \
14+
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
15+
elif [ -f package-lock.json ]; then npm ci; \
16+
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
17+
else echo "Lockfile not found." && exit 1; \
18+
fi
19+
20+
21+
# Rebuild the source code only when needed
22+
FROM base AS builder
23+
WORKDIR /app
24+
COPY --from=deps /app/node_modules ./node_modules
25+
COPY . .
26+
27+
# Next.js collects completely anonymous telemetry data about general usage.
28+
# Learn more here: https://nextjs.org/telemetry
29+
# Uncomment the following line in case you want to disable telemetry during the build.
30+
ENV NEXT_TELEMETRY_DISABLED=1
31+
32+
RUN \
33+
if [ -f yarn.lock ]; then yarn prisma generate && yarn run build; \
34+
elif [ -f package-lock.json ]; then npx prisma generate && npm run build; \
35+
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpx prisma generate && pnpm run build; \
36+
else echo "Lockfile not found." && exit 1; \
37+
fi
38+
39+
# Production image, copy all the files and run next
40+
FROM base AS runner
41+
WORKDIR /app
42+
43+
RUN ls -al
44+
45+
RUN corepack enable pnpm
46+
47+
ENV NODE_ENV=production
48+
# Uncomment the following line in case you want to disable telemetry during runtime.
49+
ENV NEXT_TELEMETRY_DISABLED=1
50+
51+
ARG FOLDER_DATA
52+
ENV FOLDER_DATA=${FOLDER_DATA}
53+
54+
RUN addgroup --system --gid 1001 nodejs
55+
RUN adduser --system --uid 1001 nextjs
56+
57+
COPY --from=builder /app/public ./public
58+
59+
# Automatically leverage output traces to reduce image size
60+
# https://nextjs.org/docs/advanced-features/output-file-tracing
61+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
62+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
63+
64+
RUN mkdir -p /app/${FOLDER_DATA} && chown nextjs:nodejs /app/${FOLDER_DATA}
65+
66+
USER nextjs
67+
68+
EXPOSE 3000
69+
70+
ENV PORT=3000
71+
72+
# server.js is created by next build from the standalone output
73+
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
74+
ENV HOSTNAME="0.0.0.0"
75+
CMD ["sh", "-c", "pnpx prisma migrate deploy && pnpx prisma db seed && node server.js"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nathan Abitbol
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# Collab - Next.js & Prisma SaaS Starter
2+
3+
![GitHub Banner](public/image/github.jpg)
4+
5+
This project is a [Next.js](https://nextjs.org) application initialized with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app) and using [Prisma](https://www.prisma.io/) for database management. It also integrates [shadcn](https://ui.shadcn.com/) for UI components and [Better Auth](https://betterauth.dev/) for authentication.
6+
7+
## Project Overview
8+
9+
This project aims to provide a SaaS platform with workspace creation, enabling a file manager system. Future features will include chat functionality and a calendar system to enhance collaboration within workspaces.
10+
11+
## Prerequisites
12+
13+
Before starting, make sure you have the following tools installed on your machine:
14+
- [Node.js](https://nodejs.org/)
15+
- [PostgreSQL](https://www.postgresql.org/) or another database supported by Prisma
16+
- [Prisma CLI](https://www.prisma.io/docs/concepts/components/prisma-cli)
17+
- [Docker](https://www.docker.com/) & [Docker Compose](https://docs.docker.com/compose/)
18+
19+
## Installation
20+
21+
Clone the repository and install dependencies:
22+
23+
```bash
24+
pnpm install
25+
# or
26+
npm install
27+
# or
28+
yarn install
29+
```
30+
31+
## Configuration
32+
33+
Copy the `.env.example` file to `.env` and configure the environment variables:
34+
35+
```bash
36+
DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE"
37+
FOLDER_DATA=data
38+
BETTER_AUTH_SECRET=..... # openssl rand -base64 32
39+
GROQ_API_KEY=.......
40+
```
41+
42+
## Prisma
43+
44+
Generate the Prisma client and apply migrations:
45+
46+
```bash
47+
npx prisma generate
48+
npx prisma migrate dev --name init
49+
```
50+
51+
### Important: Run Database Seeding Before Starting the Project
52+
53+
Before running the development server, make sure to seed the database with initial data:
54+
55+
```bash
56+
npx prisma db seed
57+
```
58+
59+
If you need to reset the database and apply the seeders again:
60+
61+
```bash
62+
npx prisma migrate reset
63+
npx prisma db seed
64+
```
65+
66+
## Start the Development Server
67+
68+
```bash
69+
npm run dev
70+
# or
71+
yarn dev
72+
# or
73+
pnpm dev
74+
# or
75+
bun dev
76+
```
77+
78+
Open [http://localhost:3000](http://localhost:3000) in your browser to see the result.
79+
80+
## Database Seeding
81+
82+
The project includes a seed script to populate the database with test data. Modify the `src/lib/prisma/seeds/seed.ts` file as needed.
83+
84+
Run the seed script:
85+
86+
```bash
87+
npx prisma db seed
88+
```
89+
90+
## Docker Setup for Production
91+
92+
To run the project in a production environment using Docker, use the provided `docker-compose.yml` file.
93+
94+
### Start the Containers
95+
96+
```bash
97+
docker-compose up -d --build
98+
```
99+
100+
### Stop the Containers
101+
102+
```bash
103+
docker-compose down
104+
```
105+
106+
### Docker Compose Configuration for Production
107+
108+
Below is the `docker-compose.yml` configuration used for running the application in production:
109+
110+
```yaml
111+
services:
112+
db:
113+
image: postgres:15.6
114+
container_name: collab-nextjs-db
115+
ports:
116+
- "5432:5432"
117+
environment:
118+
- POSTGRES_DB=collab
119+
- POSTGRES_USER=collab
120+
- POSTGRES_PASSWORD=collab
121+
volumes:
122+
- collab_nextjs_db:/var/lib/postgresql/data
123+
124+
app:
125+
container_name: collab-nextjs
126+
build:
127+
context: .
128+
dockerfile: Dockerfile
129+
args:
130+
- FOLDER_DATA
131+
environment:
132+
- DATABASE_URL=postgresql://collab:collab@db:5432/collab?schema=public
133+
restart: unless-stopped
134+
ports:
135+
- "3000:3000"
136+
depends_on:
137+
- db
138+
volumes:
139+
- collab_nextjs_data:/app/${FOLDER_DATA}
140+
141+
volumes:
142+
collab_nextjs_db:
143+
collab_nextjs_data:
144+
```
145+
146+
### Note on Dockerfile
147+
148+
This project uses `pnpm` as the package manager in the Dockerfile. If you prefer to use `npm` or `yarn`, make sure to update the Dockerfile accordingly to replace `pnpm` commands with the package manager of your choice.
149+
150+
## Documentation
151+
152+
- [Next.js Documentation](https://nextjs.org/docs)
153+
- [Prisma Documentation](https://www.prisma.io/docs/)
154+
- [Docker Documentation](https://docs.docker.com/)
155+
- [Learn Next.js](https://nextjs.org/learn)
156+
157+
## Deployment
158+
159+
The easiest way to deploy your application is by using [Vercel](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme).
160+
161+
Check out the [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
162+
163+
---
164+
165+
Happy coding! 🚀
166+

components.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "src/styles/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils",
16+
"ui": "@/components/ui",
17+
"lib": "@/lib",
18+
"hooks": "@/hooks"
19+
},
20+
"iconLibrary": "lucide"
21+
}

docker-compose.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
services:
2+
db:
3+
image: postgres:15.6
4+
container_name: collab-nextjs-db
5+
ports:
6+
- "5432:5432"
7+
environment:
8+
- POSTGRES_DB=collab
9+
- POSTGRES_USER=collab
10+
- POSTGRES_PASSWORD=collab
11+
volumes:
12+
- collab_nextjs_db:/var/lib/postgresql/data
13+
14+
app:
15+
container_name: collab-nextjs
16+
build:
17+
context: .
18+
dockerfile: Dockerfile
19+
args:
20+
- FOLDER_DATA
21+
environment:
22+
- DATABASE_URL=postgresql://collab:collab@db:5432/collab?schema=public
23+
restart: unless-stopped
24+
ports:
25+
- "3000:3000"
26+
depends_on:
27+
- db
28+
volumes:
29+
- collab_nextjs_data:/app/${FOLDER_DATA}
30+
31+
volumes:
32+
collab_nextjs_db:
33+
collab_nextjs_data:

0 commit comments

Comments
 (0)