How kylehton/labl works
Labl manages Gmail labeling: users authenticate, create labels, seed them with example emails, then fetch inbox messages for semantic matching and direct labels or suggestions. The backend separates API orchestration, Gmail access, embedding/matching, and persistence; label-record history supports review workflows. The frontend exposes landing and dashboard experiences. Some routes and UI details are represented from README capabilities and the source index; links are limited to documented or excerpted relationships.
Main entry points: pipeline.py Labeling pipeline · labeling.py Inbox labeling task · users.py User repository · gmail.py Gmail routes
Components 28
Web client
- Next.js app
client/app/layout.tsx - Auth context
client/app/context/AuthContext.tsx - Landing page
client/app/landing-page/page.tsx - Inbox dashboard
client/app/dashboard/page.tsx
API workflows
- OAuth routes
server/app/api/auth.py - User routes
server/app/api/user.py - Gmail routes
server/app/api/gmail.py - Label history routes
server/app/api/label_records.py - FastAPI entry
server/app/main.py - Gmail client
server/config/gmail.py
Labeling engine
- Labeling pipeline
server/ml/pipeline.py - Text embeddings
server/ml/embeddings.py - Centroid matching
server/ml/centroid.py - Similarity scoring
server/ml/similarity.py - Preset labels
server/ml/preset_labels.py
Persistence and sessions
- User repository
server/app/repositories/users.py - Label history store
server/app/repositories/label_records.py - Preset repository
server/app/repositories/presets.py - Label model
server/app/models/label.py - MongoDB access
server/config/db.py - Session service
server/config/session.py - Session guard
server/dependencies/session_auth.py - Token encryption
server/config/crypto.py
Background processing
- Celery setup
server/config/celery_app.py - Inbox labeling task
server/tasks/labeling.py
Other components
- User
- MongoDB
- Gmail service
Connections 40
- User → Landing page: visits
- User → Inbox dashboard: uses
- Next.js app → Auth context: provides
client/app/layout.tsx - Inbox dashboard → Auth context: uses
client/app/dashboard/page.tsx - Landing page → Auth context: uses
client/app/landing-page/page.tsx - Auth context → OAuth routes: checks session
client/app/context/AuthContext.tsx - Auth context → OAuth routes: starts login
client/app/context/AuthContext.tsx - User → OAuth routes: authenticates
README.md - OAuth routes → Session service: creates session
server/app/api/auth.py - Session service → User repository: upserts user
server/config/session.py - Session service → Token encryption: encrypts token
server/config/session.py - Session service → MongoDB access: stores session
server/config/session.py - Session guard → Session service: loads session
server/dependencies/session_auth.py - FastAPI entry → OAuth routes: registers routes
server/app/main.py - FastAPI entry → User routes: registers routes
server/app/main.py - FastAPI entry → Gmail routes: registers routes
server/app/main.py - FastAPI entry → Label history routes: registers routes
server/app/main.py - User routes → User repository: reads and updates
server/app/api/user.py - User routes → Labeling pipeline: seeds labels
server/app/api/user.py - Gmail routes → Gmail client: fetches mail
server/app/api/gmail.py - Gmail routes → Inbox labeling task: enqueues labeling
server/tasks/labeling.py - Gmail routes → User repository: loads user labels
server/app/api/gmail.py - Inbox labeling task → Labeling pipeline: labels messages
server/tasks/labeling.py - Inbox labeling task → Gmail client: fetches and applies
server/tasks/labeling.py - Inbox labeling task → User repository: updates sync state
server/tasks/labeling.py - Inbox labeling task → Label history store: records outcomes
server/tasks/labeling.py - Gmail routes → Labeling pipeline: seeds and scores
server/app/api/gmail.py - Labeling pipeline → Text embeddings: embeds text
server/ml/pipeline.py - Labeling pipeline → Centroid matching: computes centroids
server/ml/pipeline.py - Labeling pipeline → Similarity scoring: scores matches
server/ml/pipeline.py - Labeling pipeline → Label model: uses labels
server/ml/pipeline.py - User repository → Preset repository: loads defaults
server/app/repositories/users.py - Preset repository → Preset labels: seeds preset data
server/app/repositories/presets.py - Preset repository → MongoDB access: stores presets
server/app/repositories/presets.py - User repository → MongoDB access: stores user data
server/app/repositories/users.py - Label history store → MongoDB access: stores history
server/app/repositories/label_records.py - Label history routes → Label history store: reads and updates
server/app/api/label_records.py - MongoDB access → MongoDB: reads and writes
server/config/db.py - Gmail client → Gmail service: calls Gmail API
README.md - Inbox labeling task → Celery setup: runs as task
server/tasks/labeling.py