Running the Tracker System
This guide explains how to run the Tracker System, including both the API and Admin Panel, in various environments.
Running in Production
For production deployments, Docker Compose is the recommended method for running the Tracker System.
Using Docker Compose
For Production:
# Using environment variable
export COMPOSE_PROFILES=prod
docker compose up -d
# Or using --profile flag
docker compose --profile prod up -d
# Or inline
COMPOSE_PROFILES=prod docker compose up -d
# Check the status of the services
docker compose ps
# View logs
docker compose logs -f
This will start the following services:
- API: http://localhost:8000
- Admin Panel: http://localhost:8080
- Documentation: http://localhost:8001
Stopping the Services
docker compose down
Running in Development
For development, you can use the development services provided by Docker Compose, or run the services locally.
Using Docker Compose for Development
# Using environment variable
export COMPOSE_PROFILES=dev
docker compose up
# Or using --profile flag
docker compose --profile dev up
# Or inline
COMPOSE_PROFILES=dev docker compose up
# Check the status of the services
docker compose ps
# View logs
docker compose logs -f
This will start the following services:
- API (development mode): http://localhost:8100
- Admin Panel (development mode): http://localhost:3000
- PostgreSQL: localhost:2345
- Dragonfly (Redis): localhost:6379
The development services include:
- Live code reloading for both the API and Admin Panel
- Debugging support for the API
- Development tools and utilities
Running Locally
You can also run the API and Admin Panel locally for development.
Running the API Locally
# Activate the virtual environment
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Run the API with live reloading
uvicorn app.main:app --reload --port 8000
The API will be available at http://localhost:8000.
Running the Admin Panel Locally
# Navigate to the admin panel directory
cd tracker-admin
# Install dependencies (if not already installed)
npm install
# Run the development server
npm run dev
The Admin Panel will be available at http://localhost:3000.
Debugging
Debugging the API
The API includes support for remote debugging with VSCode. To debug the API:
- Start the development service:
# Using environment variable
export COMPOSE_PROFILES=dev
docker compose up
# Or using --profile flag
docker compose --profile dev up
# Or inline
COMPOSE_PROFILES=dev docker compose up
- Attach the VSCode debugger:
- Open the project in VSCode
- Go to the "Run and Debug" view (Ctrl+Shift+D or Cmd+Shift+D on macOS)
- Select "Python: Remote Attach" from the dropdown menu
- Click the green play button or press F5
VSCode will attach to the running container, and the application will start. You can now set breakpoints in your code and debug as usual.
Debugging the Admin Panel
The Admin Panel includes support for debugging with browser developer tools:
- Start the development service:
# Using environment variable
export COMPOSE_PROFILES=dev
docker compose up
# Or using --profile flag
docker compose --profile dev up
# Or inline
COMPOSE_PROFILES=dev docker compose up
- Open the Admin Panel in your browser:
- Navigate to http://localhost:3000
- Open the browser developer tools (F12 or Ctrl+Shift+I or Cmd+Option+I on macOS)
- Go to the "Sources" tab
- Set breakpoints in your code
You can also use the React Developer Tools extension for Chrome or Firefox to inspect and debug React components.
Monitoring
Monitoring the API
The API includes a performance monitoring middleware that logs request times and other metrics. You can view these logs using:
docker compose logs -f api
Monitoring the Admin Panel
The Admin Panel includes React Query DevTools for monitoring API requests and cache state. To enable the DevTools:
- Open the Admin Panel in your browser
- Press Ctrl+Shift+Q or Cmd+Shift+Q on macOS to toggle the DevTools
Common Issues
API Not Starting
If the API fails to start, check the logs for errors:
docker compose logs api
Common issues include:
- Database connection errors
- Missing environment variables
- Port conflicts
Admin Panel Not Starting
If the Admin Panel fails to start, check the logs for errors:
docker compose logs admin
Common issues include:
- Node.js version incompatibility
- Missing dependencies
- Port conflicts
CORS Errors
If you encounter CORS errors when the Admin Panel tries to connect to the API, check that:
- The API is configured to allow requests from the Admin Panel's origin
- The Admin Panel is using the correct API URL
See the CORS Error Handling guide for more information.
Performance Tuning
API Performance
To improve API performance:
- Enable Redis caching by setting the
REDIS_CACHE_TTLenvironment variable - Increase the number of workers by setting the
WORKERS_PER_COREenvironment variable - Use connection pooling for database connections
Admin Panel Performance
To improve Admin Panel performance:
- Enable production mode by setting the
NODE_ENVenvironment variable toproduction - Use code splitting to reduce bundle size
- Implement caching strategies for API responses