CRM - Standalone Linux Package
==============================

This package is a self-contained build. Python and all Python libraries are
already bundled inside the _internal folder. You do NOT need to install
Python, pip, a virtualenv, Flask, or Waitress on the customer machine.


What the customer must install
------------------------------

Required:
  * MySQL Server 8.0+ (or MariaDB 10.6+)   - the CRM database
  * mysql client                           - to import demo.sql / backups
  * glibc-based 64-bit Linux (Ubuntu 22.04 or newer recommended)

Optional:
  * systemd        - to run the CRM as a background service (see below)
  * nginx / caddy  - reverse proxy if the CRM must be reachable over HTTPS

  sudo apt update
  sudo apt install -y mysql-server mysql-client


Already bundled - no action needed
----------------------------------

  Python 3.12 runtime
  Flask 3.0.3                  - web framework
  Waitress 3.0.2               - production WSGI server used by the binary
  Werkzeug 3.0.4               - HTTP / security helpers
  mysql-connector-python 9.0.0 - MySQL driver
  python-dotenv 1.0.1          - reads _internal/.env
  openpyxl 3.1.5               - XLSX import / export
  requests 2.32.3              - license server communication
  cryptography 43.0.1          - license signature verification
  templates/ and static/       - UI assets
  licensing/keys/              - license public key


Folder layout
-------------

  crm                     the executable
  _internal/              bundled runtime, libraries and assets
  _internal/.env          database + secret configuration (EDIT THIS)
  demo.sql                demo database with sample data
  deployment/crm.service  systemd unit file


Setup
-----

1. Configure database credentials:

     nano _internal/.env

   Set at least MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE and SECRET_KEY.

2. Create the database:

     mysql -u root -p < demo.sql

3. Start the CRM:

     ./crm

   The binary serves with Waitress on port 5000 - open http://SERVER_IP:5000
   Override the bind settings with CRM_HOST, CRM_PORT or CRM_THREADS.


Run as a service (systemd)
--------------------------

  sudo mkdir -p /opt/crm
  sudo cp -a ./* /opt/crm/
  sudo useradd --system --home /opt/crm crm
  sudo chown -R crm:crm /opt/crm
  sudo cp deployment/crm.service /etc/systemd/system/crm.service
  sudo systemctl daemon-reload
  sudo systemctl enable --now crm
  sudo systemctl status crm

The unit binds to 127.0.0.1:5000; put nginx or caddy in front of it to
terminate HTTPS. To listen on all interfaces instead, change
Environment=CRM_HOST=0.0.0.0 in the unit file.

Settings can also be overridden without touching _internal/.env by creating
/etc/crm/crm.env with the same variable names (chmod 600).

Logs:

  sudo journalctl -u crm -f


Licensing
---------

The CRM validates its license with the license server on startup and during
use. Activate from the admin area after the first login. A license is bound to
one machine; moving the install to different hardware needs a new activation
from the license manager.


Demo logins
-----------

  superadmin              admin@example.com   admin1234
  manager                 siva@abcd.com       123456789
  user (sales approver)   jega@abcd.com       123456789

Change these passwords immediately after the first login.
