Skip to content

Commit 3f18547

Browse files
committed
chore: prepare codebase for github
0 parents  commit 3f18547

77 files changed

Lines changed: 16578 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug Report
3+
about: Create a report to help us improve
4+
title: ""
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1.
16+
2.
17+
3.
18+
19+
**Expected behavior**
20+
A clear and concise description of what you expected to happen.
21+
22+
**Environment:**
23+
24+
- OS: [e.g. macOS, Linux]
25+
- Node version: [e.g. 18.0.0]
26+
- Service: [e.g. auth, chat]
27+
28+
**Additional context**
29+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for this project
4+
title: ""
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is.
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Description
2+
3+
Brief description of changes
4+
5+
## Type of Change
6+
7+
- [ ] Bug fix
8+
- [ ] New feature
9+
- [ ] Breaking change
10+
- [ ] Documentation update
11+
12+
## Checklist
13+
14+
- [ ] Code follows project style guidelines
15+
- [ ] Self-review completed
16+
- [ ] Comments added for complex logic
17+
- [ ] Documentation updated
18+
- [ ] No new warnings generated
19+
- [ ] Tests added/updated (if applicable)

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
jobs:
10+
lint-and-typecheck:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: "18"
20+
cache: "yarn"
21+
22+
- name: Install dependencies
23+
run: yarn install --frozen-lockfile
24+
25+
- name: Type check
26+
run: yarn workspace @collab/prisma prisma:generate && npx tsc --noEmit
27+
28+
- name: Check for secrets
29+
run: |
30+
if grep -r "supersecretlocal\|refreshsecret" --include="*.ts" --include="*.js" services/ libs/; then
31+
echo "⚠️ Warning: Default secrets found in code. Ensure these are only fallbacks."
32+
fi

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp
4+
.pnp.js
5+
6+
# Build outputs
7+
dist/
8+
build/
9+
*.tsbuildinfo
10+
.turbo/
11+
12+
# Environment variables
13+
.env
14+
.env.local
15+
.env.*.local
16+
*.env
17+
18+
# Logs
19+
logs/
20+
*.log
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
lerna-debug.log*
25+
.pnpm-debug.log*
26+
27+
# OS files
28+
.DS_Store
29+
.DS_Store?
30+
._*
31+
.Spotlight-V100
32+
.Trashes
33+
ehthumbs.db
34+
Thumbs.db
35+
*.swp
36+
*.swo
37+
*~
38+
39+
# IDE
40+
.vscode/
41+
.idea/
42+
*.sublime-project
43+
*.sublime-workspace
44+
*.code-workspace
45+
46+
# Prisma generated files (if not committed)
47+
# Uncomment if you want to ignore generated Prisma client
48+
# libs/prisma/generated/
49+
# services/*/src/generated/
50+
51+
# Testing
52+
coverage/
53+
.nyc_output/
54+
*.lcov
55+
56+
# Temporary files
57+
tmp/
58+
temp/
59+
*.tmp
60+
61+
# Lock files (optional - some teams commit these)
62+
# Uncomment if you don't want to commit lock files
63+
# package-lock.json
64+
# yarn.lock
65+
# pnpm-lock.yaml

PRE_PUSH_CHECKLIST.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Pre-Push Checklist
2+
3+
Before pushing to GitHub, ensure the following:
4+
5+
## ✅ Security Checks
6+
7+
- [ ] No `.env` files are committed (check with `git ls-files | grep .env`)
8+
- [ ] No hardcoded secrets in code (only fallback defaults for local dev)
9+
- [ ] No API keys or credentials in code
10+
- [ ] Database URLs use environment variables
11+
- [ ] All sensitive configs use `process.env` with fallbacks only for local dev
12+
13+
## ✅ Code Quality
14+
15+
- [ ] TypeScript compiles without errors (`npx tsc --noEmit`)
16+
- [ ] No console.log statements in production code
17+
- [ ] No TODO/FIXME comments without issue references
18+
- [ ] Code follows project style guidelines
19+
20+
## ✅ Files & Directories
21+
22+
- [ ] `node_modules/` is in `.gitignore`
23+
- [ ] `dist/` and `build/` directories are ignored
24+
- [ ] `.DS_Store` and other OS files are ignored
25+
- [ ] Log files are ignored
26+
- [ ] Generated Prisma files are handled correctly
27+
28+
## ✅ Documentation
29+
30+
- [ ] README.md is up to date
31+
- [ ] API endpoints are documented
32+
- [ ] Environment variables are documented
33+
- [ ] Setup instructions are clear
34+
35+
## ✅ Git
36+
37+
- [ ] Meaningful commit messages
38+
- [ ] No large files (>100MB)
39+
- [ ] No merge conflicts
40+
- [ ] Branch is up to date with main/develop
41+
42+
## Quick Commands
43+
44+
```bash
45+
# Check for secrets
46+
grep -r "supersecretlocal\|refreshsecret" --include="*.ts" --include="*.js" services/ libs/
47+
48+
# Check for .env files
49+
git ls-files | grep .env
50+
51+
# Type check
52+
npx tsc --noEmit
53+
54+
# Check git status
55+
git status
56+
57+
# Verify .gitignore is working
58+
git check-ignore -v libs/prisma/.env
59+
```

