Skip to content

Development Environment Setup

This guide walks you through setting up a complete development environment for Acumen ERP.

Prerequisites

Required Software

Software Minimum Version Purpose
Python 3.9+ Backend development
Node.js 16+ Frontend development
PostgreSQL 13+ Database (production-like)
Git 2.30+ Version control
Redis 5.0+ Task queue (optional)

Optional Tools

  • pgAdmin or DBeaver - Database management GUI
  • Postman or Insomnia - API testing
  • VS Code or PyCharm - Code editor/IDE

System Requirements

  • OS : Linux, macOS, or Windows 10/11
  • RAM : 8GB minimum, 16GB recommended
  • Disk : 10GB free space
  • CPU : Multi-core processor recommended

Installation Steps

1. Install Python 3.9+

Ubuntu/DebianmacOSWindows

sudo apt update
sudo apt install python3.9 python3.9-venv python3.9-dev



brew install python@3.9

Download from python.org and install.

Verify installation:

python3 --version
# Should show: Python 3.9.x or higher

2. Install Node.js 16+

Ubuntu/DebianmacOSWindows

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs



brew install node@18

Download from nodejs.org and install LTS version.

Verify installation:

node --version  # Should show: v16.x or higher
npm --version   # Should show: 8.x or higher

3. Install PostgreSQL

Ubuntu/DebianmacOSWindows

sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresql



brew install postgresql@15
brew services start postgresql@15

Download from postgresql.org and install.

4. Install Git

Ubuntu/DebianmacOSWindows

sudo apt install git



brew install git

Download from git-scm.com and install.

Verify installation:

git --version

5. Install Redis (Optional)

Ubuntu/DebianmacOSWindows

sudo apt install redis-server
sudo systemctl start redis
sudo systemctl enable redis



brew install redis
brew services start redis

Use Windows Subsystem for Linux or Docker.

Clone the Repository

# Clone from Git repository
git clone https://github.com/DevBitserfGit/adaptive-alpha.git
cd adaptive-alpha

# Or if already on the server
cd /opt/acumen/project_root

Database Setup

1. Create PostgreSQL Database

# Switch to postgres user
sudo -u postgres psql

# In PostgreSQL prompt:
CREATE DATABASE acumen_erp;
CREATE USER acumen_user WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE acumen_erp TO acumen_user;
\q

2. Import Database Schema (if available)

# If you have a database dump
psql -U acumen_user -d acumen_erp < database_dump.sql

# Or run migrations (Django)
cd backend/django_app
python manage.py migrate

3. Configure Database Connection

Create .env file in backend/django_app/:

# Database Configuration
DATABASE_URL=postgresql://acumen_user:secure_password@localhost:5432/acumen_erp

# Django Settings
SECRET_KEY=your-secret-key-here-change-in-production
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

# CORS Settings
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

# JWT Settings
JWT_SECRET_KEY=another-secret-key-for-jwt
JWT_ALGORITHM=HS256
JWT_EXPIRATION_HOURS=24

Backend Setup (Python)

1. Create Virtual Environment

cd /opt/acumen/project_root

# Create virtual environment
python3 -m venv venv

# Activate virtual environment
source venv/bin/activate  # Linux/macOS
# or
venv\Scripts\activate     # Windows

2. Install Python Dependencies

# Ensure venv is activated
pip install --upgrade pip

# Install all dependencies
pip install -r requirements.txt

Common dependencies include: - fastapi - Web framework - uvicorn - ASGI server - sqlalchemy - ORM - pydantic - Data validation - django - Auth framework - djangorestframework - REST API - python-jose - JWT handling - bcrypt - Password hashing - celery - Task queue - redis - Cache

3. Configure FastAPI

Create backend/api/config.py (if not exists):

import os

DATABASE_URL = os.getenv(
    "DATABASE_URL",
    "postgresql://acumen_user:secure_password@localhost:5432/acumen_erp"
)

ALLOWED_ORIGINS = [
    "http://localhost:3000",
    "http://127.0.0.1:3000",
]

ROUTER_MODE = os.getenv("ROUTER_MODE", "core")  # core | minimal | full

4. Initialize Django

cd backend/django_app

# Run migrations
python manage.py migrate

# Create superuser for Django admin
python manage.py createsuperuser
# Enter: username, email, password

# Collect static files
python manage.py collectstatic --noinput

Frontend Setup (Node.js)

1. Install Node Dependencies

cd frontend

# Install all packages
npm install

Common dependencies include: - react - UI library - react-router-dom - Routing - @mui/material - Material-UI components - axios - HTTP client - react-hook-form - Form handling - js-yaml - YAML parsing

2. Configure Frontend

Create frontend/.env:

# API Endpoints
REACT_APP_API_URL=http://localhost:8001
REACT_APP_DJANGO_URL=http://localhost:8000

# Environment
REACT_APP_ENV=development

3. Build Frontend (Optional)

# For production build
npm run build

# Output in: frontend/build/

Running the Application

You need three terminal windows to run all services:

Terminal 1: FastAPI Backend

cd /opt/acumen/project_root
source venv/bin/activate
python run.py

Output:

