A web application focused on ethical analysis using AI models, leveraging backend processes for validation, model selection, and result generation.
- Prerequisites
- Setup
- Local Development
- Configuration
- API Usage
- Physical Verification Blockchain (PVB)
- Security Notes
- Docker installed
- Docker Compose installed
- PowerShell 5.1 or later (for Windows users)
- Clone the repository
- Copy the example environment file:
cp .env.example .env
- Edit
.envto configure your environment variables (API keys, etc.)
This project uses Docker Compose to run both frontend and backend services locally. Follow these steps:
-
Copy and configure environment files:
# Copy root configuration cp .env.example .env # The file 'backend.env' already contains placeholders for LLM API keys and models. # Edit it in-place to fill in your OpenAI, Anthropic, and Gemini keys, and set DEFAULT_LLM_MODEL and ANALYSIS_LLM_MODEL.
-
Build Docker images:
# Use Docker Compose v2 syntax docker compose build -
Start all services:
docker compose up -d
-
View service logs (for troubleshooting):
docker compose logs -f ai-backend docker compose logs -f ai-frontend docker compose logs -f app
-
Stop and remove containers:
docker compose down
-
Optional: Rebuild a single service:
docker compose build ai-backend docker compose up -d ai-backend
- The
.envfile stores configuration variables for the local development environment only. - It is based on the
.env.exampletemplate. - Crucially, this file should be listed in your
.gitignorefile and NEVER committed to version control.
Required environment variables:
API_KEY: Primary key for accessing required APIsAPI_SECRET: Secret or secondary key for API authenticationAPI_ENDPOINT: Base URL for the API endpointAPI_VERSION: Specific version of the API being targetedNODE_ENV: Specifies the runtime environment (e.g.,development,production)LOG_LEVEL: Determines verbosity of application logs
The base URL for the API is configured via the API_ENDPOINT environment variable.
- Local Development: Check your
.envfile.
Authentication is handled using the API_KEY and API_SECRET.
- Mechanism: Authentication details (e.g., header names like
X-API-KEYorAuthorization) should be verified in the API implementation. - Credentials: Obtain the necessary key and secret from your local
.envfile.
Detailed API endpoint documentation is not currently linked here. Please refer to the API source code or create dedicated documentation (e.g., using Swagger/OpenAPI). The docs/R2_Ethical_Analysis_Flow.md file describes the /analyze endpoint flow.
The API version may be specified by the API_VERSION configuration variable. If used, include this information in your requests as needed (e.g., in the URL path or an Accept header). The specific implementation of API versioning (if any) should be verified in the API source code.
The Ethics Dashboard includes a Physical Verification Blockchain (PVB) system that provides cryptographically secure chain of custody for media and data. This system enables:
- Device Security Modules (DSMs): Software/hardware on capturing devices that sign data at the source
- Trusted Verifiers (TVs): Entities that vet and register DSMs
- Immutable Records: Blockchain-based storage of data hashes, signatures, and metadata
- Cryptographic verification of data authenticity
- Immutable audit trails
- Decentralized trust through blockchain technology
- Support for off-chain data storage (IPFS, Arweave)
- RESTful API for integration with external systems
- Health Check:
GET /api/pvb/health - Verifier Registration:
POST /api/pvb/verifiers - Device Management:
POST /api/pvb/verifiers/{address}/devices - Data Submission:
POST /api/pvb/data - Data Verification:
GET /api/pvb/data/{hash}/verify
-
Start the blockchain service:
docker compose up -d ganache
-
Deploy smart contracts:
python scripts/deploy_pvb_contracts.py
-
Test the PVB API:
curl http://localhost:5000/api/pvb/health
For detailed PVB documentation, see docs/PVB_Implementation_Guide.md.
- Secret Management: Never commit sensitive information like passwords, API keys, or
.envfiles directly into the Git repository. Use.gitignoreto prevent accidental commits. - Production Secrets: For production deployments, ensure secure secret management and proper environment variable configuration.
- PowerShell Execution Policy (Windows): If using PowerShell scripts for setup or tasks, be mindful of the system's execution policy. Changes should be understood and potentially reverted if temporary. Apply the principle of least privilege.