Installation Guide
This guide will help you set up the BrainMaps API on your local machine for development purposes.
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- PostgreSQL 12 or higher (optional, SQLite for development)
- Git
Installation Steps
1. Clone the Repository
git clone https://github.com/yourusername/brainmaps-api.git
cd brainmaps-api2. Set Up a Virtual Environment
# Create a virtual environment
python -m venv env
# Activate the virtual environment
# On Windows:
env\Scripts\activate
# On macOS/Linux:
source env/bin/activate3. Install Dependencies
pip install -r requirements.txt4. Environment Configuration
Create a .env file in the root directory:
cp .env.example .envUpdate the following variables in .env:
DEBUG=True
SECRET_KEY=your-secret-key
DATABASE_URL=sqlite:///db.sqlite3 # For development
ALLOWED_HOSTS=localhost,127.0.0.1
CORS_ALLOWED_ORIGINS=http://localhost:3000
# Optional AWS Configuration for S3 storage
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_STORAGE_BUCKET_NAME=your-bucket-name
AWS_S3_REGION_NAME=your-region5. Database Setup
# Create database tables
python manage.py migrate
# Create a superuser (admin account)
python manage.py createsuperuser6. Run Development Server
python manage.py runserverThe API will be available at http://localhost:8000/api/.
Docker Installation (Alternative)
If you prefer using Docker:
# Build and start the containers
docker-compose up -d
# Run migrations
docker-compose exec web python manage.py migrate
# Create superuser
docker-compose exec web python manage.py createsuperuserVerifying Installation
To verify your installation:
- Visit
http://localhost:8000/api/in your browser - You should see the Django REST framework API root page
- Try logging in with your superuser credentials
Common Issues
Database Connection Issues
If you’re using PostgreSQL and encounter connection issues:
- Verify PostgreSQL is running
- Check your database URL in
.env - Ensure the database exists and the user has appropriate permissions
File Upload Issues
If file uploads aren’t working:
- Check your media directory permissions
- Verify your AWS credentials if using S3
- Ensure your file size doesn’t exceed the limit
Next Steps
- Read the Authentication Guide to learn about securing your API
- Check the Quick Start Guide for basic usage examples
- Explore the API Reference for detailed endpoint documentation