- The application that is taking charge of AI related tasks mainly. 主にAI関連のタスクを担当するアプリケーション
- A unified FastAPI service that integrates focus analysis and scoring capabilities using modular architecture with dependency injection
- We will try to release another version in the future to make sure that this code repository could be used
This application uses a unified single-service architecture (not microservices):
- Single FastAPI application running on port 7003
- Modular controllers and services with dependency injection
- Direct in-process service calls (no HTTP between services)
- Centralized configuration and routing
- Python 3.9+ (recommended: Python 3.12)
- pipenv (will be installed automatically if not present)
- OpenAI API Key
./entry.shThis will:
- ✅ Check Python version compatibility
- ✅ Install pipenv if needed
- ✅ Create virtual environment
- ✅ Install all dependencies
- ✅ Create
.envfile with default configuration - ✅ Verify installation
After setup, update your .env file with your OpenAI API key:
OPENAI_API_KEY=your_actual_api_key_hereThe application runs as a single unified FastAPI service that integrates focus analysis and scoring capabilities.
pipenv run python src/app/main.pyOr using uvicorn directly:
pipenv run uvicorn src.app.main:app --host 0.0.0.0 --port 7003 --reload# Build and run with docker-compose
cd src
docker-compose up --build
# Or build and run manually
docker build -t anchor-insight-ai -f src/Dockerfile .
docker run -p 7003:7003 --env-file .env anchor-insight-aiOnce the service is running:
- API Documentation (Swagger): http://localhost:7003/docs
- API Documentation (ReDoc): http://localhost:7003/redoc
- Health Check: http://localhost:7003/health
- Root Endpoint: http://localhost:7003/
Available endpoints:
/api/v1/monitor/*- Focus time monitoring and person detection/api/v1/analyze/*- Focus score analysis from images
# Activate virtual environment
pipenv shell
# Run the application
pipenv run python src/app/main.py
# Or using uvicorn with auto-reload for development
pipenv run uvicorn src.app.main:app --host 0.0.0.0 --port 7003 --reloadanchor-insight-AI/
├── entry.sh # Setup and dependency installation script
├── Pipfile # Python dependencies
├── .env # Environment configuration (created from .env.template)
├── src/
│ ├── app/
│ │ └── main.py # Unified FastAPI application
│ ├── config/
│ │ └── settings.py # Application settings and configuration
│ ├── controllers/
│ │ ├── focus_controller.py # Focus monitoring endpoints
│ │ └── focus_score_controller.py # Focus score analysis endpoints
│ ├── services/
│ │ ├── focus_service.py # Focus monitoring service
│ │ └── focus_score_service.py # Focus score analysis service
│ ├── models/
│ │ └── focus_models.py # Data models and schemas
│ ├── constants/
│ │ └── focus_constants.py # Application constants
│ ├── dependencies.py # Dependency injection setup
│ ├── Dockerfile # Docker container definition
│ └── docker-compose.yml # Docker orchestration
└── README.md
The project uses pipenv for dependency management:
# Activate virtual environment
pipenv shell
# Install new package
pipenv install package_name
# Install dev dependencies
pipenv install package_name --dev| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY |
Your OpenAI API key | Required |
MODEL_ID |
OpenAI model to use | gpt-5-nano |
MAX_FILE_SIZE_MB |
Maximum file size for uploads | 10 |
URL_TIMEOUT_SECONDS |
Request timeout | 30 |
API_HOST |
Server host address | 0.0.0.0 |
API_PORT |
Server port number | 7003 |
API_RELOAD |
Auto-reload on code changes | false |
LOG_LEVEL |
Logging verbosity | info |
CAMERA_INDEX |
Camera device index | 0 |
CAMERA_WIDTH |
Camera resolution width | 640 |
CAMERA_HEIGHT |
Camera resolution height | 480 |
CONFIDENCE_THRESHOLD |
YOLO confidence threshold | 0.5 |
Python version error:
# Check Python version
python3 --version
# Ensure you have Python 3.9+Pipenv not found:
# Install pipenv manually
python3 -m pip install --user pipenvService connection errors:
- Ensure the service is running on port 7003
- Check configuration in
.envfile - Verify firewall settings allow connections to port 7003
OpenAI API errors:
- Verify your API key in
.envfile - Check your OpenAI account balance
- Ensure you have access to the specified model
See LICENSE file for details.