Changed terminology from "API" to "Routes" to better reflect server-rendered HTML approach: - Renamed submission_api.md → submission_routes.md - Renamed dashboard_api.md → dashboard_routes.md - Renamed admin_api.md → admin_routes.md - Updated headers to clarify "Response Type: Server-rendered HTML (no JavaScript required)" - Updated references in plan.md and quickstart.md This clarifies that the application uses traditional web routes with form submissions and HTML responses, not REST API endpoints with JSON. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
12 KiB
Quickstart Guide: Reklamator Development
Branch: 001-build-an-application | Date: 2025-10-15
This guide helps developers set up the Reklamator development environment and understand the project structure.
Prerequisites
- Python 3.11 or higher
- ClamAV daemon (
clamd) for malware scanning - Git
- Virtual environment tool (venv)
Initial Setup
1. Clone Repository
git clone <repository-url>
cd reklamator
git checkout 001-build-an-application
2. Create Virtual Environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install Dependencies
pip install -r requirements.txt
Expected Core Dependencies:
- Flask 3.0+
- Flask-Login (session management)
- Flask-Limiter (rate limiting)
- Flask-WTF (CSRF protection)
- anthropic (Claude API client)
- clamd (ClamAV integration)
- bcrypt (password hashing)
- PyYAML (configuration files)
- pytest, pytest-flask (testing)
4. Install and Configure ClamAV
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install clamav clamav-daemon
sudo systemctl start clamav-daemon
sudo systemctl enable clamav-daemon
macOS:
brew install clamav
brew services start clamav
Verify ClamAV is running:
clamdscan --version
5. Set Up Environment Variables
Create .env file in project root:
# Flask Configuration
FLASK_APP=run.py
FLASK_ENV=development
SECRET_KEY=your-secret-key-here-change-in-production
# Claude API
ANTHROPIC_API_KEY=your-claude-api-key-here
# ClamAV
CLAMD_SOCKET=/var/run/clamav/clamd.ctl # Adjust path for your system
# File Storage
DATA_DIR=./data
# Rate Limiting
RATE_LIMIT_ENABLED=true
RATE_LIMIT_PER_HOUR=10
Get Claude API Key:
- Sign up at https://console.anthropic.com/
- Create an API key
- Add to
.envfile
6. Initialize Data Directory
mkdir -p data/products
7. Create Initial Admin User
Create data/users.yaml:
users:
- id: "admin-001"
email: "admin@localhost"
password_hash: "$2b$12$KIXxBt5H4vE2zT9vN8FqOe9JxwLxPqz0q5kYv2Z3j4RQvN8FqOe9J" # Password: "admin123"
name: "Admin User"
role: "admin"
assigned_product_ids: []
created_date: "2025-10-15"
last_login: null
Security Note: Change the password immediately after first login!
To generate a new password hash:
import bcrypt
password = "your-password-here"
hash = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(rounds=12))
print(hash.decode('utf-8'))
Running the Application
Development Server
python run.py
Application will be available at: http://localhost:5000
Production Server (Gunicorn)
gunicorn -w 4 -b 0.0.0.0:8000 "app:create_app()"
Project Structure Overview
reklamator/
├── app/ # Application code
│ ├── __init__.py # Flask app factory
│ ├── routes/ # HTTP endpoints
│ │ ├── submission.py # Anonymous feedback submission
│ │ ├── dashboard.py # Product owner dashboard
│ │ └── admin.py # Admin interface
│ ├── services/ # Business logic
│ │ ├── feedback_storage.py # File-based storage operations
│ │ ├── ai_analyzer.py # AI analysis/translation
│ │ └── auth.py # Authentication
│ ├── models/ # Domain models
│ │ ├── feedback.py # Feedback entity
│ │ ├── product.py # Product entity
│ │ └── user.py # User entity
│ ├── templates/ # HTML templates (Jinja2)
│ └── utils/ # Utilities
│ ├── file_validator.py # File upload validation
│ └── rate_limiter.py # Rate limiting
│
├── data/ # File-based storage
│ ├── users.yaml # User accounts
│ └── products/ # Product-specific data
│ └── {product-id}/
│ ├── config.yaml # Product metadata
│ └── feedback/
│ └── {feedback-id}/
│ ├── metadata.yaml
│ ├── content.txt
│ ├── analysis.md
│ └── attachments/
│
├── tests/ # Test suite
│ ├── contract/ # API contract tests
│ ├── integration/ # User journey tests
│ └── unit/ # Unit tests
│
├── config/ # Configuration files
│ ├── development.py
│ ├── production.py
│ └── testing.py
│
├── specs/ # Feature specifications (this directory)
├── requirements.txt
├── pytest.ini
├── .env # Environment variables (not in git)
└── run.py # Application entry point
Common Development Tasks
Creating a Test Product
-
Log in as admin: http://localhost:5000/login
- Email:
admin@localhost - Password:
admin123
- Email:
-
Navigate to: http://localhost:5000/admin/products
-
Click "Create New Product" and fill in:
- ID:
001-test-product - Name:
Test Product - Target Language:
en - Submission URL Slug:
test-product - Assign yourself as product owner
- ID:
-
Access submission form: http://localhost:5000/submit/test-product
Submitting Test Feedback
- Visit: http://localhost:5000/submit/test-product
- Enter feedback text
- Optionally attach files (max 3, max 10MB each)
- Submit
Feedback will be processed asynchronously. Check the dashboard to view analysis results.
Viewing Feedback in Dashboard
- Log in: http://localhost:5000/login
- Dashboard: http://localhost:5000/dashboard
- Click on feedback item to view details
Running Tests
All tests:
pytest
Contract tests only:
pytest tests/contract/
Integration tests only:
pytest tests/integration/
With coverage:
pytest --cov=app --cov-report=html
Test-first workflow (per constitution):
- Write test for new feature (should fail)
- Run test to verify failure
- Implement feature
- Run test to verify success
- Refactor if needed
Web Routes Reference
Anonymous Submission
GET /submit/{product_slug}- Submission formPOST /submit/{product_slug}- Submit feedback
Authentication
GET /login- Login formPOST /login- AuthenticateGET /logout- Log out
Dashboard (Product Owners)
GET /dashboard- Feedback list (with filters)GET /feedback/{feedback_id}- Feedback detailPOST /feedback/{feedback_id}/status- Update statusGET /feedback/{feedback_id}/attachment/{filename}- Download attachment
Admin
GET /admin/products- List productsGET /admin/products/new- Create product formPOST /admin/products- Create productGET /admin/products/{id}/edit- Edit product formPOST /admin/products/{id}- Update productPOST /admin/products/{id}/archive- Archive productGET /admin/users- List usersPOST /admin/users- Create userPOST /admin/users/{id}- Update user
Full API contracts: See /specs/001-build-an-application/contracts/
Configuration
Development Configuration (config/development.py)
DEBUG = True
TESTING = False
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key')
DATA_DIR = os.environ.get('DATA_DIR', './data')
ANTHROPIC_API_KEY = os.environ.get('ANTHROPIC_API_KEY')
CLAMD_SOCKET = os.environ.get('CLAMD_SOCKET', '/var/run/clamav/clamd.ctl')
MAX_CONTENT_LENGTH = 10 * 1024 * 1024 # 10MB max upload
RATE_LIMIT_ENABLED = True
RATE_LIMIT_PER_HOUR = 10
Production Configuration (config/production.py)
DEBUG = False
TESTING = False
SECRET_KEY = os.environ.get('SECRET_KEY') # Required, no default
DATA_DIR = os.environ.get('DATA_DIR', '/var/lib/reklamator/data')
ANTHROPIC_API_KEY = os.environ.get('ANTHROPIC_API_KEY') # Required
CLAMD_SOCKET = os.environ.get('CLAMD_SOCKET', '/var/run/clamav/clamd.ctl')
MAX_CONTENT_LENGTH = 10 * 1024 * 1024
RATE_LIMIT_ENABLED = True
RATE_LIMIT_PER_HOUR = 10
SESSION_COOKIE_SECURE = True # HTTPS only
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
Troubleshooting
ClamAV Connection Error
Error: pyclamd.ConnectionError: Could not connect to clamd
Solution:
- Verify ClamAV is running:
sudo systemctl status clamav-daemon - Check socket path:
ls /var/run/clamav/clamd.ctl - Update
CLAMD_SOCKETin.envif needed - Restart ClamAV:
sudo systemctl restart clamav-daemon
Claude API Error
Error: anthropic.APIError: Invalid API key
Solution:
- Verify API key in
.envfile - Check key is active at https://console.anthropic.com/
- Ensure no extra whitespace in key
File Upload Fails
Error: 413 Payload Too Large
Solution:
- Check file size (max 10MB per file)
- Check total payload size (3 files + form data)
- Verify
MAX_CONTENT_LENGTHin config
Error: Unsupported file type
Solution:
- Verify file extension:
.pdf,.docx,.txt,.jpg,.png,.gif,.webp - Check MIME type matches extension
Rate Limit Exceeded
Error: 429 Too Many Requests
Solution:
- Wait 1 hour before retrying
- For development, disable rate limiting:
RATE_LIMIT_ENABLED=falsein.env - Or increase limit:
RATE_LIMIT_PER_HOUR=100
Development Guidelines
Test-First Discipline (Constitutional Requirement)
-
Before implementing any feature:
- Write contract/integration test
- Run test to verify it fails
- Implement feature
- Run test to verify success
-
Test organization:
- Contract tests: Test API endpoints (HTTP requests/responses)
- Integration tests: Test user journeys (multi-step workflows)
- Unit tests: Test complex business logic in isolation
-
Example test-first workflow:
# Step 1: Write test (tests/contract/test_submission_api.py)
def test_submit_feedback_with_text_only(client):
response = client.post('/submit/test-product', data={
'feedback_text': 'This is test feedback'
})
assert response.status_code == 200
assert b'Thank You!' in response.data
# Step 2: Run test (should FAIL - endpoint not implemented)
# pytest tests/contract/test_submission_api.py::test_submit_feedback_with_text_only
# Step 3: Implement feature (app/routes/submission.py)
@bp.route('/submit/<product_slug>', methods=['POST'])
def submit_feedback(product_slug):
# Implementation here
pass
# Step 4: Run test again (should PASS)
# pytest tests/contract/test_submission_api.py::test_submit_feedback_with_text_only
Code Style
- Follow PEP 8
- Use type hints where helpful
- Keep functions small and focused
- Prefer clear names over comments
- Run linting:
flake8 app/ - Run formatting:
black app/
Git Workflow
- Feature branch:
001-build-an-application(already created) - Commit messages: Descriptive, imperative mood
- Test before committing
- Regular integration to main branch
Next Steps
- Set up environment following steps above
- Run tests to verify setup:
pytest - Start development server:
python run.py - Create test product via admin interface
- Submit test feedback via submission form
- Review implementation plan:
/specs/001-build-an-application/plan.md - Begin task implementation: Wait for
/specs/001-build-an-application/tasks.md(generated by/speckit.tasks)
Resources
- Feature Specification:
/specs/001-build-an-application/spec.md - Implementation Plan:
/specs/001-build-an-application/plan.md - Research:
/specs/001-build-an-application/research.md - Data Model:
/specs/001-build-an-application/data-model.md - API Contracts:
/specs/001-build-an-application/contracts/ - Flask Documentation: https://flask.palletsprojects.com/
- Claude API Documentation: https://docs.anthropic.com/
- Pytest Documentation: https://docs.pytest.org/
Questions? Refer to the specification documents or implementation plan for detailed requirements and design decisions.