# Tech Stack

## Purpose
Document the concrete technologies and dependencies in use across backend and frontend as defined in the repository.

## Code Locations (exact paths)
- Backend dependency manifest: `backend/requirements.txt`
- Backend settings (framework integration): `backend/igny8_core/settings.py`
- Frontend dependency manifest: `frontend/package.json`
- Frontend build tooling: `frontend/vite.config.ts`, `frontend/tsconfig*.json`

## High-Level Responsibilities
- Backend: Django 5.x with DRF for APIs, Celery for async tasks, Redis for broker/result, PostgreSQL or SQLite for data, drf-spectacular for OpenAPI, Stripe/PayPal configs for billing, WhiteNoise for static serving.
- Frontend: React 19 with Vite, TypeScript, TailwindCSS, Zustand state, React Router 7, ApexCharts and FullCalendar for UI widgets.

## Detailed Behavior
- Backend settings wire DRF pagination, filters, authentication (API key, JWT, session, basic), throttling, schema generation, CORS, Celery, logging, and Stripe/PayPal credentials. Static assets are served via WhiteNoise; admin uses Django contrib.
- `requirements.txt` enumerates runtime libs: Django, gunicorn, psycopg2-binary (PostgreSQL), redis, WhiteNoise, DRF, django-filter, django-cors-headers, PyJWT, requests, Celery, BeautifulSoup4, psutil, docker (for ops scripts), drf-spectacular, and stripe.
- Frontend `package.json` pins React 19, React Router 7, Zustand 5, Vite 6, TailwindCSS 4, ApexCharts 4, FullCalendar 6, react-dnd, dropzone, lucide/react-heroicons, and testing/tooling (Vitest, Testing Library, ESLint).
- Build scripts use Vite for dev and production builds, with separate marketing mode; tests via Vitest; lint via ESLint; type-check via `tsc -b`.

## Data Structures / Models Involved (no code)
- Not applicable; this file tracks technology components rather than domain models.

## Execution Flow
- Backend runs under Django/DRF with middleware and installed apps per `settings.py`. ASGI/WSGI entrypoints in `igny8_core/asgi.py` and `igny8_core/wsgi.py` (default WSGI via gunicorn).
- Celery worker/beat use Redis URLs from `settings.py` and respect JSON serialization/time limits.
- Frontend builds with Vite, consuming environment variables defined via Vite conventions.

## Cross-Module Interactions
- DRF auth classes depend on PyJWT and custom utilities for token handling.
- Celery tasks in AI/automation/publishing rely on Redis connectivity and the configured serializer/time limits.
- Stripe/PayPal keys in settings are consumed by billing modules.
- Frontend API calls rely on the DRF endpoints exposed in `igny8_core/urls.py`.

## State Transitions (if applicable)
- Dependency-driven: none beyond the build/runtime phases (install → build → serve).

## Error Handling
- Backend error handling configured via custom DRF exception handler (enabled by default) and logging setup in `settings.py`.
- Frontend build/test errors are surfaced through Vite/TypeScript/Vitest/ESLint tooling.

## Tenancy Rules
- Implemented at runtime by backend middleware and viewsets; the tech stack provides JWT, session, and API key support to carry tenant context.

## Billing Rules (if applicable)
- Stripe and PayPal keys in `settings.py` enable billing integrations; credit logic is implemented in billing modules (documented elsewhere).

## Background Tasks / Schedulers (if applicable)
- Celery configured in `settings.py` with Redis broker/backend, JSON serialization, and task limits; beat scheduling persists in `celerybeat-schedule`.

## Key Design Considerations
- Keep dependency manifests authoritative (`requirements.txt`, `package.json`).
- Redis is the default async backbone; Postgres is the default DB with SQLite fallback for local/dev.
- Vite + React 19 selected for fast dev/build; TailwindCSS 4 used for styling; Zustand for state.

## How Developers Should Work With This Module
- Add backend dependencies to `requirements.txt` and pin versions appropriately; update settings if new middleware/auth is added.
- Add frontend dependencies to `package.json`; run `npm install` and ensure Vite/TSC builds remain clean.
- Respect configured auth stack (API key → JWT → session) when adding API clients.
- Keep CORS and env vars aligned with the domains/ports in use for local and production.
