An open API service indexing awesome lists of open source software.

https://github.com/manziosee/auditshield

Keep your business audit-ready anywhere in the world. Manage employees, encrypted documents, payroll, and regulatory obligations in one secure multi-tenant SaaS.
https://github.com/manziosee/auditshield

angular angular-material apollo-angular apollographql celery django-rest-framework fernet-encryption jwt-authentication postgresql pymupdf redis scss strawberry-graphql tesseract typescript weasyprint

Last synced: 17 days ago
JSON representation

Keep your business audit-ready anywhere in the world. Manage employees, encrypted documents, payroll, and regulatory obligations in one secure multi-tenant SaaS.

Awesome Lists containing this project

README

          


AuditShield Logo




# πŸ›‘οΈ AuditShield

### **The Global SME Compliance Platform**

> _Keep your business audit-ready β€” anywhere in the world._
> Manage employees, encrypted documents, payroll, and regulatory obligations in one secure multi-tenant SaaS.


[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Deployed on Fly.io](https://img.shields.io/badge/Deployed%20on-Fly.io-8b5cf6?logo=flydotio&logoColor=white)](https://fly.io)


---

### πŸ”§ Built With


**Backend**

![Python](https://img.shields.io/badge/Python_3.12-3776AB?style=for-the-badge&logo=python&logoColor=white)
![Django](https://img.shields.io/badge/Django_5-092E20?style=for-the-badge&logo=django&logoColor=white)
![DRF](https://img.shields.io/badge/Django_REST_Framework-a30000?style=for-the-badge&logo=django&logoColor=white)
![GraphQL](https://img.shields.io/badge/Strawberry_GraphQL-E10098?style=for-the-badge&logo=graphql&logoColor=white)

**Database & Cache**

![PostgreSQL](https://img.shields.io/badge/PostgreSQL_16-4169E1?style=for-the-badge&logo=postgresql&logoColor=white)
![SQLite](https://img.shields.io/badge/SQLite-003B57?style=for-the-badge&logo=sqlite&logoColor=white)
![Redis](https://img.shields.io/badge/Redis_7-DC382D?style=for-the-badge&logo=redis&logoColor=white)
![Celery](https://img.shields.io/badge/Celery-37814A?style=for-the-badge&logo=celery&logoColor=white)

**Frontend**

![Angular](https://img.shields.io/badge/Angular_18-DD0031?style=for-the-badge&logo=angular&logoColor=white)
![TypeScript](https://img.shields.io/badge/TypeScript_5-3178C6?style=for-the-badge&logo=typescript&logoColor=white)
![Angular Material](https://img.shields.io/badge/Angular_Material-757575?style=for-the-badge&logo=materialdesign&logoColor=white)
![Apollo](https://img.shields.io/badge/Apollo_Client-311C87?style=for-the-badge&logo=apollographql&logoColor=white)

**Infrastructure**

![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white)
![Nginx](https://img.shields.io/badge/Nginx-009639?style=for-the-badge&logo=nginx&logoColor=white)
![GitHub Actions](https://img.shields.io/badge/GitHub_Actions-2088FF?style=for-the-badge&logo=githubactions&logoColor=white)
![Fly.io](https://img.shields.io/badge/Fly.io-8b5cf6?style=for-the-badge&logo=flydotio&logoColor=white)


---

## What is AuditShield?

**AuditShield** is a **multi-tenant SaaS compliance platform** built for small and medium enterprises (SMEs) operating across multiple countries. It centralises everything an SME needs to stay audit-ready:

- πŸ“‹ **Employee records** β€” full lifecycle management with department hierarchy
- πŸ”’ **Encrypted document vault** β€” AES-128 Fernet encryption at rest, OCR text extraction, expiry alerts
- βœ… **Compliance tracker** β€” tax, social security, and labour law obligations mapped to global authorities
- πŸ’° **Payroll engine** β€” country-specific tax rules, payroll runs, and payslip generation
- πŸ“„ **PDF report generation** β€” async via Celery + WeasyPrint, download when ready
- 🌍 **Multi-country** β€” 16+ countries, 17+ currencies, global authority mapping
- πŸ” **Immutable audit trail** β€” every write recorded automatically by middleware
- πŸ”” **Notifications** β€” in-app + email with unread badge and mark-all-read
- πŸ”— **Dual API** β€” REST (DRF + Swagger) **and** GraphQL (Strawberry + Apollo)

Every company is a **fully isolated tenant** with UUID-keyed records and scoped row-level queries. No data leaks across tenants β€” ever.

---

## Table of Contents

- [Features](#features)
- [Innovation Features](#innovation-features)
- [Tech Stack](#tech-stack)
- [Architecture](#architecture)
- [Quick Start (Docker)](#quick-start-docker)
- [Local Development (without Docker)](#local-development-without-docker)
- [Environment Variables](#environment-variables)
- [API Documentation](#api-documentation)
- [New API Endpoints](#new-api-endpoints)
- [Deployment β€” Fly.io](#deployment--flyio)
- [Deployment β€” Docker Compose Production](#deployment--docker-compose-production)
- [User Roles](#user-roles)
- [Project Structure](#project-structure)
- [Makefile Commands](#makefile-commands)
- [License](#license)

---

## Features

### Core Platform

| 🏷️ Area | ✨ Capabilities |
|---------|----------------|
| 🏒 **Multi-tenancy** | Each company is a fully isolated tenant β€” UUID PKs, cascading row-level scoping |
| πŸ‘₯ **Employees** | Full CRUD, department management, bulk Excel/CSV import, one-click export, risk scoring |
| πŸ”’ **Documents** | Fernet AES-128 encryption at rest, OCR extraction, version control, expiry tracking & email alerts |
| πŸ€– **AI Extraction** | OCR auto-extracts employee name, salary, start/end dates from uploaded contracts |
| βœ… **Compliance** | Tax, social security & labour law tracker; authority dashboards; full CRUD; bulk updates |
| 🧠 **Health Pulse** | Rolling 6-month compliance trend + 30-day AI risk prediction |
| πŸ” **Gap Analysis** | Auto-detects missing requirements vs your country + industry |
| πŸ“… **Deadline Calendar** | Monthly calendar view of all compliance deadlines with iCal export |
| πŸ‘€ **Self-Service Portal** | Employees see only their own payslips, documents, and compliance status |
| πŸ“Š **Reports** | Async PDF generation (WeasyPrint + Celery); scheduled delivery via email |
| πŸ’° **Payroll** | Country-specific tax rule engine, payroll runs, payslip generation, variance alerts |
| 🌍 **Geography** | 16+ countries, 17+ currencies, live exchange rate support |
| πŸ”‘ **Auth** | JWT rotate-on-refresh, Argon2 hashing, brute-force lockout (django-axes) |
| πŸ“œ **Audit Trail** | Immutable middleware log of every POST/PUT/PATCH/DELETE; CSV/PDF export |
| πŸ”” **Notifications** | In-app + email alerts, unread badge, mark-all-read |
| πŸ›οΈ **Portfolio** | Super-admin sees all tenant companies with live compliance scores |
| πŸ”— **Webhooks** | Outbound HMAC-signed webhooks for all platform events |
| πŸ”— **GraphQL** | Strawberry endpoint β€” Apollo-compatible at `/graphql/` |
| πŸ“– **REST API** | Full DRF REST API with OpenAPI/Swagger docs at `/api/docs/` |

### New Features (v2)

| 🏷️ Area | ✨ Capabilities |
|---------|----------------|
| ✍️ **E-Signatures** | Request legally-binding document signatures from employees; track signing status per signer |
| πŸš€ **Onboarding** | Configurable onboarding checklists with task types (document, form, training, sign); progress tracking |
| πŸŽ“ **Training & Certifications** | Track employee certifications with validity periods, expiry alerts, and compliance reports |
| πŸ“‹ **Policy Management** | Version-controlled policies with mandatory employee acknowledgment tracking and audit trail |
| 🚨 **Incident Log** | Report and investigate compliance violations, data breaches, and safety incidents; update trail |
| βœ… **Approval Workflows** | Configurable multi-step approval chains for documents, expenses, leave; full audit trail |
| 🏭 **Vendor Compliance** | Vendor registry with compliance scores, insurance tracking, contract expiry monitoring |
| πŸ“ **Custom Forms** | Drag-and-drop form builder; collect employee and vendor data with structured field types |
| 🀝 **Partner / White-Label** | Partner portal with custom branding, sub-company management, revenue dashboards |
| πŸ”Œ **Integration Hub** | Connect QuickBooks, Xero, BambooHR, Slack, Google Workspace via OAuth; sync status & logs |
| πŸ“Š **Employee Risk Scores** | Composite risk scoring per employee based on document status, training gaps, compliance history |
| πŸ“… **Scheduled Reports** | Schedule PDF reports for automatic email delivery (daily/weekly/monthly) |
| πŸ” **Audit Prep Assistant** | Step-by-step audit readiness checklist with live progress score per regulatory framework |
| πŸ“± **Mobile PWA** | Progressive Web App β€” installable on iOS/Android, offline capability, responsive design |

---

## Innovation Features

### 🧠 Compliance Health Pulse
`GET /api/v1/compliance/health-pulse/`

Returns rolling 6-month history + linear regression prediction:
```json
{
"current_score": 78,
"trend": "improving",
"predicted_30d": 83,
"risk_level": "moderate",
"days_to_threshold": null,
"history": [
{"month": "2025-10", "score": 65},
{"month": "2025-11", "score": 70},
{"month": "2025-12", "score": 72},
{"month": "2026-01", "score": 74},
{"month": "2026-02", "score": 76},
{"month": "2026-03", "score": 78}
]
}
```

### πŸ” Compliance Gap Analysis
`GET /api/v1/compliance/gap-analysis/`

Compares your company's tracked requirements against the global requirement library for your country + industry. Returns prioritised list of missing requirements:
```json
{
"total_gaps": 4,
"coverage_percent": 76,
"gaps": [
{
"requirement_id": "...",
"title": "Annual Tax Return Filing",
"authority": "IRS",
"priority": "high",
"is_mandatory": true,
"frequency": "annually"
}
]
}
```

### ⚠️ Payroll Variance Check
`POST /api/v1/payroll/runs/{id}/variance-check/`

Compares current run against the previous completed run. Flags salary spikes >15%, missing employees, and new additions.

### πŸ“€ Audit Trail Export
`GET /api/v1/audit-logs/export/?format=csv&date_from=2026-01-01&date_to=2026-03-31`

Downloads the audit trail as CSV (or JSON) for external auditors. Supports date range, method, and status filters.

### πŸ›οΈ Portfolio Dashboard
`GET /api/v1/companies/portfolio/` _(super_admin only)_

Returns all tenant companies with live compliance scores, employee counts, and last activity β€” for accounting firms managing multiple clients.

### πŸ”— Webhooks
`/api/v1/webhooks/` β€” Full CRUD for webhook endpoints.

Configure outbound HTTP webhooks for platform events:
- `employee.created` / `employee.updated`
- `payroll.run.completed`
- `document.expired` / `document.expiring_soon`
- `compliance.overdue`

All deliveries are HMAC-SHA256 signed with `X-AuditShield-Signature` header. Automatic retry on failure.

---

## Tech Stack

### 🐍 Backend

| Technology | Version | Purpose |
|-----------|:-------:|---------|
| ![Python](https://img.shields.io/badge/-Python-3776AB?logo=python&logoColor=white) **Python** | 3.12 | Runtime |
| ![Django](https://img.shields.io/badge/-Django-092E20?logo=django&logoColor=white) **Django** | 5.0 | Web framework |
| ![DRF](https://img.shields.io/badge/-DRF-a30000?logo=django&logoColor=white) **Django REST Framework** | 3.15 | REST API |
| ![Strawberry](https://img.shields.io/badge/-Strawberry_GraphQL-E10098?logo=graphql&logoColor=white) **Strawberry GraphQL** | 0.236 | GraphQL (Apollo-compatible) |
| ![PostgreSQL](https://img.shields.io/badge/-PostgreSQL-4169E1?logo=postgresql&logoColor=white) **PostgreSQL** | 16 | Primary database (Docker / self-hosted) |
| ![SQLite](https://img.shields.io/badge/-SQLite-003B57?logo=sqlite&logoColor=white) **SQLite** | 3 | Lightweight DB (Fly.io / CI) |
| ![Redis](https://img.shields.io/badge/-Redis-DC382D?logo=redis&logoColor=white) **Redis** | 7 | Celery message broker + cache |
| ![Celery](https://img.shields.io/badge/-Celery-37814A?logo=celery&logoColor=white) **Celery** + Beat | 5.3 | Async task queue + scheduler |
| **Gunicorn** gthread | β€” | Production WSGI server |
| **drf-spectacular** | 0.27 | Auto OpenAPI / Swagger docs |
| **WeasyPrint** | 61 | PDF report generation |
| **pytesseract** | 0.3 | OCR text extraction from documents |
| **cryptography** (Fernet) | 42 | AES-128 file encryption at rest |
| **django-axes** | 6.4 | Brute-force login protection |
| **Argon2** | β€” | Strongest password hashing |

### πŸ…°οΈ Frontend

| Technology | Version | Purpose |
|-----------|:-------:|---------|
| ![Angular](https://img.shields.io/badge/-Angular-DD0031?logo=angular&logoColor=white) **Angular** | 18 | SPA framework β€” standalone components + signals |
| ![TypeScript](https://img.shields.io/badge/-TypeScript-3178C6?logo=typescript&logoColor=white) **TypeScript** | 5 | Strict type-safe development |
| ![Material](https://img.shields.io/badge/-Angular_Material-757575?logo=materialdesign&logoColor=white) **Angular Material** | 18 | UI component library |
| ![Apollo](https://img.shields.io/badge/-Apollo_Angular-311C87?logo=apollographql&logoColor=white) **Apollo Angular** | 7 | GraphQL client |
| **RxJS** | 7 | Reactive streams & observables |

### πŸ—οΈ Infrastructure

| Technology | Purpose |
|-----------|---------|
| ![Docker](https://img.shields.io/badge/-Docker-2496ED?logo=docker&logoColor=white) **Docker Compose** | Dev (7 services) + Production stacks |
| ![Nginx](https://img.shields.io/badge/-Nginx-009639?logo=nginx&logoColor=white) **Nginx** | Reverse proxy, SSL termination, static serving |
| ![Fly.io](https://img.shields.io/badge/-Fly.io-8b5cf6?logo=flydotio&logoColor=white) **Fly.io** | Backend cloud deployment with persistent volume |
| ![GitHub Actions](https://img.shields.io/badge/-GitHub_Actions-2088FF?logo=githubactions&logoColor=white) **GitHub Actions** | CI/CD β€” lint, test, coverage, auto-deploy |

---

## Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ User's Browser β”‚
β”‚ Angular 18 SPA (TypeScript + Signals) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ HTTPS
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Nginx :80/:443 β”‚
β”‚ /api/v1/* β†’ Django β”‚
β”‚ /graphql/ β†’ Django β”‚
β”‚ /* β†’ Angular β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Django 5 + DRF + Strawberry GQL β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ JWT Auth β”‚ Tenant β”‚ AuditLog β”‚ β”‚
β”‚ β”‚ middlewareβ”‚ scoping β”‚ middleware β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ REST API ──── GraphQL API β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
β”‚ PostgreSQL 16 β”‚ β”‚ Redis 7 β”‚
β”‚ (app data) β”‚ β”‚ broker + cache β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Celery Workers + Beat β”‚
β”‚ πŸ“„ OCR Β· πŸ“Š PDF reports β”‚
β”‚ πŸ“§ Emails Β· πŸ’Ύ Backups β”‚
β”‚ πŸ”” Reminders Β· 🧹 Cleanup β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

---

## Quick Start (Docker)

> **Prerequisites**: Docker Desktop β‰₯ 24 with the Compose v2 plugin

```bash
# 1. Clone
git clone https://github.com/manziosee/auditshield.git
cd auditshield

# 2. Environment file
cp .env.example .env

# 3. Generate required secret keys
make gen-secret # β†’ paste as DJANGO_SECRET_KEY in .env
make gen-fernet # β†’ paste as FILE_ENCRYPTION_KEY in .env

# Also set DATABASE_URL in .env:
# DATABASE_URL=postgresql://auditshield:auditshield@db:5432/auditshield

# 4. Start the full stack (PostgreSQL + Redis + Django + Celery + Angular + Nginx)
make dev

# 5. Create your admin user
make createsuperuser

# 6. (Optional) Seed realistic demo data across all 18 modules
docker compose exec backend python manage.py seed_demo_data
# Login: admin@technova.com / Demo@12345

# 7. Open the app πŸŽ‰
```

| Service | URL |
|---------|-----|
| 🌐 **Frontend** | http://localhost:4200 |
| πŸ”Œ **API** | http://localhost:8000/api/v1/ |
| πŸ“– **Swagger UI** | http://localhost:8000/api/docs/ |
| πŸ”— **GraphiQL** | http://localhost:8000/graphql/ |
| 🌸 **Flower (Celery)** | http://localhost:5555 |

### Demo Credentials

After running `seed_demo_data`:

| Role | Email | Password |
|------|-------|----------|
| Admin | admin@technova.com | Demo@12345 |
| HR | hr@technova.com | Demo@12345 |
| Accountant | accountant@technova.com | Demo@12345 |
| Auditor | auditor@technova.com | Demo@12345 |
| Employee | emp1@technova.com | Demo@12345 |

---

## Local Development (without Docker)

### Backend

```bash
cd backend
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements/development.txt

# In .env: set TURSO_DATABASE_URL=file:db.sqlite3 (remove DATABASE_URL line)
python manage.py migrate
python manage.py seed_global_data # loads countries, currencies, authorities
python manage.py createsuperuser
python manage.py runserver # β†’ http://localhost:8000
```

### Frontend

```bash
cd frontend
npm install
npm start # β†’ http://localhost:4200
```

### Celery (optional β€” needed for PDF gen, OCR, email)

```bash
cd backend
celery -A auditshield worker --loglevel=info -Q default,documents,reports,notifications
celery -A auditshield beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
```

---

## Environment Variables

| Variable | Required | Description |
|----------|:--------:|-------------|
| `DJANGO_SECRET_KEY` | βœ… | Django secret key (50+ chars) |
| `FILE_ENCRYPTION_KEY` | βœ… | Fernet key β€” document encryption at rest |
| `DATABASE_URL` | 🐳 Docker | PostgreSQL `postgresql://user:pass@host/db` |
| `TURSO_DATABASE_URL` | ✈️ Fly.io/CI | SQLite `file:db.sqlite3` |
| `REDIS_URL` | βœ… | `redis://:password@host:6379/0` |
| `CELERY_BROKER_URL` | βœ… | Celery broker (Redis) |
| `DJANGO_ALLOWED_HOSTS` | πŸš€ Prod | Comma-separated hostnames |
| `CORS_ALLOWED_ORIGINS` | πŸš€ Prod | Comma-separated frontend origins |
| `EMAIL_HOST_USER` | optional | SMTP username |
| `EMAIL_HOST_PASSWORD` | optional | SMTP app password |
| `SENTRY_DSN` | optional | Sentry error tracking |
| `DB_NAME / DB_USER / DB_PASSWORD` | 🐳 Docker | PostgreSQL credentials |

---

## API Documentation

> All endpoints require `Authorization: Bearer ` except `/health/`, `/auth/register/`, `/auth/login/`.

### Login

```http
POST /api/v1/auth/login/
Content-Type: application/json

{ "email": "admin@company.com", "password": "yourpassword" }
```

### Key Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/health/` | Health check β€” no auth |
| `POST` | `/api/v1/auth/register/` | Register company + admin |
| `POST` | `/api/v1/auth/login/` | Obtain JWT tokens |
| `GET/PATCH` | `/api/v1/companies/me/` | Company profile |
| `GET` | `/api/v1/companies/export/` | Export all company data |
| `GET/POST` | `/api/v1/employees/` | List / create employees |
| `GET/PATCH/DELETE` | `/api/v1/employees/{id}/` | Employee detail |
| `POST` | `/api/v1/employees/bulk-import/` | Import from Excel/CSV |
| `GET/POST` | `/api/v1/employees/departments/` | List / create departments |
| `GET/POST` | `/api/v1/documents/` | List / upload documents |
| `GET` | `/api/v1/documents/{id}/download/` | Download decrypted file |
| `DELETE` | `/api/v1/documents/{id}/` | Delete document |
| `GET` | `/api/v1/compliance/dashboard/` | Compliance score + stats |
| `GET/POST` | `/api/v1/compliance/records/` | List / create records |
| `PATCH/DELETE` | `/api/v1/compliance/records/{id}/` | Update / delete record |
| `GET` | `/api/v1/reports/` | List reports |
| `POST` | `/api/v1/reports/` | Generate report (async) |
| `POST` | `/api/v1/notifications/mark-all-read/` | Mark all read |
| `GET` | `/api/v1/notifications/unread-count/` | Unread count |
| `GET` | `/api/v1/audit-logs/` | Audit trail |
| `GET` | `/api/v1/geo/countries/` | Countries list |
| `GET` | `/api/v1/geo/currencies/` | Currencies list |

> πŸ“¦ **Postman collection** β†’ [`postman_collection.json`](postman_collection.json)
>
> πŸ“– **Swagger** β†’ `/api/docs/` Β· **ReDoc** β†’ `/api/redoc/` Β· **GraphiQL** β†’ `/graphql/`

---

## Deployment β€” Fly.io

```bash
# Install CLI
curl -L https://fly.io/install.sh | sh && flyctl auth login

# Create persistent SQLite volume
flyctl volumes create auditshield_data --region jnb --size 3 --config backend/fly.toml

# Set secrets
flyctl secrets set \
DJANGO_SECRET_KEY="" \
FILE_ENCRYPTION_KEY="" \
DJANGO_ALLOWED_HOSTS="auditshield-backend.fly.dev" \
CORS_ALLOWED_ORIGINS="https://your-frontend.fly.dev" \
--config backend/fly.toml

# Deploy
flyctl deploy --config backend/fly.toml
```

**Auto-deploy on push to `main`**: Add `FLY_API_TOKEN` to GitHub repo secrets β†’ (**Settings β†’ Secrets β†’ Actions**).

### Live Production URLs

| | URL |
|---|---|
| 🌐 **API Base** | https://auditshield-backend.fly.dev/api/v1/ |
| πŸ“– **Swagger UI** | https://auditshield-backend.fly.dev/api/docs/ |
| πŸ“„ **ReDoc** | https://auditshield-backend.fly.dev/api/redoc/ |
| πŸ”— **GraphiQL** | https://auditshield-backend.fly.dev/graphql/ |
| ❀️ **Health check** | https://auditshield-backend.fly.dev/health/ |

---

## Deployment β€” Docker Compose Production

```bash
git clone https://github.com/manziosee/auditshield.git && cd auditshield
cp .env.example .env # fill in production values

docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
docker compose exec backend python manage.py createsuperuser
```

Place SSL certs in `nginx/ssl/` and configure your domain in `nginx/nginx.prod.conf`.

---

## User Roles

| Role | Access |
|------|--------|
| πŸ‘‘ `super_admin` | Full platform access |
| πŸ”§ `admin` | Company admin β€” full access to own tenant |
| πŸ‘©β€πŸ’Ό `hr` | Employees, documents, compliance |
| 🧾 `accountant` | Payroll, financial reports |
| πŸ” `auditor` | Read-only + audit logs |
| πŸ‘€ `employee` | Own profile and documents only |

---

## Project Structure

```
auditshield/
β”œβ”€β”€ 🐍 backend/
β”‚ β”œβ”€β”€ auditshield/settings/ # base / development / production
β”‚ β”œβ”€β”€ apps/
β”‚ β”‚ β”œβ”€β”€ accounts/ # User + JWT auth
β”‚ β”‚ β”œβ”€β”€ companies/ # Company (tenant) + onboarding
β”‚ β”‚ β”œβ”€β”€ employees/ # Employee + Department
β”‚ β”‚ β”œβ”€β”€ documents/ # Encrypted upload + OCR
β”‚ β”‚ β”œβ”€β”€ compliance/ # Authority + Requirements + Records
β”‚ β”‚ β”œβ”€β”€ reports/ # PDF generation (WeasyPrint)
β”‚ β”‚ β”œβ”€β”€ notifications/ # In-app + email alerts
β”‚ β”‚ β”œβ”€β”€ audit_logs/ # Immutable activity trail
β”‚ β”‚ β”œβ”€β”€ geography/ # Country + Currency + ExchangeRate
β”‚ β”‚ └── payroll/ # TaxRule + PayrollRun + Payslip
β”‚ β”œβ”€β”€ core/ # Shared: TenantModel, middleware, utils
β”‚ β”œβ”€β”€ Dockerfile.dev / Dockerfile.prod
β”‚ β”œβ”€β”€ entrypoint.sh # Fly.io startup script
β”‚ └── fly.toml # Fly.io deployment config
β”‚
β”œβ”€β”€ πŸ…°οΈ frontend/src/app/
β”‚ β”œβ”€β”€ core/ # Guards, interceptors, services, models
β”‚ β”œβ”€β”€ features/
β”‚ β”‚ β”œβ”€β”€ auth/ # Login + Register pages
β”‚ β”‚ β”œβ”€β”€ dashboard/ # KPI cards + live charts
β”‚ β”‚ β”œβ”€β”€ employees/ # List, Detail, Form (CRUD)
β”‚ β”‚ β”œβ”€β”€ documents/ # List, Upload, Detail (CRUD)
β”‚ β”‚ β”œβ”€β”€ compliance/ # Tracker + Add/Edit/Delete
β”‚ β”‚ β”œβ”€β”€ reports/ # List + Generate
β”‚ β”‚ β”œβ”€β”€ notifications/ # Notification centre
β”‚ β”‚ β”œβ”€β”€ audit-logs/ # Audit log viewer
β”‚ β”‚ └── company/ # Company settings
β”‚ └── shared/layout/ # Shell β€” sidebar + topbar
β”‚
β”œβ”€β”€ 🌐 nginx/ # nginx.dev.conf / nginx.prod.conf
β”œβ”€β”€ πŸ’Ύ scripts/backup/ # GPG-encrypted backup + restore
β”œβ”€β”€ βš™οΈ .github/workflows/ # CI/CD pipelines
β”œβ”€β”€ 🐳 docker-compose.yml # Dev stack
β”œβ”€β”€ 🐳 docker-compose.prod.yml # Production overrides
β”œβ”€β”€ πŸ“¦ postman_collection.json # Full Postman API collection
β”œβ”€β”€ πŸ”§ Makefile
└── πŸ“‹ .env.example
```

---

## Makefile Commands

```bash
make dev # Start dev stack (docker compose up --build)
make stop # Stop all services
make logs # Tail all service logs
make migrate # Run database migrations
make makemigrations # Create new migrations
make shell # Django shell_plus
make createsuperuser # Create admin user
make seed # Seed global countries, currencies, authorities
make test # Run Django test suite
make lint # Ruff linter
make coverage # Tests with coverage report
make deploy # Deploy backend to Fly.io
make build-prod # Build production Docker images
make backup # GPG-encrypted DB + media backup
make gen-secret # Generate DJANGO_SECRET_KEY
make gen-fernet # Generate FILE_ENCRYPTION_KEY
```

---

**MIT License** β€” Copyright Β© 2026 [Osee Manzi](mailto:oseemanzi3@gmail.com)

_Built with ❀️ to make compliance accessible for every SME, everywhere._