|
|
4 kuukautta sitten | |
|---|---|---|
| common | 6 kuukautta sitten | |
| config | 6 kuukautta sitten | |
| database | 6 kuukautta sitten | |
| deploy | 6 kuukautta sitten | |
| llm | 6 kuukautta sitten | |
| proto | 6 kuukautta sitten | |
| systemd | 6 kuukautta sitten | |
| tests | 6 kuukautta sitten | |
| webserver | 6 kuukautta sitten | |
| webui | 6 kuukautta sitten | |
| .clang-format | 6 kuukautta sitten | |
| .clang-tidy | 6 kuukautta sitten | |
| .gitignore | 6 kuukautta sitten | |
| CMakeLists.txt | 6 kuukautta sitten | |
| CMakePresets.json | 6 kuukautta sitten | |
| README.md | 4 kuukautta sitten |
A flexible, schema-driven CRM foundation built with C++20 and React.
SmartBotic CRM consists of four main components:
Database Node: An in-memory document database with gRPC interface, supporting collections, JSON documents with metadata, relations, encryption, TTL, and persistent snapshots.
Web Server Node: A REST API server with WebSocket support that communicates with the database via gRPC, handling authentication (JWT + API keys), workspace/user management, and real-time updates.
LLM Service Node: A gRPC service providing AI capabilities with support for multiple LLM providers (OpenAI, Anthropic), session management, and tool execution.
Web UI: A React 19 + TypeScript + Vite + TailwindCSS admin dashboard for managing workspaces, users, collections, and schema-defined views.
# Build tools
sudo apt install cmake ninja-build build-essential pkg-config
# System libraries
sudo apt install libspdlog-dev nlohmann-json3-dev \
libgrpc++-dev libprotobuf-dev protobuf-compiler-grpc \
libwebsockets-dev libssl-dev
# Node.js (via nvm recommended)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 18
npm install -g pnpm
Note: cpp-httplib and jwt-cpp are automatically fetched via CMake FetchContent.
# Clone the repository
git clone https://github.com/fszontagh/smartbotic-crm.git
cd smartbotic-crm
# Configure and build C++ components
cmake --preset release
cmake --build build -j$(nproc)
# Build WebUI
cd webui
pnpm install
pnpm build
cd ..
Open four terminal windows:
Terminal 1 - Database:
./build/database/smartbotic-crm-database --data-dir ./data
Terminal 2 - LLM Service (optional):
./build/llm/smartbotic-crm-llm
Terminal 3 - Webserver:
# Set required environment variables
export SMARTBOTIC_SERVER_JWT_SECRET=your-secret-key-change-in-production
export SMARTBOTIC_SERVER_STATIC_PATH=./webui/dist
./build/webserver/smartbotic-crm-webserver
Terminal 4 - WebUI Development (optional, for development):
cd webui
pnpm dev
On first run, create the admin user:
curl -X POST http://localhost:18080/api/bootstrap \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "your-password", "name": "Admin"}'
For persistent local testing, use systemd user services. Example service files are available in the systemd/ directory.
Create the config directory:
mkdir -p ~/.config/systemd/user ~/.config/smartbotic-crm ~/.local/share/smartbotic-crm
Copy and customize the service files (adjust paths to match your setup):
# Copy service files
cp systemd/*.service ~/.config/systemd/user/
# Edit the WorkingDirectory and ExecStart paths in each service file
nano ~/.config/systemd/user/smartbotic-db.service
Create the config file:
cat > ~/.config/smartbotic-crm/server.env << 'EOF'
SMARTBOTIC_SERVER_JWT_SECRET=dev-testing-secret-change-in-production
SMARTBOTIC_SERVER_STATIC_PATH=/path/to/smartbotic-crm/webui/dist
SMARTBOTIC_SERVER_LLM_ADDRESS=localhost:50052
EOF
Enable and start services:
systemctl --user daemon-reload
systemctl --user enable smartbotic-db
systemctl --user start smartbotic-db
# Add other services as needed
Check status:
systemctl --user status smartbotic-db
View logs:
journalctl --user -u smartbotic-db -f
~/.config/smartbotic-crm/~/.local/share/smartbotic-crm/journalctl --usersmartbotic-crm/
├── database/ # Database node (C++)
│ ├── include/ # Header files
│ └── src/ # Source files
├── webserver/ # Webserver node (C++)
│ ├── include/ # Header files
│ └── src/ # Source files
├── llm/ # LLM service node (C++)
│ ├── include/ # Header files
│ └── src/ # Source files
├── webui/ # Web UI (React)
│ ├── src/ # React components
│ └── dist/ # Built static files
├── proto/ # Protocol Buffer definitions
├── common/ # Shared C++ utilities
├── config/ # Configuration files
├── deploy/ # Deployment configurations
├── systemd/ # Systemd service files
├── tests/ # Test files
├── build/ # CMake build output
└── data/ # Runtime data directory
Environment variables:
SMARTBOTIC_DB_PORT - gRPC port (default: 50151)Command line options:
--data-dir - Data directory path for snapshotsEnvironment variables:
SMARTBOTIC_SERVER_HTTP_PORT - HTTP port (default: 18080)SMARTBOTIC_SERVER_WS_PORT - WebSocket port (default: 18081)SMARTBOTIC_SERVER_DATABASE_HOST - Database host (default: localhost)SMARTBOTIC_SERVER_DATABASE_PORT - Database port (default: 50151)SMARTBOTIC_SERVER_LLM_ADDRESS - LLM service address (default: localhost:50052)SMARTBOTIC_SERVER_JWT_SECRET - JWT signing secret (required)SMARTBOTIC_SERVER_STATIC_PATH - Static files directory (required)Environment variables:
SMARTBOTIC_LLM_PORT - gRPC port (default: 50052)SMARTBOTIC_LLM_DATABASE_HOST - Database host (default: localhost)SMARTBOTIC_LLM_DATABASE_PORT - Database port (default: 50151)GET /api/health - Health checkGET /api/version - Version informationPOST /api/bootstrap - Create first admin userPOST /api/auth/login - Login with email/passwordPOST /api/auth/refresh - Refresh access tokenPOST /api/auth/logout - LogoutGET /api/auth/me - Get current user infoPOST /api/users - Create user (superadmin)GET /api/users - List usersGET /api/users/:id - Get userPATCH /api/users/:id - Update userDELETE /api/users/:id - Delete userPOST /api/users/:id/api-keys - Create API keyGET /api/users/:id/api-keys - List API keysDELETE /api/users/:id/api-keys/:keyId - Revoke API keyPOST /api/workspaces - Create workspaceGET /api/workspaces - List workspacesGET /api/workspaces/:id - Get workspacePATCH /api/workspaces/:id - Update workspaceDELETE /api/workspaces/:id - Delete workspacePOST /api/workspaces/:wid/groups - Create groupGET /api/workspaces/:wid/groups - List groupsGET /api/workspaces/:wid/groups/:id - Get groupPATCH /api/workspaces/:wid/groups/:id - Update groupDELETE /api/workspaces/:wid/groups/:id - Delete groupPOST /api/workspaces/:wid/members - Add memberGET /api/workspaces/:wid/members - List membersGET /api/workspaces/:wid/members/:userId - Get memberPUT /api/workspaces/:wid/members/:userId - Update member groupsDELETE /api/workspaces/:wid/members/:userId - Remove memberPOST /api/workspaces/:wid/collections - Create collectionGET /api/workspaces/:wid/collections - List collectionsGET /api/workspaces/:wid/collections/:name - Get collectionPUT /api/workspaces/:wid/collections/:name - Update collectionDELETE /api/workspaces/:wid/collections/:name - Delete collectionPOST /api/workspaces/:wid/collections/:name/documents - Create documentGET /api/workspaces/:wid/collections/:name/documents - List documentsGET /api/workspaces/:wid/collections/:name/documents/:id - Get documentPUT /api/workspaces/:wid/collections/:name/documents/:id - Update documentPATCH /api/workspaces/:wid/collections/:name/documents/:id - Partial updateDELETE /api/workspaces/:wid/collections/:name/documents/:id - Delete documentPOST /api/workspaces/:wid/views - Create viewGET /api/workspaces/:wid/views - List viewsGET /api/workspaces/:wid/views/:id - Get viewPATCH /api/workspaces/:wid/views/:id - Update viewDELETE /api/workspaces/:wid/views/:id - Delete viewPOST /api/workspaces/:wid/pages - Create pageGET /api/workspaces/:wid/pages - List pagesGET /api/workspaces/:wid/pages/sidebar - List sidebar pagesGET /api/workspaces/:wid/pages/slug/:slug - Get page by slugGET /api/workspaces/:wid/pages/:id - Get pagePATCH /api/workspaces/:wid/pages/:id - Update pagePATCH /api/workspaces/:wid/pages/:id/share - Update page sharingDELETE /api/workspaces/:wid/pages/:id - Delete pagePOST /api/llm/sessions - Create LLM sessionGET /api/llm/sessions - List sessionsGET /api/llm/sessions/:id - Get sessionDELETE /api/llm/sessions/:id - Delete sessionPOST /api/llm/sessions/:id/messages - Send messagePOST /api/llm/sessions/:id/stream - Stream messagePOST /api/llm/sessions/:id/clear - Clear messagesGET /api/llm/providers - List providersGET /api/llm/models - List modelsPOST /api/llm/models/refresh - Refresh modelsGET /api/llm/providers/:id/health - Provider healthGET /api/llm/admin/providers - Admin: List providersPOST /api/llm/admin/providers - Admin: Create providerPUT /api/llm/admin/providers/:id - Admin: Update providerDELETE /api/llm/admin/providers/:id - Admin: Delete providerPUT /api/llm/workspaces/:wid/key - Set workspace LLM key (BYOK)GET /api/llm/workspaces/:wid/key - Get workspace LLM keyDELETE /api/llm/workspaces/:wid/key - Delete workspace LLM keyConnect to ws://localhost:18081/ws and authenticate:
{ "type": "auth", "token": "your-jwt-token" }
Subscribe to collection changes:
{ "type": "subscribe", "workspace_id": "...", "collection": "name" }
Receive document events:
{
"type": "document",
"action": "create|update|delete",
"workspace_id": "...",
"collection": "...",
"document_id": "...",
"data": { ... }
}
# Configure
cmake --preset release
# Build
cmake --build build -j$(nproc)
# C++ formatting
clang-format -i database/src/*.cpp webserver/src/*.cpp
# C++ linting
clang-tidy database/src/*.cpp webserver/src/*.cpp
# WebUI
cd webui
pnpm typecheck
pnpm lint
Copy the service files from the deploy/ directory and customize for your environment:
# Copy service files
sudo cp deploy/*.service /etc/systemd/system/
# Edit service files to match your installation paths
sudo nano /etc/systemd/system/smartbotic-db.service
# Reload systemd
sudo systemctl daemon-reload
# Enable services
sudo systemctl enable smartbotic-db
# Enable other services as needed
# Start services
sudo systemctl start smartbotic-db
Create configuration files in /etc/smartbotic/:
Database: Generally uses command-line arguments for data directory
Webserver (/etc/smartbotic/webserver.env):
SMARTBOTIC_SERVER_JWT_SECRET=your-secure-secret-key-min-32-chars
SMARTBOTIC_SERVER_STATIC_PATH=/opt/smartbotic-crm/webui/dist
SMARTBOTIC_SERVER_LLM_ADDRESS=localhost:50052
LLM Service (/etc/smartbotic/llm.env):
SMARTBOTIC_LLM_DATABASE_HOST=localhost
SMARTBOTIC_LLM_DATABASE_PORT=50151
Proprietary - All rights reserved.