A cross-platform, gamified productivity system that tracks application usage, enforces adaptive restrictions, and helps users build lasting focus habits through behavioral intelligence.
Modern knowledge workers lose 2.5+ hours daily to context switching, distraction loops, and unstructured app usage. Existing tools either spy too aggressively or nudge too gently. There is no system that:
- Tracks what you do (not what you type)
- Escalates restrictions intelligently based on behavior
- Helps you understand why you get distracted
- Gamifies discipline without being annoying
FocusLayer is a cross-device productivity OS layer that:
- Passively monitors app usage metadata (no content, no keystrokes)
- Detects distraction loops and context drift in real time
- Applies a 5-stage escalating restriction engine
- Provides a gamified habit + streak system
- Shows beautiful analytics to build self-awareness
- Optionally enables ethical employee monitoring (opt-in only)
| Feature | Description |
|---|---|
| π Activity Tracking | Track app usage, idle time, switch frequency |
| π« Focus Mode | Whitelist/blacklist apps with 5-stage escalation |
| π Context Drift Detection | Real-time distraction loop identification |
| π Habit System | Create habits linked to actual usage data |
| π Analytics Dashboard | Focus score, heatmaps, weekly reports |
| π Cross-Device Sync | Real-time WebSocket sync between desktop + mobile |
| π Employee Mode | Opt-in ethical monitoring with productivity scores |
| π Smart Notifications | Behavior-aware warning messages |
| π Privacy Controls | Consent screen, data transparency, pause tracking |
| Layer | Technology |
|---|---|
| Frontend | React 18 + TypeScript + Tailwind CSS |
| Desktop App | Electron.js |
| Mobile App | React Native (Android) |
| Backend | Node.js + Express |
| Database | PostgreSQL |
| Real-time | Socket.io (WebSockets) |
| Auth | JWT + bcrypt |
| ORM | Prisma |
focuslayer/
βββ docker-compose.yml β Run everything with one command
βββ frontend/
β βββ Dockerfile
β βββ src/ # React + TypeScript web dashboard
βββ backend/
β βββ Dockerfile
β βββ prisma/schema.prisma
β βββ src/ # Node.js + Express API server
βββ electron/
β βββ src/ # Desktop app wrapper + native tracking
βββ mobile/
β βββ src/ # React Native Android app
βββ docs/
βββ ARCHITECTURE.md # Full system design documentation
This is the easiest way to run the full stack. You only need Docker Desktop installed β no Node.js, no PostgreSQL setup required.
Download from https://www.docker.com/products/docker-desktop and install it. Make sure it is running before continuing.
unzip focuslayer-complete.zip
cd focuslayerdocker compose up --buildThat's it. Docker will automatically:
- Pull and start a PostgreSQL database
- Build and start the backend API (runs DB migrations automatically)
- Build and start the frontend (served via nginx)
| Service | URL |
|---|---|
| Web Dashboard | http://localhost:5173 |
| Backend API | http://localhost:4000 |
| API Health Check | http://localhost:4000/health |
docker compose downTo also wipe the database and start completely fresh:
docker compose down -vUse this if you want to run each service individually for active development.
- Node.js >= 18
- PostgreSQL >= 14 running locally, or a free cloud instance from https://neon.tech
- Android Studio (for mobile only)
unzip focuslayer-complete.zip
cd focuslayercd backend
npm install
cp .env.example .envOpen .env and fill in your values:
DATABASE_URL="postgresql://your_user:your_password@localhost:5432/focuslayer"
JWT_SECRET="any-long-random-string-you-choose"
PORT=4000
CLIENT_URL="http://localhost:5173"Run migrations and start the server:
npx prisma migrate dev
npm run devAPI is now running at http://localhost:4000
cd ../frontend
npm install
cp .env.example .env
npm run devDashboard is now at http://localhost:5173
cd ../electron
npm install
npm run devThis opens the desktop window and begins tracking your active app windows in the background.
cd ../mobile
npm install
npx react-native run-androidRequires Android Studio with an emulator running, or a physical Android device connected via USB with USB debugging enabled.
- Sign Up β Create an account and read through the consent screen
- Enable Tracking β Toggle tracking on from the Privacy tab
- Set Focus Goals β Define a session length and add habits in the Habits tab
- Start a Session β Click "Start Session" in the Focus tab; FocusLayer monitors app usage in the background
- Get Nudged β Receive stage-based alerts when you drift from focused work
- Review Dashboard β See your focus score, hourly heatmap, and streaks
- Improve β Act on weekly insights and AI-generated habit suggestions
See /docs/ARCHITECTURE.md for the full documentation including:
- High-Level Architecture diagram
- Low-Level Design (LLD)
- ER Diagram
- Data Flow Diagram (DFD)
- Sequence Diagrams
- Full REST API documentation
- WebSocket event reference
- Module-by-module explanations
"Cannot connect to database"
β Make sure PostgreSQL is running. With Docker, just run docker compose up again.
"Port 4000 already in use"
β Set PORT=4001 in backend/.env and update VITE_API_URL=http://localhost:4001/api in frontend/.env.
"Prisma migration failed"
β Double-check that DATABASE_URL in .env points to an existing PostgreSQL server with the correct username and password.
Electron shows a blank screen
β Make sure the frontend dev server is running first (npm run dev inside /frontend), then launch Electron.
Android build fails
β Make sure ANDROID_HOME is set and an emulator is running. Run npx react-native doctor to diagnose issues.
MIT License β Free for personal and educational use.