Skip to content

Commit 34bd376

Browse files
authored
Merge pull request #64 from MicroPyramid/dev
Dev
2 parents b2d339e + b6d3667 commit 34bd376

File tree

23 files changed

+5452
-414
lines changed

23 files changed

+5452
-414
lines changed

.env.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
GOOGLE_CLIENT_ID="your-google-client-id-here"
2+
GOOGLE_CLIENT_SECRET="your-google-client-secret-here"
3+
GOOGLE_LOGIN_DOMAIN="http://localhost:5173"
4+
DATABASE_URL="postgresql://username:password@localhost:5432/bottlecrm?schema=public"
5+
6+
# API Configuration
7+
API_PORT=3001
8+
JWT_SECRET=your-super-secure-jwt-secret-key-change-this-in-production
9+
JWT_EXPIRES_IN=24h
10+
FRONTEND_URL=http://localhost:5173
11+
12+
# Logging Configuration
13+
ENABLE_REQUEST_LOGGING=true
14+
LOG_REQUEST_BODY=false
15+
LOG_RESPONSE_BODY=false
16+
17+
# Environment
18+
NODE_ENV=development

CLAUDE.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
BottleCRM is a SaaS CRM platform built with SvelteKit, designed for startups and enterprises with role-based access control (RBAC). The application features multi-tenancy through organizations, with strict data isolation enforced at the database level.
8+
9+
## Technology Stack
10+
11+
- **Frontend**: SvelteKit 2.x with Svelte 5.x
12+
- **Styling**: TailwindCSS 4.x
13+
- **Database**: PostgreSQL with Prisma ORM
14+
- **Icons**: Lucide Svelte
15+
- **Validation**: Zod
16+
- **Package Manager**: pnpm
17+
18+
## Development Commands
19+
20+
```bash
21+
# Development server
22+
pnpm run dev
23+
24+
# Build for production
25+
pnpm run build
26+
27+
# Preview production build
28+
pnpm run preview
29+
30+
# Type checking
31+
pnpm run check
32+
33+
# Type checking with watch mode
34+
pnpm run check:watch
35+
36+
# Linting and formatting (both required to pass)
37+
pnpm run lint
38+
39+
# Format code
40+
pnpm run format
41+
42+
# Database operations
43+
npx prisma migrate dev
44+
npx prisma generate
45+
npx prisma studio
46+
```
47+
48+
## Architecture Overview
49+
50+
### Multi-Tenant Structure
51+
- **Organizations**: Top-level tenant containers with strict data isolation
52+
- **Users**: Can belong to multiple organizations with different roles (ADMIN/USER)
53+
- **Super Admin**: Users with @micropyramid.com email domain have platform-wide access
54+
55+
### Core CRM Entities
56+
- **Leads**: Initial prospects that can be converted to Accounts/Contacts/Opportunities
57+
- **Accounts**: Company/organization records
58+
- **Contacts**: Individual people associated with accounts
59+
- **Opportunities**: Sales deals with pipeline stages
60+
- **Tasks/Events**: Activity management
61+
- **Cases**: Customer support tickets
62+
- **Products/Quotes**: Sales catalog and quotation system
63+
64+
### Authentication & Authorization
65+
- Session-based authentication using cookies (`session`, `org`, `org_name`)
66+
- Organization selection required after login via `/org` route
67+
- Route protection in `src/hooks.server.js`:
68+
- `/app/*` routes require authentication and organization membership
69+
- `/admin/*` routes restricted to @micropyramid.com domain users
70+
- `/org` route for organization selection
71+
72+
### Data Access Control
73+
- All database queries must include organization filtering
74+
- User can only access data from organizations they belong to
75+
- Prisma schema enforces relationships with `organizationId` foreign keys
76+
77+
### Route Structure
78+
- `(site)`: Public marketing pages
79+
- `(no-layout)`: Auth pages (login, org selection)
80+
- `(app)`: Main CRM application (requires auth + org membership)
81+
- `(admin)`: Platform administration (requires @micropyramid.com email)
82+
83+
### Key Files
84+
- `src/hooks.server.js`: Authentication, org membership validation, route protection
85+
- `src/lib/prisma.js`: Database client configuration
86+
- `src/lib/stores/auth.js`: Authentication state management
87+
- `prisma/schema.prisma`: Complete database schema with RBAC models
88+
89+
## Form Development
90+
- All form labels must be properly associated with form controls for accessibility
91+
- Use Zod for form validation
92+
- Follow existing patterns in `/contacts`, `/leads`, `/accounts` for consistency
93+
94+
## Security Requirements
95+
- Never expose cross-organization data
96+
- Always filter queries by user's organization membership
97+
- Validate user permissions before any data operations
98+
- Use parameterized queries via Prisma to prevent SQL injection

