Skip to content

Commit 13ed0da

Browse files
committed
inital support for collabrative docs platform
0 parents  commit 13ed0da

File tree

178 files changed

+34731
-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.

178 files changed

+34731
-0
lines changed

.dockerignore

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Dependencies
2+
node_modules
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Next.js
8+
.next
9+
out
10+
dist
11+
12+
# Environment files
13+
.env
14+
.env.local
15+
.env.production.local
16+
.env.development.local
17+
.env.test.local
18+
19+
# IDE
20+
.vscode
21+
.idea
22+
*.swp
23+
*.swo
24+
*~
25+
.DS_Store
26+
27+
# Testing
28+
coverage
29+
.nyc_output
30+
31+
# Git
32+
.git
33+
.gitignore
34+
35+
# Documentation
36+
README.md
37+
CLAUDE.md
38+
AUTH_SETUP.md
39+
FEATURES.md
40+
docs
41+
42+
# Docker
43+
Dockerfile
44+
docker-compose*.yml
45+
.dockerignore
46+
47+
# CI/CD
48+
.github
49+
.gitlab-ci.yml
50+
.circleci
51+
52+
# Development
53+
.eslintrc.json
54+
.prettierrc
55+
jest.config.js
56+
cypress
57+
cypress.json
58+
59+
# Logs
60+
logs
61+
*.log
62+
63+
# OS files
64+
Thumbs.db
65+
66+
# Temporary files
67+
tmp
68+
temp
69+
.tmp

.env.example

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Database
2+
DATABASE_URL="postgresql://postgres:password@localhost:5432/snapdocs"
3+
MONGODB_URI="mongodb://localhost:27017/snapdocs"
4+
5+
# Redis
6+
REDIS_URL="redis://localhost:6379"
7+
8+
# NextAuth
9+
NEXTAUTH_URL="http://localhost:3000"
10+
NEXTAUTH_SECRET="your-secret-key-change-this-in-production"
11+
12+
# File Storage (MinIO or S3)
13+
S3_ENDPOINT="http://localhost:9000"
14+
S3_ACCESS_KEY="minioadmin"
15+
S3_SECRET_KEY="minioadmin"
16+
S3_BUCKET="snapdocs"
17+
S3_REGION="us-east-1"
18+
19+
# Socket.io for real-time
20+
NEXT_PUBLIC_SOCKET_URL="http://localhost:3000"
21+
22+
# App Configuration
23+
NEXT_PUBLIC_APP_URL="http://localhost:3000"

.github/dependabot.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "04:00"
10+
open-pull-requests-limit: 10
11+
reviewers:
12+
- "nevil"
13+
labels:
14+
- "dependencies"
15+
- "npm"
16+
commit-message:
17+
prefix: "chore"
18+
include: "scope"
19+
20+
# Enable version updates for Docker
21+
- package-ecosystem: "docker"
22+
directory: "/"
23+
schedule:
24+
interval: "weekly"
25+
day: "monday"
26+
time: "04:00"
27+
open-pull-requests-limit: 5
28+
reviewers:
29+
- "nevil"
30+
labels:
31+
- "dependencies"
32+
- "docker"
33+
commit-message:
34+
prefix: "chore"
35+
include: "scope"
36+
37+
# Enable version updates for GitHub Actions
38+
- package-ecosystem: "github-actions"
39+
directory: "/"
40+
schedule:
41+
interval: "weekly"
42+
day: "monday"
43+
time: "04:00"
44+
open-pull-requests-limit: 5
45+
reviewers:
46+
- "nevil"
47+
labels:
48+
- "dependencies"
49+
- "github-actions"
50+
commit-message:
51+
prefix: "chore"
52+
include: "scope"

