# pulipati0443-web/audit-log-service architecture

> Architecture diagram of the GitHub repository pulipati0443-web/audit-log-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pulipati0443-web/audit-log-service
- Repository: https://github.com/pulipati0443-web/audit-log-service

## Overview

Audit Log Service is a FastAPI prototype for recording, querying, verifying, archiving, and exporting tamper-evident audit events. The principal workflow accepts an event, assigns its timestamp, hashes it into an append-only chain, and persists it; users can later query or verify that chain, archive records logically, or export filtered and optionally redacted bundles. The graph follows the sampled API, service, integrity, and SQLite code. Other README capabilities, including concurrent-write validation, are reflected where evidenced by the persistence implementation.

Main entry points: [`app/persistence/database.py`](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/persistence/database.py) (SQLite audit store), [`app/api/routes.py`](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/api/routes.py) (Audit routes), [`app/main.py`](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/main.py) (FastAPI application), [`app/services/audit_service.py`](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py) (Chain verification entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_application["FastAPI application<br/>[main.py]"]
  node_routes["Audit routes<br/>[routes.py]"]
end

subgraph group_services["Audit Services"]
  node_create["Event creation<br/>[audit_service.py]"]
  node_query["Filtered query<br/>[audit_service.py]"]
  node_chain_service["Chain verification entry<br/>[audit_service.py]"]
  node_export["Filtered export<br/>[export.py]"]
  node_redaction["Payload redaction<br/>[redaction.py]"]
end

subgraph group_integrity["Integrity"]
  node_verification["Chain verification<br/>[verification.py]"]
  node_hashing["Canonical hashing<br/>[hashing.py]"]
end

subgraph group_persistence["Persistence"]
  node_database[("SQLite audit store<br/>[database.py]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_application
node_application -->|"mounts router"| node_routes
node_application -->|"initializes schema"| node_database
node_routes -->|"creates event"| node_create
node_create -->|"persists event"| node_database
node_database -->|"hashes records"| node_hashing
node_routes -->|"queries events"| node_query
node_query -->|"reads records"| node_database
node_routes -->|"requests verification"| node_chain_service
node_chain_service -->|"loads records"| node_database
node_chain_service -->|"checks chain"| node_verification
node_verification -->|"recomputes hashes"| node_hashing
node_routes -->|"archives event"| node_database
node_routes -->|"requests export"| node_export
node_export -->|"reads records"| node_database
node_export -->|"redacts payload"| node_redaction

click node_application "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/main.py"
click node_routes "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/api/routes.py"
click node_create "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py"
click node_query "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py"
click node_chain_service "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py"
click node_export "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/export.py"
click node_redaction "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/redaction.py"
click node_verification "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/integrity/verification.py"
click node_hashing "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/integrity/hashing.py"
click node_database "https://github.com/pulipati0443-web/audit-log-service/blob/main/app/persistence/database.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_routes,node_client toneBlue
class node_create,node_query,node_chain_service,node_export,node_redaction toneAmber
class node_verification,node_hashing toneMint
class node_database toneRose
```

## Components

### HTTP API

- [FastAPI application](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/main.py): `app/main.py`
- [Audit routes](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/api/routes.py): `app/api/routes.py`

### Audit Services

- [Event creation](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py): `app/services/audit_service.py`
- [Filtered query](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py): `app/services/audit_service.py`
- [Chain verification entry](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/audit_service.py): `app/services/audit_service.py`
- [Filtered export](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/export.py): `app/services/export.py`
- [Payload redaction](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/services/redaction.py): `app/services/redaction.py`

### Integrity

- [Chain verification](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/integrity/verification.py): `app/integrity/verification.py`
- [Canonical hashing](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/integrity/hashing.py): `app/integrity/hashing.py`

### Persistence

- [SQLite audit store](https://github.com/pulipati0443-web/audit-log-service/blob/main/app/persistence/database.py): `app/persistence/database.py`

### Other components

- **API client**

## Connections

- API client → FastAPI application: sends requests
- FastAPI application → Audit routes: mounts router
- FastAPI application → SQLite audit store: initializes schema
- Audit routes → Event creation: creates event
- Event creation → SQLite audit store: persists event
- SQLite audit store → Canonical hashing: hashes records
- Audit routes → Filtered query: queries events
- Filtered query → SQLite audit store: reads records
- Audit routes → Chain verification entry: requests verification
- Chain verification entry → SQLite audit store: loads records
- Chain verification entry → Chain verification: checks chain
- Chain verification → Canonical hashing: recomputes hashes
- Audit routes → SQLite audit store: archives event
- Audit routes → Filtered export: requests export
- Filtered export → SQLite audit store: reads records
- Filtered export → Payload redaction: redacts payload