ENV.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 147 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,205 @@
11
# BottleCRM: Free and Open Source Customer Relationship Management
22

33
<div align="center">
4-
<h3>Powerful, Modern CRM for Everyone</h3>
4+
<h3>Powerful, Modern Multi-Tenant CRM for Everyone</h3>
55
</div>
66

7-
BottleCRM is a free, open-source Customer Relationship Management solution designed to help small and medium businesses effectively manage their customer relationships. Built with modern technologies, it offers a comprehensive set of features without the enterprise price tag.
7+
BottleCRM is a free, open-source Customer Relationship Management solution designed to help small and medium businesses effectively manage their customer relationships. Built with modern technologies and enterprise-grade multi-tenancy, it offers a comprehensive set of features without the enterprise price tag.
88

9-
## 🚀 Features
9+
## ✨ Key Highlights
1010

11+
- **Multi-Tenant Architecture**: Secure organization-based data isolation
12+
- **Role-Based Access Control**: Granular permissions for users and admins
13+
- **Modern Technology Stack**: Built with SvelteKit 2.x, Svelte 5.x, and PostgreSQL
14+
- **Mobile-First Design**: Responsive interface optimized for all devices
15+
16+
## 🚀 Core Features
17+
18+
### Sales & Lead Management
1119
- **Lead Management**: Track and nurture leads from initial contact to conversion
1220
- **Account Management**: Maintain detailed records of customer accounts and organizations
1321
- **Contact Management**: Store and organize all your customer contact information
22+
- **Opportunity Management**: Track deals through your sales pipeline with customizable stages
23+
24+
### Customer Support
1425
- **Case Management**: Handle customer support cases and track resolution
26+
- **Solution Knowledge Base**: Maintain searchable solutions for common issues
27+
- **Multi-Channel Support**: Handle cases from various origins (email, web, phone)
28+
29+
### Productivity & Collaboration
1530
- **Task Management**: Never miss a follow-up with built-in task tracking
16-
- **Opportunity Management**: Track deals through your sales pipeline
17-
- **Mobile Friendly**: Access your CRM data on any device
18-
- **Modern UI**: Clean, intuitive interface built with Svelte and TailwindCSS
31+
- **Event Management**: Schedule and manage meetings and activities
32+
- **Board Management**: Trello-like kanban boards for project tracking
33+
- **Comment System**: Collaborate with team members on records
34+
35+
### Sales Tools
36+
- **Quote Management**: Generate professional quotes with line items
37+
- **Product Catalog**: Maintain product inventory with pricing
38+
- **Sales Pipeline**: Visual opportunity tracking with probability scoring
39+
40+
### Administrative Features
41+
- **User Management**: Add team members with appropriate role assignments
42+
- **Organization Management**: Multi-tenant structure with data isolation
43+
- **Audit Logging**: Complete activity tracking for compliance
44+
- **Super Admin Panel**: Platform-wide management for system administrators
1945

2046
## 🔮 Coming Soon
2147

2248
- **Invoice Management**: Create, send, and track invoices (in development)
2349
- **Email Integration**: Connect your email accounts for seamless communication
2450
- **Analytics Dashboard**: Make data-driven decisions with powerful reporting tools
51+
- **API Integration**: REST API for third-party integrations
2552

26-
## 🖥️ Technologies
53+
## 🖥️ Technology Stack
2754

28-
- **Frontend**: SvelteKit, Flowbite-Svelte, TailwindCSS
29-
- **Backend**: Prisma ORM with your choice of database
30-
- **Authentication**: Built-in authentication system
55+
- **Frontend**: SvelteKit 2.x, Svelte 5.x, TailwindCSS 4.x
56+
- **Backend**: Node.js with Prisma ORM
57+
- **Database**: PostgreSQL (recommended) with multi-tenant schema
58+
- **Authentication**: Session-based authentication with organization membership
59+
- **Icons**: Lucide Svelte icon library
60+
- **Validation**: Zod for type-safe form validation
3161

3262
## 🚀 Getting Started
3363

3464
### Prerequisites
3565

36-
- Node.js (v20 or newer)
37-
- npm, pnpm, or yarn package manager
38-
- A database (PostgreSQL recommended)
66+
- **Node.js**: v22.13.0 (use nvm for version management)
67+
- **Package Manager**: pnpm (recommended)
68+
- **Database**: PostgreSQL (required for multi-tenancy features)
3969