README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Collab Platform
2+
3+
A microservices-based collaboration platform with real-time chat, authentication, and workspace management.
4+
5+
## Architecture
6+
7+
This is a monorepo containing multiple services and shared libraries:
8+
9+
### Services
10+
11+
- **auth** - Authentication service (Fastify + Prisma + PostgreSQL)
12+
- **chat** - Real-time chat service (Fastify + WebSocket + RabbitMQ + Redis)
13+
- **storage** - File storage service
14+
- **analytics** - Analytics service
15+
16+
### Libraries
17+
18+
- **@collab/prisma** - Shared Prisma client with database models
19+
- **@collab/plugins** - Shared plugins (Prometheus metrics)
20+
- **@collab/events** - Event envelope types
21+
- **@collab/types** - Shared TypeScript types
22+
- **@collab/redis-utils** - Redis utilities and key helpers
23+
24+
## Tech Stack
25+
26+
- **Runtime**: Node.js
27+
- **Framework**: Fastify
28+
- **Database**: PostgreSQL (via Prisma)
29+
- **Message Queue**: RabbitMQ
30+
- **Cache**: Redis
31+
- **Metrics**: Prometheus
32+
- **TypeScript**: Full type safety across services
33+
- **Monorepo**: Yarn workspaces
34+
35+
## Getting Started
36+
37+
### Prerequisites
38+
39+
- Node.js 18+
40+
- Docker & Docker Compose
41+
- PostgreSQL
42+
- Redis
43+
- RabbitMQ
44+
45+
### Installation
46+
47+
```bash
48+
# Install dependencies
49+
yarn install
50+
51+
# Generate Prisma clients
52+
yarn workspace @collab/prisma prisma:generate
53+
54+
# Start infrastructure (PostgreSQL, Redis, RabbitMQ)
55+
docker-compose -f infra/docker/docker-compose.yml up -d
56+
57+
# Set up environment variables
58+
cp .env.example .env
59+
# Edit .env with your configuration
60+
61+
# Run migrations
62+
yarn workspace @collab/prisma prisma:migrate dev
63+
```
64+
65+
### Development
66+
67+
```bash
68+
# Run auth service
69+
yarn workspace auth dev
70+
71+
# Run chat service
72+
yarn workspace chat dev
73+
```
74+
75+
### Environment Variables
76+
77+
Each service requires specific environment variables. See `.env.example` files in each service directory.
78+
79+
**Common variables:**
80+
81+
- `DATABASE_URL` - PostgreSQL connection string
82+
- `REDIS_URL` - Redis connection string
83+
- `RABBITMQ_URL` - RabbitMQ connection string
84+
- `JWT_SECRET` - Secret for JWT token signing
85+
- `REFRESH_SECRET` - Secret for refresh tokens
86+
87+
## Features
88+
89+
### Authentication Service
90+
91+
- User registration and login
92+
- JWT-based authentication
93+
- Refresh token rotation
94+
- Rate limiting
95+
- Prometheus metrics
96+
97+
### Chat Service
98+
99+
- Real-time WebSocket messaging
100+
- Channel-based chat
101+
- Message replay on reconnect
102+
- Typing indicators
103+
- Read receipts
104+
- RabbitMQ message distribution
105+
- Redis offset tracking
106+
107+
## Project Structure
108+
109+
```
110+
collab-platform/
111+
├── libs/ # Shared libraries
112+
│ ├── prisma/ # Database client and schemas
113+
│ ├── plugins/ # Fastify plugins (metrics)
114+
│ ├── events/ # Event types
115+
│ ├── types/ # TypeScript types
116+
│ └── redis-utils/ # Redis utilities
117+
├── services/ # Microservices
118+
│ ├── auth/ # Authentication service
119+
│ ├── chat/ # Chat service
120+
│ ├── storage/ # Storage service
121+
│ └── analytics/ # Analytics service
122+
├── infra/ # Infrastructure configs
123+
│ └── docker/ # Docker compose and configs
124+
└── tsconfig/ # TypeScript configurations
125+
```
126+
127+
## Metrics
128+
129+
All services expose Prometheus metrics at `/metrics`:
130+
131+
- HTTP request duration and counts
132+
- WebSocket connection metrics
133+
- RabbitMQ message metrics
134+
- Database query metrics
135+
- Authentication metrics
136+
- Custom business metrics
137+
138+
## API Documentation
139+
140+
### Auth Service (`/auth`)
141+
142+
- `POST /register` - Register new user
143+
- `POST /login` - User login
144+
- `POST /refresh` - Refresh access token
145+
- `POST /logout` - Logout user
146+
- `GET /me` - Get current user
147+
- `GET /health` - Health check
148+
- `GET /metrics` - Prometheus metrics
149+
150+
### Chat Service (`/chat`)
151+
152+
- `GET /ws` - WebSocket connection endpoint
153+
- `GET /channels/:id/messages` - Get channel messages
154+
- `GET /health` - Health check
155+
- `GET /metrics` - Prometheus metrics
156+
157+
## Development Guidelines
158+
159+
1. **Type Safety**: All code is TypeScript with strict mode enabled
160+
2. **Code Style**: Follow existing patterns and use ESLint
161+
3. **Testing**: Write tests for new features
162+
4. **Documentation**: Update README and add JSDoc comments
163+
5. **Commits**: Use conventional commit messages
164+
165+
## License
166+
167+
MIT

0 commit comments

Comments
 (0)