Skip to content

Getting Started

Ayush Sachan edited this page Apr 6, 2025 · 3 revisions

Getting Started

This guide provides step-by-step instructions to set up the SafeMinds AI project for local development. Follow these steps to get the application running on your machine.


1. Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Operating System: Linux or macOS is recommended. Windows users should use the Windows Subsystem for Linux (WSL 2).
  • Python: Version 3.12.3 or later. Verify your installation includes pip. [Download Python](https://www.python.org/)
  • Git: Required for cloning the project repository. [Install Git](https://git-scm.com/)
  • Virtual Environment Tool: Python's built-in venv is used.

Optional: Depending on your OS and specific package installations (like OpenCV), you might need system-level build tools or libraries (e.g., build-essential, libgl1-mesa-glx on Debian/Ubuntu). Check pip install logs for errors if they occur.


2. Clone the Repository

git clone https://github.com/HackByte3-0/SafeMind-AI
cd SafeMind-AI

3. Set Up the Python Environment

We use a virtual environment to isolate project dependencies.

# Create virtual environment
python -m venv venv

# Activate it:
# macOS/Linux:
source venv/bin/activate

# Windows (Git Bash/WSL):
source venv/Scripts/activate

# Windows (Command Prompt):
.\venv\Scripts\activate.bat

# Windows (PowerShell):
.\venv\Scripts\Activate.ps1

# Install dependencies
pip install -r requirements.txt

4. Configure Environment Variables

We use a .env file in development, loaded with python-dotenv.

a. Create .env File

cp env.example .env

b. Edit .env

Fill in the required environment variables:

# Django Settings
SECRET_KEY='your_unique_django_secret_key_here'
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost

# External API Keys
GEMINI_API_KEY='your_google_gemini_api_key_here'
CLOUDFLARE_ACCOUNT_ID='your_cloudflare_account_id_here'
CLOUDFLARE_API_TOKEN='your_cloudflare_api_token_here'

Note: Never commit your .env file to Git.


5. Set Up External Services (API Keys)

a. Google Gemini API Key

[Get API Key Guide](https://ai.google.dev/tutorials/get_started_web#get-api-key)


b. Cloudflare API Token

  • Purpose: Used for:

    • Speech-to-text transcription.
    • Sentiment analysis.
  • Steps:

    1. Login at [Cloudflare Dashboard](https://dash.cloudflare.com/)
    2. Get your Account ID (found in Overview or Workers section).
    3. Go to My Profile > API Tokens > Create Token.
    4. Use template or custom permissions:
      • AccountWorkers AIRead
    5. Scope the token to your account.
    6. Copy and add it to .env as CLOUDFLARE_API_TOKEN.

6. Set Up the Database

For local dev, we use SQLite (auto-handled by Django).

# Apply DB migrations
python manage.py migrate

# Create a superuser for the admin panel
python manage.py createsuperuser

7. Run the Development Server

python manage.py runserver

Should output something like:

Django version X.Y, using settings 'SafeMindsAI.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

8. First Run Checks


🎉 Done! You now have a local SafeMinds AI environment running. Let the building begin!