Guide for new developers joining the project. This document covers setup, project structure, development workflow, and common tasks.
- Prerequisites
- Initial Setup
- Project Structure
- Development Workflow
- Key Concepts
- Common Tasks
- Debugging
- Getting Help
- Next Steps
Before you begin, ensure you have the following installed:
- Python 3.10+: Download Python
- PostgreSQL 12+: Download PostgreSQL
- Redis: Download Redis
- Git: Download Git
git clone https://github.com/sunr4y/fkapi.git
cd fkapipython -m venv venv
# On Windows
venv\Scripts\activate
# On Linux/Mac
source venv/bin/activate# Install production dependencies
pip install -r fkapi/requirements.txt
# Install development dependencies
pip install -r fkapi/requirements-dev.txtCreate a .env file in the project root:
# Django Settings
DJANGO_SECRET_KEY=your-secret-key-here
DJANGO_DEBUG=True
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/fkapi
# Redis
REDIS_URL=redis://localhost:6379/1
# Optional: API Authentication
DJANGO_API_ENABLE_AUTH=False
API_RATE_LIMIT_RATE=100/hour# Create database
createdb fkapi
# Run migrations
cd fkapi
python manage.py migratepython manage.py createsuperuserpython manage.py runserverThe API will be available at http://localhost:8000/api/
fkapi/
├── core/ # Main application code
│ ├── models.py # Database models
│ ├── views.py # Django views
│ ├── api.py # API endpoints (Django Ninja)
│ ├── scrapers.py # Web scraping logic
│ ├── parsers.py # HTML parsing
│ ├── services/ # Business logic layer
│ │ ├── kits_service.py
│ │ ├── clubs_service.py
│ │ └── scraping_service.py
│ ├── middleware.py # Custom middleware
│ ├── cache_utils.py # Cache utilities
│ └── tests/ # Test files
├── fkapi/ # Django project settings
│ ├── settings.py # Main settings
│ ├── urls.py # URL routing
│ └── api.py # API configuration
├── docs/ # Documentation
├── requirements.txt # Production dependencies
└── requirements-dev.txt # Development dependencies
# Run all tests
pytest
# Run specific test file
pytest fkapi/core/tests/test_api.py
# Run with coverage
pytest --cov=fkapi/core --cov-report=html# Check code style
ruff check .
# Auto-fix issues
ruff check --fix .
# Format code
ruff format .# Run migrations
python manage.py migrate
# Create migrations
python manage.py makemigrations
# Note: We do not serve static files
# Images are stored as URLs pointing to footballkitarchive.com
# Run scraping command
python manage.py scrape_brand adidas
# Warm cache
python manage.py warm_cacheBusiness logic is separated into service classes:
KitsService: Handles kit-related operationsClubsService: Handles club-related operationsScrapingService: Orchestrates scraping operations
- Redis is used for caching API responses
- Cache keys follow patterns:
{type}_{id},search_{type}_{keyword} - Cache invalidation happens automatically via Django signals
All API endpoints are defined in fkapi/fkapi/api.py using Django Ninja.
See docs/api/endpoint-catalog.md for complete API documentation.
- Tests are located in
fkapi/core/tests/ - Use pytest fixtures for test data
- Test coverage is tracked with pytest-cov
- Add endpoint function in
fkapi/fkapi/api.py:
@api.get("/my-endpoint")
def my_endpoint(request: HttpRequest):
return {"message": "Hello"}- Add tests in
fkapi/core/tests/test_api.py - Update
docs/api/endpoint-catalog.md
- Define model in
fkapi/core/models.py - Create migration:
python manage.py makemigrations - Run migration:
python manage.py migrate - Add to admin in
fkapi/core/admin.py(if needed) - Add tests in
fkapi/core/tests/test_models.py
- Add signal handler in
fkapi/core/cache_utils.py - Connect signal in
fkapi/core/apps.py - Test cache invalidation
Set DJANGO_DEBUG=True in .env file.
Logs are written to:
fkapi/api.log: General application logsfkapi/logs/performance.log: Performance monitoring logs
Enable query logging in settings.py:
LOGGING = {
'loggers': {
'django.db.backends': {
'level': 'DEBUG',
},
},
}- Documentation: Check
docs/directory - API Docs: Visit
http://localhost:8000/api/docswhen server is running - Issues: Check GitHub issues
- Code Review: Follow existing code patterns
- Read
docs/architecture.mdfor system overview - Review
docs/api/endpoint-catalog.mdfor API reference - Explore existing code in
fkapi/core/ - Run tests to understand test patterns
- Make your first contribution!
- Always run tests before committing
- Use type hints for better code clarity
- Follow existing code style (Ruff will help)
- Write docstrings for new functions/classes
- Update documentation when adding features
Last Updated: 2026-01-17 Maintained by: sunr4y