# flexsidee/nfc-card-payment architecture

> Architecture diagram of the GitHub repository flexsidee/nfc-card-payment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flexsidee/nfc-card-payment
- Repository: https://github.com/flexsidee/nfc-card-payment

## Overview

##### Main Components

A. Hardware Layer:
- ESP8266 NodeMCU (Main microcontroller)
- RC522 RFID Module
- Peripheral components (LED, Buzzer)
- WiFi Access Point functionality

B. Software Layer:
- Frontend Web Application
- Backend Server (PHP)
- MySQL Database
- Hardware Communication Interface

**[Hardware Layer]**
- ↕
**[Backend Layer]**
- ↕
**[Frontend Layer]**

##### Detailed Component Breakdown

a) Hardware Layer (Bottom):
- It to the RC522 RFID Module
- WiFi communication capability
- LED and Buzzer as output components

b) Backend Layer (Middle):
- PHP Scripts Container
- Authentication handlers
- Payment processors
- User management
- MySQL Database
- Main tables (users, transactions)
- API Endpoints for:
- Hardware communication
- Frontend requests

c) Frontend Layer (Top):
- Web Interface Components:
- Admin Dashboard
- Student Portal
- Payment Processing Interface
- User Management
- Transaction Logs

##### Important Flows to Highlight

a) Payment Flow:
**RFID Card → RC522 Reader → ESP8266 → Backend API → Database**

b) User Authentication Flow:
**Frontend → Backend Authentication → Database Verification**

c) Transaction Monitoring Flow:
**Database → Backend API → Frontend Display**

##### Additional Elements

- Notes about the WiFi configuration (SSID: Credit Account)
- Critical security points
- Error handling paths

##### Technical Details

- Database connection points
- API endpoints for hardware communication
- User authentication flow
- Transaction processing pipeline

Remember to include:
- Version information
- Date of last update
- System requirements
- Network dependencies
- Security protocols

This will provide a comprehensive view of how the NFC payment system operates from hardware interaction through to user interface, making it easy for both technical and non-technical stakeholders to understand the system architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef hardware fill:#E0E0E0,stroke:#333
    classDef database fill:#B3E0FF,stroke:#333
    classDef backend fill:#90EE90,stroke:#333
    classDef frontend fill:#FFB366,stroke:#333
    classDef api fill:#E6B3FF,stroke:#333

    %% Hardware Layer
    subgraph Hardware
        ESP["ESP8266 NodeMCU"]
        RFID["RC522 RFID Module"]
        LED["LED Indicator"]
        BUZZ["Buzzer"]
        WIFI["WiFi Access Point<br/>(SSID: Credit Account)"]
        
        ESP --- RFID
        ESP --- LED
        ESP --- BUZZ
        ESP --- WIFI
    end

    %% Backend Layer
    subgraph Backend
        DB[(MySQL Database)]
        AUTH["Authentication Handler"]
        PAY["Payment Processor"]
        USER["User Management"]
        API["/API Endpoints"]
    end

    %% Frontend Layer
    subgraph Frontend
        ADMIN["Admin Dashboard"]
        STUDENT["Student Portal"]
        TRANS["Transaction Logs"]
        FUND["Fund Management"]
        USERMGMT["User Management Interface"]
    end

    %% Connections
    WIFI --> API
    API --> AUTH
    API --> PAY
    API --> USER
    AUTH --> DB
    PAY --> DB
    USER --> DB
    
    ADMIN --> API
    STUDENT --> API
    TRANS --> API
    FUND --> API
    USERMGMT --> API

    %% Click events
    click ESP "https://github.com/Flexsidee/nfc-card-payment/blob/main/Hardware/read_card-send_to_db-and_display_on_Oled/read_card-send_to_db-and_display_on_Oled/read_card-send_to_db-and_display_on_Oled.ino"
    click DB "https://github.com/Flexsidee/nfc-card-payment/blob/main/backend/database/nfc_payment.sql"
    click AUTH "https://github.com/Flexsidee/nfc-card-payment/blob/main/backend/process_login.php"
    click PAY "https://github.com/Flexsidee/nfc-card-payment/blob/main/backend/process_payment.php"
    click USER "https://github.com/Flexsidee/nfc-card-payment/blob/main/backend/create_user.php"
    click ADMIN "https://github.com/Flexsidee/nfc-card-payment/blob/main/Frontend/dashboard.php"
    click STUDENT "https://github.com/Flexsidee/nfc-card-payment/blob/main/Frontend/students/index.php"
    click TRANS "https://github.com/Flexsidee/nfc-card-payment/blob/main/Frontend/logs.php"
    click FUND "https://github.com/Flexsidee/nfc-card-payment/blob/main/Frontend/funduser.php"
    click USERMGMT "https://github.com/Flexsidee/nfc-card-payment/blob/main/Frontend/users.php"

    %% Legend
    subgraph Legend
        H["Hardware Component"]:::hardware
        D["Database"]:::database
        B["Backend Service"]:::backend
        F["Frontend Interface"]:::frontend
        A["API Endpoint"]:::api
    end

    %% Apply styles
    class ESP,RFID,LED,BUZZ,WIFI,H hardware
    class DB,D database
    class AUTH,PAY,USER,B backend
    class ADMIN,STUDENT,TRANS,FUND,USERMGMT,F frontend
    class API,A api
```
