User Activity Dashboard
A modern admin dashboard built with SvelteKit (Svelte 5) for managing users and analyzing login activity. The project includes OAuth authentication, a custom UI system, role-based access, and real login analytics powered by Turso and Drizzle ORM.
๐งช Live Demo
๐งฐ Tech Stack
- Framework: SvelteKit (Svelte 5)
- Styling: Tailwind CSS + shadcn/ui + OverlayScrollbars + Lenis
- Charts: Chart.js (+ Zoom plugin)
- Authentication: BetterAuth (GitHub, Google, Email/Password)
- ORM: Drizzle ORM
- Database: Turso (libSQL)
- Email: Resend API (custom email verification)
- Routing: Shallow routing with Drawer (on
/users/[id]
)
- Deployment: Vercel
๐ Getting Started
# Clone the repository
git clone https://github.com/ondrejjcizek/procorp-frontend-test.git
cd procorp-frontend-test
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env
# Push the schema to the database (required before first run)
pnpm db:push
# (Optional) Seed the database with test data
pnpm db:seed
# Start the development server
pnpm dev
๐งฉ Features
๐งโ๐ผ Admin Area
- โ
Sign in via GitHub, Google, or email/password using BetterAuth
- โ
Email verification with custom Resend template
- โ
Auto role promotion for whitelisted admin emails
- โ
Login history auto-generated on first login
- โ
Device, browser, and IP tracking on every login
- โ
Online/offline state synced on login/logout
- โ
Cookie-based sessions with expiration and cache
๐ฅ Users
- ๐งช Stored in Turso DB, seedable via
pnpm db:seed
- ๐ Fuzzy search by name/email using Fuse.js
- ๐ Sorted by online status and last active time
- ๐งพ User detail shown in Drawer (shallow routing)
- โ ๏ธ Suspicious users flagged with warnings
- ๐ข Animated online/offline indicators
- ๐
Joined date, role badge, and status shown
- ๐ ๏ธ User actions: View and Delete
๐ค Account
- ๐ Displays avatar, name, email, and role
- ๐ฌ Email verification via Resend
- ๐ Activity summary:
- Joined date
- Last active timestamp
- Logins in last 30 and 3 days
- ๐ Login frequency chart (last 30 days, Chart.js)
- โ ๏ธ Suspicious days highlighted (โฅ 8 logins)
- ๐งญ Admins can navigate to full user list
- ๐ Secure logout with session clear
๐ Analytics
- ๐ Daily login trend (30 days) visualized with Chart.js
- ๐ Spike detection based on activity thresholds
- ๐ Auto-refresh login data every 30 seconds
- ๐ฑ๏ธ Pan + zoom interactions via Chart.js plugin
๐จ Suspicious Activity Detection
- Users are flagged if:
- Logged in 10ร+ per day on 3 or more days
- Had a sudden spike (e.g. avg. 2โ3 โ 15+)
- โ ๏ธ Suspicious users are listed and clearly marked
๐ API Routes
GET /api/users
- Returns all users from Turso DB
- Includes login history, activity stats, and role
- Suspicious login detection
- ๐ก๏ธ Admin-only access
GET /api/activity/[id]
- Returns login history for a specific user
- Logins in last 30 / 3 days
- Last active timestamp
- ๐ก๏ธ Admin-only access