Baby Tracker Setup Guide

Step-by-step instructions for setting up the Baby Tracker development environment

Developer Setup

Get up and running with Baby Tracker in minutes

Prerequisites

  • Python 3.9+
  • PostgreSQL 12+ (or use Docker)
  • Git
  • Docker & Docker Compose (optional, for containerized setup)

Quick Start with Docker (Recommended)

The easiest way to get started is using Docker Compose, which includes PostgreSQL and all dependencies.

1. Clone and start the application

# Clone the repository
git clone https://github.com/theamazingmrb/baby-tracker-api.git
cd baby-tracker-api

# Start all services
docker-compose up -d

2. Initialize the database

# Run migrations
docker-compose exec web python manage.py migrate

# Create admin user
docker-compose exec web python manage.py createsuperuser

# Load demo data (optional)
docker-compose exec web python manage.py loaddata demo_data.json

Local Development Setup

For local development without Docker, follow these steps:

1. Clone and setup Python environment

git clone https://github.com/theamazingmrb/baby-tracker-api.git
cd baby-tracker-api

# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\\Scripts\\activate

# Install dependencies
pip install -r requirements.txt

2. Configure environment variables

# Copy environment template
cp .env.example .env

Important: Edit the .env file with your database credentials and other settings.

3. Setup PostgreSQL database

# Create database (adjust for your PostgreSQL setup)
createdb babytracker

# Run migrations
python manage.py migrate

# Create admin user
python manage.py createsuperuser

# Start development server
python manage.py runserver

Environment Variables

Key environment variables you need to configure:

VariableDescriptionExample
DJANGO_DEBUGEnable debug modeTrue
SECRET_KEYDjango secret keyyour-secret-key-here
ENVIRONMENTEnvironment typedevelopment
NETWORK_HOSTHost to bind the Django server to0.0.0.0
NETWORK_PORTPort for the Django server8000
WEB_PORTPort to expose the web service on host80
ALLOWED_HOSTSComma-separated list of allowed host nameslocalhost,127.0.0.1,0.0.0.0
PRODUCTION_DOMAINYour API backend domainexample.com
FRONTEND_DOMAINYour frontend application domainexample.com
CORS_ALLOW_ALL_ORIGINSAllow all origins for CORSTrue
CORS_ALLOWED_ORIGINSComma-separated list of allowed originshttp://localhost:3000
DATABASE_URLDatabase connection stringpostgresql://user:pass@localhost/babytracker
POSTGRES_USERPostgreSQL username (Docker)postgres
POSTGRES_PASSWORDPostgreSQL password (Docker)postgres
POSTGRES_DBPostgreSQL database name (Docker)baby_tracker
EMAIL_BACKENDDjango email backenddjango.core.mail.backends.smtp.EmailBackend
EMAIL_HOSTSMTP server hostnamesmtp.gmail.com
EMAIL_PORTSMTP server port587
EMAIL_USE_TLSUse TLS for emailTrue
EMAIL_HOST_USEREmail usernameyour-email@example.com
EMAIL_HOST_PASSWORDEmail passwordyour-email-password
AWS_ACCESS_KEY_IDAWS access key (for S3/EB)your-access-key
AWS_SECRET_ACCESS_KEYAWS secret key (for S3/EB)your-secret-key
AWS_STORAGE_BUCKET_NAMEAWS S3 bucket nameyour-bucket-name
AWS_S3_REGION_NAMEAWS regionus-west-2

Testing the API

Once the server is running, you can test the API endpoints:

Using curl

# Register a new user
curl -X POST http://localhost:80/api/tracker/register/ \
-H "Content-Type: application/json" \\\
-d '{ "username": "testuser", "email": "test@example.com", "password": "testpass123" }'

Using Python requests

import
requests

response = requests.post(
"http://localhost:80/api/tracker/register/",
json={ "username": "testuser", "email": "test@example.com", "password": "testpass123" }
)

📚 Next Steps