Skip to content

Tvaibhav06/LowKeySecure-GoogleTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LowKey Secure β€” Privacy-First Event Access System

Consent-First Identity Fabric for campus events with strict RBAC, event approval workflows, consent-based PII reveal, and anonymous attendance tracking.

Tech Stack React SQLite TailwindCSS FireBase

πŸš€ LowKey Secure is now live!

πŸ”— Visit here:
πŸ‘‰ LowKey Secure

πŸ“– Overview

LowKey Secure enables students to prove eligibility for campus events without exposing sensitive PII unless they explicitly consent. The platform implements a three-tier workflow:

Role Capabilities
Club Lead Create events, request specific attributes & custom data fields, set expiry dates, view consent-based attendance
Admin Review & approve/reject events based on privacy risk, manage users (edit/delete), view event history & audit trail
Student View approved events filtered by year, review risk levels, give consent, dismiss unwanted events

✨ Key Features

πŸ”’ Privacy & Consent Engine

  • Three-Tier Risk Classification β€” Events auto-classified as HIGH, MEDIUM, or LOW risk based on requested attributes and custom fields
  • Consent-Based PII Reveal β€” Club leads only see student data the student explicitly consented to share (name, email, branch, etc.)
  • Anonymized Attendance β€” Students tracked by SHA-256 hashed tokens, not user IDs
  • Centralized Privacy Engine (privacy_engine.py) β€” Keyword-based risk analysis covering 40+ sensitive data patterns

πŸ“‹ Event Lifecycle

  • Event Approval Pipeline β€” Admin review queue with mandatory comments for HIGH risk and rejections
  • Mandatory Expiry Dates β€” Every event requires an expiry date; expired events are auto-cleaned on startup and admin fetch
  • Event History Tab β€” Admin can view all approved/rejected events with timestamps and comments
  • Edit Resets to Pending β€” Any club lead edit automatically resets event status for re-review

πŸŽ›οΈ Dynamic Custom Data Fields

  • Supported Types: Short Text, Long Text, Number, Dropdown, Checkbox, Date, URL
  • Auto Risk Classification β€” Custom field labels are analyzed against HIGH/MEDIUM/LOW risk keyword lists
  • Required Field Validation β€” Club leads can mark fields as required; backend enforces before consent

πŸ‘₯ User Management

  • Auto-Generated Usernames β€” Random role-based username generation for students and club leads
  • Profile Dialog β€” View your profile info from the navbar
  • Admin User Management β€” Edit user details, delete users with full cascade cleanup (events, logs, audits, credentials)
  • Delete Confirmation Dialog β€” Safe deletion with confirmation modal

πŸ›‘οΈ Authentication & Security

  • JWT Authentication β€” 24-hour token expiry with HS256 signing
  • Bcrypt Password Hashing β€” Industry-standard password security
  • RSA-256 Credential Signing β€” Cryptographically signed verifiable credentials
  • Role-Based Access Control β€” Strict endpoint-level RBAC for admin, club, and student roles

πŸ› οΈ Tech Stack

Layer Technology
Backend Python 3.8+, FastAPI, SQLAlchemy, SQLite
Auth/Crypto python-jose (JWT), passlib + bcrypt, RSA key pairs
Frontend React 19 (Vite 7), Tailwind CSS 3, Radix UI primitives
UI Components Custom shadcn/ui (Badge, Button, Card, Dialog, Input, Select, Checkbox, Textarea, Label)
Icons Lucide React
HTTP Client Axios with interceptors (auto token injection, 401 redirect)

πŸš€ Setup & Run

Prerequisites

  • Python 3.8+
  • Node.js 18+ & npm

1. Backend

cd backend

# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate        # macOS/Linux
# .\venv\Scripts\Activate       # Windows PowerShell

# Install dependencies
pip install -r requirements.txt

# Run database migration (if upgrading existing DB)
python migrate_db.py

# Start server
uvicorn main:app --reload

Backend API: http://localhost:8000 Swagger Docs: http://localhost:8000/docs

2. Frontend

cd frontend

