Architecture of a Python HRIS

Moving beyond Excel: How I built a relational database system to handle Employee Data, Payroll, and Security.

Python Flask SQLAlchemy JWT Auth REST API

The Business Problem

Most HR departments rely on "Excel Chaos." Data is scattered across spreadsheets, leading to:

I built this system to demonstrate how Relational Databases (SQL) solve these specific HR operational failures.

Database Architecture (Schema)

Unlike Excel, I used a normalized SQL database structure to ensure data integrity. Here is a simplified view of the Entity Relationship Diagram (ERD) I designed:

Employees
id PK
email Unique
password_hash String
dept_id FK
Department
id PK
name String
cost_center Int
Payroll
id PK
employee_id FK
base_salary Float
tax_code String

The FK (Foreign Key) relationships ensure that you cannot pay a salary to an employee who doesn't exist—an error impossible to prevent in Excel.

Security Implementation

HR data is sensitive. I implemented Password Hashing using bcrypt instead of storing plain text, and JWT (JSON Web Tokens) for API access.

Code Snippet: Secure Model

class Employee(db.Model):
    __tablename__ = 'employees'
    
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password_hash = db.Column(db.String(256))

    def set_password(self, password):
        # Never store plain text!
        self.password_hash = generate_password_hash(password)

    def check_password(self, password):
        return check_password_hash(self.password_hash, password)

This code proves I understand GDPR/Data Privacy compliance at a technical level, not just a policy level.

The Outcome

This project serves as a "Proof of Concept" for a headless HR backend. By decoupling the data (Backend) from the view (Frontend), this system allows for:

View Source Code