Skip to content

Latest commit

 

History

History
156 lines (119 loc) · 3.34 KB

File metadata and controls

156 lines (119 loc) · 3.34 KB

CRADLE Backend

Django-powered API for CRADLE
Explore main project »

About

Django-based backend providing core functionality for CRADLE including:

  • REST API endpoints
  • Data models and PostgreSQL integration
  • File storage with MinIO
  • Authentication system
  • Background task processing with Celery and Redis

(back to top)

Getting Started

Prerequisites

  • Python 3.11+
  • PostgreSQL 13+
  • Redis 6.0+
  • Pipenv
  • MinIO (optional)

Installation

  1. Clone the repository

    git clone https://github.com/prodaft/cradle.git
    cd cradle/backend
    git submodule update --init --recursive
  2. Database Setup

    psql -U [your-postgres-username]
    CREATE DATABASE cradledb;
  3. Redis Setup

    • Install and start Redis server
    # On Ubuntu
    sudo apt install redis-server
    sudo systemctl start redis
  4. Configure Environment

    • Update database credentials in cradle/settings.py
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': 'cradledb',
            'USER': '[your_user]',
            'PASSWORD': '[your_password]',
            'HOST': 'localhost',
            'PORT': '5432',
        }
    }
    
    CELERY_BROKER_URL = 'redis://localhost:6379/0'
  5. Install Dependencies

    pip install pipenv
    pipenv install
  6. Run Migrations

    pipenv run python manage.py migrate
  7. Start Services

    # Start Django development server
    pipenv run python manage.py runserver
    
    # Start Celery worker (in separate terminal)
    pipenv run celery -A cradle worker -Q email,notes,publish,import -l INFO

(back to top)

Usage

Common Commands

# Run tests
pipenv run python manage.py test

# Create new migration
pipenv run python manage.py makemigrations

# Generate API documentation
cd docs && make html

# Monitor Celery tasks
pipenv run celery -A cradle flower

Development Tips

# Access Django shell
pipenv run python manage.py shell_plus --ipython

# Check code quality
pipenv run flake8 .

(back to top)

Troubleshooting

Database Connection Issues

  • Verify PostgreSQL service is running
  • Check credentials in settings.py match your DB configuration

Celery Task Issues

  • Ensure Redis server is running
  • Verify Celery worker is started
  • Check task queue status with Flower

(back to top)

Contributing

See main project contribution guidelines. For backend-specific issues:

  1. Fork & create feature branch
  2. Commit changes with descriptive messages
  3. Open pull request with test coverage details

(back to top)

License

Distributed under the MIT License. See LICENSE for details.

(back to top)