https://github.com/victormarlor/hyperfocus
Typed, test-driven FastAPI backend using SQLModel and SQLite to analyze user focus, interruptions, and time-based productivity metrics.
https://github.com/victormarlor/hyperfocus
analytics api-design async-python backend clean-architecture deep-work developer-tools docker fastapi focus-tracking productivity pydantic pytest python rest-api sqlite sqlmodel time-tracking
Last synced: 29 days ago
JSON representation
Typed, test-driven FastAPI backend using SQLModel and SQLite to analyze user focus, interruptions, and time-based productivity metrics.
- Host: GitHub
- URL: https://github.com/victormarlor/hyperfocus
- Owner: victormarlor
- License: mit
- Created: 2025-11-17T18:47:41.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-11-17T19:47:26.000Z (7 months ago)
- Last Synced: 2025-11-17T20:26:01.245Z (7 months ago)
- Topics: analytics, api-design, async-python, backend, clean-architecture, deep-work, developer-tools, docker, fastapi, focus-tracking, productivity, pydantic, pytest, python, rest-api, sqlite, sqlmodel, time-tracking
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# ๐ง HyperFocus
### Master Your Deep Work. Track Your Interruptions.
**HyperFocus** is not just another time tracker. It is a **Full-Stack Analytics Platform** designed for remote workers, developers, and students who want to understand the *science* behind their productivity.
We all feel busy, but are we **productive**? HyperFocus helps you answer that question by tracking your "Deep Work" sessions and analyzing exactly what breaks your flowโwhether it's a phone call, a family member, or your own wandering mind.
---
## ๐ Live Demo
Try the application live here: **[https://hyper-focus-six.vercel.app/](https://hyper-focus-six.vercel.app/)**
> [!WARNING]
> **Free Tier Limitations**:
> * **Cold Starts**: The backend is hosted on Render's free tier. If the API hasn't been used for a while, the first request may take **50+ seconds** to wake up. Please be patient! โณ
> * **Performance**: The database and server run on minimal resources (shared CPU/RAM). Heavy usage might cause slowness.
> * **Data Persistence**: While data is saved, this is a demo environment. Do not use for critical production data.
---
## โจ Key Features
### ๐ก๏ธ Enterprise-Grade Security
* **Secure Authentication**: Built with **OAuth2** and **JWT** (JSON Web Tokens).
* **Data Protection**: Passwords hashed with **Argon2**, the winner of the Password Hashing Competition.
* **Role-Based Access**: Granular permissions for Users and Admins.
### โฑ๏ธ Seamless Focus Tracking
* **Focus Timer (Pomodoro)**: Built-in timer with presets (25m, 50m) and visual progress ring.
* **One-Click Sessions**: Start a "Deep Work" session instantly.
* **Frictionless Interruption Logging**: Log distractions in seconds without losing your context.
### ๐ Professional Analytics Dashboard
* **AI Insights ๐ง **: Local intelligence engine that analyzes your patterns to give personalized productivity tips.
* **Productivity Score**: A proprietary algorithm that scores your focus quality (0-100).
* **Interruption Breakdown**: Visual Pie Charts identifying your top distractors.
* **Peak Performance Hours**: Heatmaps showing *when* you are most productive.
### ๐จ Premium User Experience
* **Modern UI**: Built with **React** and **Vite** for blazing fast performance.
* **Dark Mode Native**: Designed for late-night coding sessions with a custom-tuned dark palette.
* **Fully Responsive**: Works perfectly on your Desktop, Tablet, and Mobile.
---
## ๐๏ธ Tech Stack
This project was built using industry-standard best practices and modern technologies.
### Backend (The Brain)
* **Language**: Python 3.11+
* **Framework**: [FastAPI](https://fastapi.tiangolo.com/) (High performance, easy to learn)
* **Database**: SQLite (Dev) / PostgreSQL (Prod ready)
* **ORM**: [SQLModel](https://sqlmodel.tiangolo.com/) (The power of SQLAlchemy + Pydantic)
* **Testing**: Pytest, Factory Boy
### Frontend (The Face)
* **Framework**: [React](https://react.dev/) 18
* **Build Tool**: [Vite](https://vitejs.dev/)
* **State Management**: [Zustand](https://github.com/pmndrs/zustand) (Simple, scalable state)
* **Routing**: React Router v6
* **Visualization**: Recharts
* **Styling**: Modern CSS Variables & Responsive Design
### DevOps (The Engine)
* **Containerization**: Docker & Docker Compose
* **CI/CD**: GitHub Actions (Automated Testing & Linting)
* **Deployment**: Ready for Railway (Backend) & Vercel (Frontend)
---
## ๐ Replication Guide (How to Run This Project)
Want to run HyperFocus on your own machine? Follow these steps.
### Prerequisites
* **Docker** (Recommended) OR **Python 3.11+** & **Node.js 18+**
* **Git**
### Option A: The "I want it running NOW" Method (Docker) ๐ณ
This will spin up the Backend, Frontend, and Database in isolated containers.
1. **Clone the Repository**
```bash
git clone https://github.com/victormarlor/HyperFocus.git
cd HyperFocus
```
2. **Launch with Docker Compose**
```bash
docker-compose up --build
```
3. **That's it!**
* **Frontend**: Open [http://localhost](http://localhost)
* **Backend API**: [http://localhost:8000](http://localhost:8000)
* **API Documentation**: [http://localhost:8000/docs](http://localhost:8000/docs)
---
### Option B: The "Hacker" Method (Manual Setup) ๐ป
If you want to develop or modify the code, run the services locally.
#### 1. Backend Setup
```bash
# Navigate to the project root
cd HyperFocus
# Create a virtual environment
python -m venv venv
# Activate it
# Windows:
.\venv\Scripts\Activate
# Mac/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn app.main:app --reload
```
*The API is now running at `http://localhost:8000`*
#### 2. Frontend Setup
Open a new terminal window.
```bash
# Navigate to the frontend directory
cd frontend
# Install Node dependencies
npm install
# Start the development server
npm run dev
```
*The App is now running at `http://localhost:5173`*
---
## ๐งช Quality Assurance
We maintain high code quality standards. You can run our test suites to verify everything is working.
**Backend Tests:**
```bash
pytest
```
**Frontend Tests:**
```bash
cd frontend
npm test
```
---
## ๐ Project Structure
A detailed look at the architecture:
```
HyperFocus/
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # CI/CD Pipeline configuration
โโโ app/ # FastAPI Backend Source
โ โโโ core/
โ โ โโโ config.py # Environment configuration
โ โ โโโ deps.py # Dependency Injection
โ โ โโโ logging_config.py # Logger setup
โ โ โโโ security.py # JWT & Password hashing
โ โ โโโ stats_logic.py # Analytics business logic
โ โโโ routers/
โ โ โโโ auth.py # Authentication endpoints
โ โ โโโ interruptions.py # Interruption management
โ โ โโโ sessions.py # Session management
โ โ โโโ stats.py # Statistics endpoints
โ โ โโโ users.py # User management
โ โโโ db.py # Database connection
โ โโโ main.py # App entry point
โ โโโ models.py # SQLModel Database Models
โ โโโ schemas.py # Pydantic Data Schemas
โโโ frontend/ # React Frontend Source
โ โโโ src/
โ โ โโโ api/
โ โ โ โโโ axios.js # Axios instance with interceptors
โ โ โโโ components/
โ โ โ โโโ features/ # Feature Widgets (Timer, Insights)
โ โ โ โโโ layout/ # Layout & Sidebar components
โ โ โ โโโ ui/ # Reusable UI (Buttons, Inputs, Cards)
โ โ โโโ pages/
โ โ โ โโโ DashboardPage.jsx
โ โ โ โโโ LoginPage.jsx
โ โ โ โโโ RegisterPage.jsx
โ โ โ โโโ SessionsPage.jsx
โ โ โโโ store/
โ โ โ โโโ authStore.js # Zustand Auth Store
โ โ โโโ styles/
โ โ โ โโโ layout.css # Responsive Layout Styles
โ โ โ โโโ theme.css # CSS Variables & Dark Mode
โ โ โโโ App.jsx # Main App Component & Routing
โ โ โโโ main.jsx # React Entry Point
โ โโโ Dockerfile # Frontend Dockerfile (Nginx)
โ โโโ package.json # Frontend Dependencies
โ โโโ vite.config.js # Vite Configuration
โโโ tests/ # Backend Integration Tests
โ โโโ conftest.py # Test Fixtures
โ โโโ test_auth.py # Auth Tests
โ โโโ test_interruptions_api.py
โ โโโ test_stats_logic.py
โโโ .dockerignore # Docker exclusion list
โโโ .gitignore # Git exclusion list
โโโ docker-compose.yml # Docker Orchestration
โโโ Dockerfile # Backend Dockerfile
โโโ railway.toml # Railway Deployment Config
โโโ requirements.txt # Backend Dependencies
โโโ README.md # Project Documentation
```
---
## ๐ฎ Future Roadmap
* [x] **Focus Timer**: Pomodoro integration directly in the session view.
* [x] **AI Insights**: Local heuristics engine to improve your workflow.
* [ ] **Mobile App**: Native React Native application.
---
## ๐ License
This project is licensed under the **MIT License** - see the [LICENSE](LICENSE) file for details.
---
*Built with โค๏ธ by Victormarlor*