INFO:     Started server process [12345]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)

Access: - API: http://localhost:8001 - Swagger UI: http://localhost:8001/docs - ReDoc: http://localhost:8001/redoc

Terminal 2: Django Backend

cd /opt/acumen/project_root/backend/django_app
source ../../venv/bin/activate
python manage.py runserver

Output:

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

Access: - Admin: http://localhost:8000/admin/ - Auth API: http://localhost:8000/api/auth/

Terminal 3: React Frontend

cd /opt/acumen/project_root/frontend
npm start

Output:

Compiled successfully!

You can now view acumen-erp in the browser.

  Local:            http://localhost:3000
  On Your Network:  http://192.168.1.100:3000

Access: - Application: http://localhost:3000

Verify Installation

1. Check FastAPI Health

curl http://localhost:8001/health

Expected response:

{
  "status": "healthy",
  "service": "Enterprise ERP API"
}

2. Check Database Connection

curl http://localhost:8001/api/company/company/ | jq

Should return a list of companies (or empty array).

3. Check Django Admin

Visit http://localhost:8000/admin/ and login with superuser credentials.

4. Check Frontend

Visit http://localhost:3000 and login.

Router Modes

FastAPI supports three startup modes for performance:

Minimal Mode (Fastest)

export ROUTER_MODE=minimal
python run.py

Loads only essential entities. Best for development.

Core Mode (Default)

export ROUTER_MODE=core
python run.py

Loads Core, Finance, Company domains. Recommended for most development.

Full Mode (Slowest)

export ROUTER_MODE=full
python run.py

Loads all 2016+ entities. Only use when needed.

Development Tools

Database Tools

pgAdmin - GUI for PostgreSQL

sudo apt install pgadmin4  # Ubuntu
brew install --cask pgadmin4  # macOS

Connection details: - Host: localhost - Port: 5432 - Database: acumen_erp - Username: acumen_user

API Testing

Swagger UI (built-in): - http://localhost:8001/docs

Postman : 1. Import OpenAPI spec from http://localhost:8001/openapi.json 2. Set environment variable: BASE_URL = http://localhost:8001

Code Quality Tools

# Code formatting
pip install black isort

# Run black
black backend/

# Sort imports
isort backend/

# Linting
pip install flake8
flake8 backend/

Testing Tools

# Install pytest
pip install pytest pytest-cov

# Run tests
pytest

# With coverage
pytest --cov=backend/

Common Issues

Port Already in Use

Problem: Port 8001, 8000, or 3000 is already in use.

Solution:

# Find process using port
lsof -i :8001  # Linux/macOS
netstat -ano | findstr :8001  # Windows

# Kill process
kill -9 <PID>

Or change port in run.py or npm start.

Database Connection Error

Problem: sqlalchemy.exc.OperationalError: could not connect to server

Solution: 1. Verify PostgreSQL is running: sudo systemctl status postgresql 2. Check DATABASE_URL in .env file 3. Verify credentials: psql -U acumen_user -d acumen_erp

Module Not Found

Problem: ModuleNotFoundError: No module named 'fastapi'

Solution:

# Activate virtual environment
source venv/bin/activate

# Reinstall dependencies
pip install -r requirements.txt

CORS Error in Browser

Problem: CORS policy: No 'Access-Control-Allow-Origin' header

Solution: 1. Check ALLOWED_ORIGINS in backend/api/config.py 2. Add frontend URL: http://localhost:3000 3. Restart FastAPI server

npm Install Fails

Problem: npm ERR! code ERESOLVE

Solution:

# Clear npm cache
npm cache clean --force

# Install with legacy peer deps
npm install --legacy-peer-deps

Next Steps

Now that your environment is set up:

  1. Development Workflow - Learn daily development practices
  2. Architecture Overview - Understand system design
  3. Adding New Entities - Create your first feature
  4. API Documentation - Explore available APIs

Useful Commands

# Backend
source venv/bin/activate          # Activate venv
python run.py                      # Start FastAPI
python manage.py runserver         # Start Django
python manage.py makemigrations    # Create migrations
python manage.py migrate           # Apply migrations
python manage.py createsuperuser   # Create admin user

# Frontend
npm start                          # Start dev server
npm run build                      # Production build
npm test                           # Run tests

# Database
psql -U acumen_user -d acumen_erp  # Connect to database
pg_dump acumen_erp > backup.sql    # Backup database
psql acumen_erp < backup.sql       # Restore database

# Quality
black backend/                     # Format code
isort backend/                     # Sort imports
flake8 backend/                    # Lint code
pytest                             # Run tests

Environment Variables Reference

Variable Purpose Example
DATABASE_URL PostgreSQL connection postgresql://user:pass@host:5432/db
ROUTER_MODE API startup mode core, minimal, full
SECRET_KEY Django secret Random string
DEBUG Debug mode True, False
ALLOWED_HOSTS Django allowed hosts localhost,127.0.0.1
CORS_ALLOWED_ORIGINS CORS origins http://localhost:3000
REACT_APP_API_URL FastAPI URL http://localhost:8001
REACT_APP_DJANGO_URL Django URL http://localhost:8000