Raven Zero Logo RAVEN ZERO

Development

🏗️ Design Patterns

1. Dependency Injection (FastAPI Depends)

async def get_redis() -> Redis:
    return redis_client

@app.post("/upload")
async def upload(redis: Redis = Depends(get_redis)):
    # Redis injected automatically

Benefits: Testable, reusable, clean code.

2. Repository Pattern (Storage Module)

class FileRepository(ABC):
    async def save(self, content: bytes, path: Path) -> bool: ...
    async def delete(self, path: Path) -> bool: ...

class LocalFileRepository(FileRepository):
    # Implementation with secure shredding

Benefits: Easy to swap implementations (filesystem → S3).

3. Strategy Pattern (Validators)

class FileValidator(ABC):
    async def validate(self, content, metadata) -> tuple[bool, str]: ...

class FileSizeValidator(FileValidator): ...
class FileMimeTypeValidator(FileValidator): ...

Benefits: Composable validation rules.

4. Middleware Pattern

app.add_middleware(SecurityHeadersMiddleware)
app.add_middleware(BaseHTTPMiddleware, dispatch=logging_middleware)

Benefits: Cross-cutting concerns separated from routes.


📝 Naming Conventions

ContextFormatExample
Product nameTitle CaseRaven Zero
Repositorykebab-caseraven-zero
Python packagesnake_caseraven_zero
Docker imagekebab-caseraven-zero:latest
Environment varsUPPER_SNAKEREDIS_URL
Redis keyscolon-separatedupload:key:uses
File pathssnake_casestorage/uploads/

🔧 Development Workflow

Setup

# Clone repository
git clone https://github.com/your-username/raven-zero.git
cd raven-zero

# Install dependencies
uv sync

# Copy environment file
cp .env.example .env

# Start services
docker compose up -d

Code Quality

# Format code
uv run ruff format .

# Lint code
uv run ruff check .

# Auto-fix lints
uv run ruff check --fix .

Run Locally

# Development server
uv run fastapi dev app/main.py

# Production mode
uv run fastapi run app/main.py

📦 Dependencies

Production

  • fastapi
  • uvicorn[standard]
  • redis (async)
  • python-multipart
  • pydantic-settings
  • python-magic
  • cryptography
  • structlog
  • apscheduler
  • aiofiles
  • slowapi
  • scalar-fastapi

Development

  • pytest
  • pytest-asyncio
  • pytest-cov
  • httpx
  • fakeredis
  • ruff