Skip to main content
This guide will walk you through setting up the SMS project for local development.

Prerequisites

Before you begin, ensure you have the following installed on your system:
  • Python 3.12+
  • PostgreSQL 15+ (Docker recommended)
  • Redis (Optional for dev, required for production/caching tasks)
  • Git

Step-by-Step Installation

Step 1: Clone the repository

First, clone the project to your local machine:
git clone <repository-url>
cd sms

Step 2: Set up PostgreSQL (Docker method)

The easiest way to get the database running is via Docker:
docker run --name postgres-dev \
  -e POSTGRES_DB=devdb \
  -e POSTGRES_USER=devuser \
  -e POSTGRES_PASSWORD=devpass \
  -p 5432:5432 \
  -d postgres:15

Step 3: Create a Virtual Environment

Set up a Python virtual environment to isolate project dependencies:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
Install the required dependencies:
pip install -r requirements.txt

Step 4: Configure Environment Variables

The project uses .env.dev for local development. Copy the example file:
cp .env.example .env.dev
Make sure the DATABASE_URL in .env.dev matches the credentials used in your PostgreSQL setup (postgres://devuser:devpass@localhost:5432/devdb).

Step 5: Database Migrations

Because the system uses django-tenants, you must migrate the public schema first, then the tenant schemas.
# Make migrations for the apps
python manage.py makemigrations authentication
python manage.py makemigrations clients
python manage.py makemigrations core
python manage.py makemigrations

# Apply migrations
python manage.py migrate_schemas --shared
python manage.py migrate_schemas

Step 6: Create the Public Tenant

For the multi-tenant system to work, you must create a public tenant which acts as the main routing domain:
python manage.py create_tenant
Follow the interactive prompts to set the domain (e.g., localhost) and name.

Step 7: Run the Server

Start the Django development server:
python manage.py runserver
You can now navigate to http://localhost:8000 to interact with the API or admin portal!