AuditLogX 🔐
Append-Only Centralized Audit Logging Service
AuditLogX is a backend service that records who did what and when across systems. It is designed to model real production audit logging systems used in banking, admin dashboards, and compliance-driven environments (SOC2, GDPR, ISO 27001).
The core goal is immutability, traceability, and correctness, not just CRUD.
✨ Key Features
Append-only audit logs
Database-level enforcement (no UPDATE / DELETE)
Centralized ingestion
Single API for logging user/system actions
Queryable audit trail
Filter by actor, action, and time
Compliance-ready design
Immutable history
Indexed access
Production-style setup
Dockerized services
Alembic migrations
Async FastAPI + PostgreSQL
🧠 Why AuditLogX?
Audit logs are security-critical:
They must not be altered
They must be queryable under pressure
They must survive application bugs
AuditLogX enforces these guarantees at the database layer, not just in application code.
🏗️ Architecture Client / Service | | POST /audit-log v FastAPI (Async) | | SQLAlchemy (async) v PostgreSQL ├─ audit_logs table (append-only) ├─ indexes (actor_id, action, timestamp) └─ trigger blocking UPDATE / DELETE
🧱 Tech Stack
Language: Python 3.11
Framework: FastAPI
Database: PostgreSQL
ORM: SQLAlchemy (async)
Migrations: Alembic
Infra: Docker, Docker Compose
📁 Project Structure auditlogx/ ├── app/ │ ├── main.py # FastAPI app startup │ ├── routes.py # API endpoints │ ├── crud.py # DB operations │ ├── models.py # SQLAlchemy models │ ├── schemas.py # Pydantic schemas │ └── database.py # Async DB setup │ ├── alembic/ │ ├── env.py │ └── versions/ │ └── 0001_create_audit_logs_table.py │ ├── docker-compose.yml ├── Dockerfile ├── alembic.ini ├── requirements.txt └── README.md
🗄️ Database Design audit_logs (append-only) Column Type Purpose id UUID / INT Primary key actor_id TEXT User / service identifier actor_type TEXT user / system / service action TEXT Action performed resource TEXT Target resource metadata JSONB Flexible event data timestamp TIMESTAMPTZ Set by DB Immutability Enforcement
PostgreSQL trigger blocks all:
UPDATE
DELETE
Even compromised application code cannot alter logs
⚙️ Getting Started (Docker) Prerequisites
Docker Desktop