# System Architecture

TAGBASE is built as a modular system that connects physical NFC tags with cloud-based verification, analytics, and (optionally) blockchain infrastructure. It is optimized for low friction on the end-user side and high security and extensibility on the backend.

***

### High-Level Overview

```plaintext
┌────────────┐     ┌─────────────┐     ┌─────────────┐     ┌──────────────┐
│  NFC TAG   │ --> │  Smartphone │ --> │ TAGBASE API │ --> │ Verification │
│ (NTAG 424) │     │   (Browser) │     │   (Backend) │     │   Database   │
└────────────┘     └─────────────┘     └─────────────┘     └──────────────┘
```

### Core Components

#### 1. **NFC Tags**

* **Hardware:** NTAG 424 DNA chips
* **Security:** AES-128 CMAC, unique UID, anti-cloning counter
* **Data:** Pre-encoded secure URL with crypto parameters

#### 2. **User Interface**

* **Device:** NFC-enabled mobile phone (iOS/Android)
* **Interface:** Default mobile browser (no app)
* **Behavior:** Tap-to-open secure URL

#### 3. **Verification API (Backend)**

* Built with **Elixir + Phoenix** for fault tolerance and speed
* Stateless endpoint that verifies each scan using:
  * Encrypted URL tokens
  * Session tracking and delta analysis
  * Tag state and activation status
* Connects to internal services: logging, analytics, blockchain, and portals

#### 4. **Verification Database**

* **Stores:**
  * Tag status (active/inactive)
  * Scan history
  * Session deltas
  * Optional ownership metadata
* Powered by **PostgreSQL**, with **pgvector** for advanced tracking and embeddings

#### 5. **Web Portal**

* Internal + customer-facing UI
* Supports:
  * Tag batch management
  * Live verification map
  * Order and analytics dashboards

#### 6. **Blockchain Integration (Optional)**

* Chain support: **Cardano**, **Ethereum**, **Solana**
* Use cases:
  * Minting NFTs or fungible tokens
  * Ownership records
  * Resale tracking

***

### Scalability & Modularity

TAGBASE is designed to support:

* Thousands of concurrent scans
* Millions of tags
* Distributed tag writing via Raspberry Pi + USB writer systems
* Lightweight deployment on edge devices (in progress)

Each component can be independently scaled, replaced, or extended via API.