4070
### Installation
4171

42-
1. Clone the repository:
72+
1. **Clone the repository:**
4373
```bash
4474
git clone https://github.com/micropyramid/svelte-crm.git
4575
cd svelte-crm
4676
```
4777

48-
2. Install dependencies:
78+
2. **Set up Node.js version:**
79+
```bash
80+
nvm use 22.13.0
81+
```
82+
83+
3. **Install dependencies:**
4984
```bash
5085
pnpm install
5186
```
5287

53-
3. Configure your environment variables (see `.env.example`)
88+
4. **Configure environment variables:**
89+
Create a `.env` file based on the following template:
90+
```env
91+
# Database Configuration
92+
DATABASE_URL="postgresql://postgres:password@localhost:5432/bottlecrm?schema=public"
5493
55-
4. Run database migrations:
94+
# Google OAuth (Optional)
95+
GOOGLE_CLIENT_ID=""
96+
GOOGLE_CLIENT_SECRET=""
97+
GOOGLE_LOGIN_DOMAIN="http://localhost:5173"
98+
```
99+
100+
5. **Set up the database:**
56101
```bash
102+
# Generate Prisma client
103+
npx prisma generate
104+
105+
# Run database migrations
57106
npx prisma migrate dev
107+
108+
# (Optional) Open Prisma Studio to view data
109+
npx prisma studio
58110
```
59111

60-
5. Start the development server:
112+
6. **Start the development server:**
61113
```bash
62114
pnpm run dev
63115
```
64116

117+
### Development Workflow
118+
119+
Before committing code, ensure quality checks pass:
120+
121+
```bash
122+
# Type checking
123+
pnpm run check
124+
125+
# Linting and formatting
126+
pnpm run lint
127+
128+
# Build verification
129+
pnpm run build
130+
```
131+
132+
### Production Deployment
133+
134+
```bash
135+
# Set Node.js version
136+
nvm use 22.13.0
137+
138+
# Generate Prisma client
139+
npx prisma generate
140+
141+
# Run production migrations
142+
npx prisma migrate deploy
143+
144+
# Build application
145+
pnpm run build
146+
147+
# Start production server
148+
pnpm run preview
149+
```
150+
151+
## 🏗️ Architecture & Security
152+
153+
### Multi-Tenant Design
154+
- **Organization Isolation**: Complete data separation between organizations
155+
- **Role-Based Access**: Users can have different roles across organizations
156+
- **Session Management**: Secure cookie-based authentication with organization context
157+
158+
### User Roles
159+
- **User**: Standard access to organization data
160+
- **Admin**: Organization-level administrative privileges
161+
- **Super Admin**: Platform-wide access (requires @micropyramid.com email)
162+
163+
### Data Security
164+
- All database queries are organization-scoped
165+
- Strict permission validation on all routes
166+
- Audit logging for compliance and tracking
167+
168+
## 📁 Project Structure
169+
170+
```
171+
src/
172+
├── routes/
173+
│ ├── (site)/ # Public marketing pages
174+
│ ├── (no-layout)/ # Authentication pages
175+
│ ├── (app)/ # Main CRM application
176+
│ └── (admin)/ # Super admin panel
177+
├── lib/
178+
│ ├── stores/ # Svelte stores for state management
179+
│ ├── data/ # Static data and configurations
180+
│ └── utils/ # Utility functions
181+
└── hooks.server.js # Authentication and route protection
182+
```
183+
65184
## 💬 Community and Feedback
66185

67186
We love to hear from our users! Please share your feedback, report bugs, or suggest new features:
68187

69-
- Open an issue on GitHub
70-
- Join our community forum
71-
- Contribute code via pull requests
188+
- **Issues**: Open an issue on GitHub for bugs and feature requests
189+
- **Discussions**: Join community discussions for general questions
190+
- **Pull Requests**: Contribute code improvements and new features
72191

73192
## 🤝 Contributing
74193

75194
We welcome contributions of all kinds! See our [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to get started.
76195

196+
### Development Guidelines
197+
- Follow existing code patterns and conventions
198+
- Ensure all forms have proper accessibility (labels associated with controls)
199+
- Never use `$app` imports from SvelteKit (see packaging best practices)
200+
- Always filter database queries by organization membership
201+
- Add appropriate error handling and validation
202+
77203
## 📄 License
78204

79205
BottleCRM is open source software [licensed as MIT](LICENSE).

0 commit comments

Comments
 (0)