# Install dependencies
npm install

# Start dev server
npm run dev

Frontend: http://localhost:5173


πŸ§ͺ Workflow Guide

Step 1: Register Users

Navigate to /register and create accounts for each role:

  • Admin β€” Must provide a custom username
  • Club Lead β€” Provide name, email, phone, year, club/org name
  • Student β€” Provide name, email, phone, year, branch

Usernames can be auto-generated or manually chosen for students and club leads.

Step 2: Create Event (Club Lead)

  1. Login as Club Lead
  2. Fill in event name, description, and expiry date (required)
  3. Select allowed years (or leave empty for all years)
  4. Choose predefined attributes (branch, year, email, phone, name, student_id)
  5. Add optional custom data fields (text, dropdown, etc.)
  6. Review the real-time risk preview before submitting

Step 3: Approve/Reject Event (Admin)

  1. Login as Admin β†’ Approvals tab
  2. Review each event's risk level, requested attributes, and expiry date
  3. Actions:
    • βœ… LOW/MEDIUM risk β†’ Approve with optional comment
    • βœ… HIGH risk β†’ Approve with mandatory justification
    • ❌ Reject β†’ Requires comment explaining reason

Step 4: Student Consent

  1. Login as Student β†’ View Available Events (filtered by year eligibility)
  2. Review risk badge, risk message, requested attributes, and expiry date
  3. Click "Give Consent" β†’ Review details in consent modal
  4. Fill in any required custom fields
  5. Confirm β†’ "Access Granted!" animation

Step 5: View Attendance (Club Lead)

  1. Go to My Events β†’ Click the attendance icon on an approved event
  2. View Live Attendance Feed showing:
    • βœ… Consented PII (only what the student agreed to share)
    • πŸ• Timestamp (IST)
    • πŸ”‘ Anonymized token
    • πŸ“ Custom field responses

πŸ—‚οΈ Project Structure

LowKey-secure/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py              # FastAPI routes & endpoints
β”‚   β”œβ”€β”€ models.py            # SQLAlchemy ORM models (8 tables)
β”‚   β”œβ”€β”€ schemas.py           # Pydantic request/response schemas
β”‚   β”œβ”€β”€ auth.py              # JWT auth, bcrypt, token creation
β”‚   β”œβ”€β”€ utils.py             # RSA signing, phone/email validation
β”‚   β”œβ”€β”€ privacy_engine.py    # Centralized risk classification engine
β”‚   β”œβ”€β”€ privacy_analytics.py # Digital Hygiene metrics logic
β”‚   β”œβ”€β”€ ai_advisor.py        # AI summary generation (Zero PII)
β”‚   β”œβ”€β”€ username_gen.py      # Random username generator
β”‚   β”œβ”€β”€ database.py          # SQLite engine & session
β”‚   β”œβ”€β”€ migrate_db.py        # Database migration script
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── log.png          # App logo
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx          # Router, navbar, auth guards
β”‚   β”‚   β”œβ”€β”€ api.js           # Axios instance with interceptors
β”‚   β”‚   β”œβ”€β”€ main.jsx         # React entry point
β”‚   β”‚   β”œβ”€β”€ index.css        # Global styles (dark theme)
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.jsx   # JWT decode, login/logout state
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfileDialog.jsx # User profile modal
β”‚   β”‚   β”‚   β”œβ”€β”€ RiskBadge.jsx     # Risk level badge component
β”‚   β”‚   β”‚   └── ui/              # shadcn/ui primitives
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx    # Approvals, Users, History tabs
β”‚   β”‚   β”‚   β”œβ”€β”€ ClubDashboard.jsx     # Event builder & attendance
β”‚   β”‚   β”‚   β”œβ”€β”€ StudentDashboard.jsx  # Event feed & consent
β”‚   β”‚   β”‚   └── RequestDetails.jsx
β”‚   β”‚   └── lib/
β”‚   β”‚       └── utils.js     # cn() utility for Tailwind
β”‚   └── package.json
β”œβ”€β”€ README.md
└── .gitignore