.github/workflows/ci.yml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
NODE_VERSION: '20'
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
# Code Quality Checks
16+
quality:
17+
name: Code Quality
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ env.NODE_VERSION }}
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run linter
33+
run: npm run lint
34+
35+
- name: Run type check
36+
run: npm run typecheck
37+
38+
- name: Run format check
39+
run: npm run format:check || true
40+
41+
# Security Scanning
42+
security:
43+
name: Security Scan
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
49+
- name: Run Trivy vulnerability scanner
50+
uses: aquasecurity/trivy-action@master
51+
with:
52+
scan-type: 'fs'
53+
scan-ref: '.'
54+
format: 'sarif'
55+
output: 'trivy-results.sarif'
56+
57+
- name: Upload Trivy results to GitHub Security
58+
uses: github/codeql-action/upload-sarif@v3
59+
if: always()
60+
with:
61+
sarif_file: 'trivy-results.sarif'
62+
63+
# Unit Tests
64+
test:
65+
name: Unit Tests
66+
runs-on: ubuntu-latest
67+
services:
68+
postgres:
69+
image: postgres:16-alpine
70+
env:
71+
POSTGRES_USER: postgres
72+
POSTGRES_PASSWORD: testpassword
73+
POSTGRES_DB: snapdocs_test
74+
options: >-
75+
--health-cmd pg_isready
76+
--health-interval 10s
77+
--health-timeout 5s
78+
--health-retries 5
79+
ports:
80+
- 5432:5432
81+
82+
mongodb:
83+
image: mongo:7.0
84+
env:
85+
MONGO_INITDB_ROOT_USERNAME: admin
86+
MONGO_INITDB_ROOT_PASSWORD: testpassword
87+
MONGO_INITDB_DATABASE: snapdocs_test
88+
options: >-
89+
--health-cmd "echo 'db.runCommand(\"ping\").ok' | mongosh localhost:27017/test --quiet"
90+
--health-interval 10s
91+
--health-timeout 5s
92+
--health-retries 5
93+
ports:
94+
- 27017:27017
95+
96+
redis:
97+
image: redis:7-alpine
98+
options: >-
99+
--health-cmd "redis-cli ping"
100+
--health-interval 10s
101+
--health-timeout 5s
102+
--health-retries 5
103+
ports:
104+
- 6379:6379
105+
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v4
109+
110+
- name: Setup Node.js
111+
uses: actions/setup-node@v4
112+
with:
113+
node-version: ${{ env.NODE_VERSION }}
114+
cache: 'npm'
115+
116+
- name: Install dependencies
117+
run: npm ci
118+
119+
- name: Setup test environment
120+
run: |
121+
cp .env.example .env.test
122+
echo "DATABASE_URL=postgresql://postgres:testpassword@localhost:5432/snapdocs_test" >> .env.test
123+
echo "MONGODB_URI=mongodb://admin:testpassword@localhost:27017/snapdocs_test?authSource=admin" >> .env.test
124+
echo "REDIS_URL=redis://localhost:6379" >> .env.test
125+
126+
- name: Run Prisma migrations
127+
run: npx prisma migrate deploy
128+
env:
129+
DATABASE_URL: postgresql://postgres:testpassword@localhost:5432/snapdocs_test
130+
131+
- name: Run tests
132+
run: npm test -- --passWithNoTests
133+
env:
134+
NODE_ENV: test
135+
DATABASE_URL: postgresql://postgres:testpassword@localhost:5432/snapdocs_test
136+
MONGODB_URI: mongodb://admin:testpassword@localhost:27017/snapdocs_test?authSource=admin
137+
REDIS_URL: redis://localhost:6379
138+
139+
# Build Docker Image
140+
build:
141+
name: Build Docker Image
142+
runs-on: ubuntu-latest
143+
needs: [quality, security, test]
144+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
145+
146+
permissions:
147+
contents: read
148+
packages: write
149+
150+
steps:
151+
- name: Checkout code
152+
uses: actions/checkout@v4
153+
154+
- name: Set up Docker Buildx
155+
uses: docker/setup-buildx-action@v3
156+
157+
- name: Log in to GitHub Container Registry
158+
uses: docker/login-action@v3
159+
with:
160+
registry: ${{ env.REGISTRY }}
161+
username: ${{ github.actor }}
162+
password: ${{ secrets.GITHUB_TOKEN }}
163+
164+
- name: Extract metadata
165+
id: meta
166+
uses: docker/metadata-action@v5
167+
with:
168+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
169+
tags: |
170+
type=ref,event=branch
171+
type=ref,event=pr
172+
type=semver,pattern={{version}}
173+
type=semver,pattern={{major}}.{{minor}}
174+
type=sha,prefix={{branch}}-
175+
type=raw,value=latest,enable={{is_default_branch}}
176+
177+
- name: Build and push Docker image
178+
uses: docker/build-push-action@v5
179+
with:
180+
context: .
181+
platforms: linux/amd64,linux/arm64
182+
push: true
183+
tags: ${{ steps.meta.outputs.tags }}
184+
labels: ${{ steps.meta.outputs.labels }}
185+
cache-from: type=gha
186+
cache-to: type=gha,mode=max
187+
build-args: |
188+
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
189+
190+
# Deploy to Staging
191+
deploy-staging:
192+
name: Deploy to Staging
193+
runs-on: ubuntu-latest
194+
needs: build
195+
if: github.ref == 'refs/heads/develop'
196+
environment:
197+
name: staging
198+
url: https://staging.snapdocs.app
199+
200+
steps:
201+
- name: Checkout code
202+
uses: actions/checkout@v4
203+
204+
- name: Deploy to staging server
205+
run: |
206+
echo "Deploying to staging environment"
207+
# Add your deployment script here
208+
# Example: SSH to server and run docker-compose
209+
# Or trigger webhook to deployment service
210+
211+
# Deploy to Production
212+
deploy-production:
213+
name: Deploy to Production
214+
runs-on: ubuntu-latest
215+
needs: build
216+
if: github.ref == 'refs/heads/main'
217+
environment:
218+
name: production
219+
url: https://snapdocs.app
220+
221+
steps:
222+
- name: Checkout code
223+
uses: actions/checkout@v4
224+
225+
- name: Deploy to production server
226+
run: |
227+
echo "Deploying to production environment"
228+
# Add your deployment script here
229+
# Example: SSH to server and run docker-compose
230+
# Or trigger webhook to deployment service
231+
232+
# Notify on Success
233+
notify-success:
234+
name: Notify Success
235+
runs-on: ubuntu-latest
236+
needs: [deploy-staging, deploy-production]
237+
if: always() && (needs.deploy-staging.result == 'success' || needs.deploy-production.result == 'success')
238+
239+
steps:
240+
- name: Send success notification
241+
run: |
242+
echo "Deployment successful!"
243+
# Add notification logic here (Slack, Discord, email, etc.)

0 commit comments

Comments
 (0)