πŸ”§ API Endpoints

Auth

Method Endpoint Description
GET /auth/generate-username Generate random username
POST /auth/register Register new user
POST /auth/login Login & get JWT token
GET /user/profile Get current user profile

Admin

Method Endpoint Description
POST /admin/issue-credential Issue credential to student
GET /admin/events?status= Get events (PENDING/APPROVED/REJECTED)
POST /admin/events/{id}/review Approve or reject event
GET /admin/users List all users
PUT /admin/users/{id} Update user details
DELETE /admin/users/{id} Delete user (full cascade)
GET /admin/credentials List all credentials

Club Lead

Method Endpoint Description
POST /club/events Create event with attributes & custom fields
PUT /club/events/{id} Edit event (resets to PENDING)
DELETE /club/events/{id} Delete own event
GET /club/events List own events
GET /club/events/{id}/logs Consent-based attendance with custom responses
GET /club/calendar View all approved events (read-only)

Student

Method Endpoint Description
GET /student/credentials Get own credentials
GET /student/events Approved events (year-filtered)
GET /student/events/{id} Event details (eligibility checked)
GET /student/registered-events Events already consented to
POST /student/events/{id}/consent Give consent with custom field responses

πŸ—ƒοΈ Database Schema

Table Purpose
users All users (admin, club, student) with PII fields
credentials RSA-signed verifiable credentials
access_requests Events with attributes, risk level, status, expiry
approval_audits Admin approve/reject actions with comments
access_logs Anonymized attendance with consented attributes
user_audits User modification tracking
event_custom_fields Dynamic form fields per event
student_custom_field_responses Student answers to custom fields
student_privacy_metrics New: Aggregated monthly exposure stats

πŸ”’ Privacy & Security Design

Risk Classification

Level Triggers Admin Requirement
HIGH phone, student_id, aadhaar, passport, bank details, biometrics Mandatory justification comment
MEDIUM name, email, social media, DOB, gender Optional comment
LOW branch, year, t-shirt size, preferences Optional comment

Consent-Based PII Reveal

  • When a student consents to an event, the system stores which attributes they agreed to share (consented_attrs)
  • Club leads viewing attendance logs only see the data fields the student consented to β€” no more, no less
  • Attribute mapping ensures frontend names resolve to correct database columns (student_id β†’ username, etc.)

Anonymization

  • Access logs use SHA-256 hashed tokens (user_id + event_id + timestamp)
  • Deduplication check prevents multiple registrations per student per event
  • Expired events are automatically purged on server startup

πŸ“Š Digital Hygiene Dashboard

A dedicated privacy dashboard for students to monitor their data exposure footprint. This feature shifts the focus from "access" to "behavioral privacy."

Key Metrics

  1. Exposure Score: A cumulative weighted score calculated from all attended events.
    • Formula: (High_Risk_Count * 6) + (Medium_Risk_Count * 3) + (Low_Risk_Count * 1)
  2. Entropy Score: Measures how widely your data is spread across different organisations. High entropy means your data is fragmented across many clubs (higher breach risk).
  3. Risk Velocity: Tracks the rate of change in your risk exposure compared to the previous month. A spike (e.g., +15 points) triggers an alert.

πŸ€– AI Privacy Advisor

The dashboard includes an AI-generated summary that provides actionable advice (e.g., "Your risk exposure doubled this month due to 3 high-risk hackathons. Consider using a burner email.").

Privacy Guarantee: The AI model (Llama-3 via Groq) receives ONLY aggregated integers (e.g., "High Risk Count: 5"). No raw PII, names, or event titles are ever sent to the AI.


πŸ“ Notes

  • Database: SQLite (backend/lowkey.db) β€” auto-created on first run
  • RSA Keys: Auto-generated and persisted (private_key.pem, public_key.pem)
  • Timezone: IST (Asia/Kolkata, UTC+5:30) β€” timestamps stored as naive IST
  • Notifications: Simulated via server console logs
  • Token Expiry: JWT tokens valid for 24 hours

Releases

No releases published

Packages

 
 
 

Contributors