Skip to content

Latest commit

ย 

History

7 ๆไบค

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

ไป“ๅบ“ files navigation

๐Ÿš€ DevFocus - Developer Context Intelligence Engine

A fullโ€“scale, productionโ€‘grade backend architecture made public - because my real projects are private. ๐Ÿ”’๐Ÿ”ฅ


๐Ÿงฉ Problem

As developers, we constantly:

  • Jump between tasks โžก๏ธ lose flow
  • Forget why we contextโ€‘switched
  • Scatter links (PRs, ้—ฎ้ข˜, Docs, Research) everywhere
  • Have no metrics on real focus time
  • Work inside private repos where our best architecture never sees daylight
  • Have no unified view of productivity, behavior, or workflow patterns

๐Ÿ‘‰ DevFocus was created to break this invisible wall.
To show the level of engineering I apply daily in my private projects โ€” but in a fully open, clean, wellโ€‘architected system anyone can inspect.


๐ŸŒŸ Solution

DevFocus is a Context Intelligence Engine that blends:

๐Ÿง  Developer workflow tracking

  • โฑ๏ธ Session tracking
  • ๐Ÿ”€ Context switching
  • ๐Ÿงฑ Task management (Bug / Feature / Refactor)
  • ๐Ÿ”— Resource linking

๐Ÿ‘ฅ Team collaboration + RBAC

  • Teams (Owner / Admin / Member / Viewer)
  • Scoped sessions + scoped tasks
  • Permissionโ€‘safe domain logic

๐Ÿ“Š Reporting Engine

  • Daily / Weekly reports
  • Programmatic summaries
  • Insight generation

๐Ÿงฌ Insight Engine

Automatic analytics detecting:

  • ๐Ÿšจ High context switching
  • ๐Ÿ’ค Low focus time
  • ๐Ÿ“‰ Fragile workflow patterns
  • ๐Ÿ” Room for deepโ€‘work improvements

๐Ÿš› Background Jobs (Celery)

  • Nonโ€‘blocking report generation
  • Insight analysis
  • Scalable async architecture

๐Ÿ™ GitHub Issue Importer (async httpx)

  • Fetch GitHub issues
  • Autoโ€‘create Tasks
  • Detect + ignore PRs
  • Store external URLs + IDs

๐Ÿ“ก Observability Layer

  • API Request Logging Middleware
  • Duration, status, userโ€‘agent, IP
  • Full traceability of API usage

๐Ÿ”ฅ Realtime Event Stream (SSE)

  • Live reports
  • Live insights
  • Zero WebSocket overhead

๐Ÿ“ค Export System

  • CSV
  • JSON
  • For tasks, sessions, reports, insights

๐Ÿงช Full Test Suite

  • Unit tests
  • Integration tests
  • Signals tests
  • Celery task pipeline tests
  • GitHub importer tests (mocked async)
  • SSE + middleware tests

๐Ÿงฑ Architecture Overview

devfocus/
 โ”œโ”€โ”€ core/
 โ”‚    โ”œโ”€โ”€ models.py          # Domain entities
 โ”‚    โ”œโ”€โ”€ services.py        # SOLID service layer
 โ”‚    โ”œโ”€โ”€ signals.py         # Reactive event handling
 โ”‚    โ”œโ”€โ”€ tasks.py           # Celery jobs
 โ”‚    โ”œโ”€โ”€ integrations.py    # GitHub importer
 โ”‚    โ””โ”€โ”€ ...
 โ”‚
 โ”œโ”€โ”€ api/
 โ”‚    โ”œโ”€โ”€ serializers.py
 โ”‚    โ”œโ”€โ”€ views.py
 โ”‚    โ”œโ”€โ”€ urls.py
 โ”‚    โ””โ”€โ”€ ...
 โ”‚
 โ”œโ”€โ”€ devfocus/
 โ”‚    โ”œโ”€โ”€ settings.py
 โ”‚    โ”œโ”€โ”€ celery.py
 โ”‚    โ”œโ”€โ”€ middleware.py
 โ”‚    โ””โ”€โ”€ ...
 โ”‚
 โ”œโ”€โ”€ tests/
 โ””โ”€โ”€ README.md

๐Ÿ›  Tech Stack (Full Breakdown)

Backend Core

  • ๐Ÿ Python 3.11+
  • ๐Ÿฆ„ Django 5
  • ๐ŸŒ Django REST Framework
  • ๐Ÿงฑ Clean Architecture
  • ๐Ÿงฉ SOLID Principles
  • ๐Ÿงฌ Domainโ€‘Driven Components
  • ๐Ÿงฒ Signals for reactive updates

Async & Integrations

  • โšก httpx (async)
  • ๐Ÿ™ GitHub API integration
  • ๐Ÿ”Œ SSE eventโ€‘streaming

Workers & Scalability

  • ๐Ÿณ Celery 5
  • ๐Ÿ”ด Redis (Broker + Result backend)
  • ๐Ÿงต Background report generation
  • โš™๏ธ Long-running async workflows

Database / ORM

  • ๐Ÿ’พ SQLite (dev)
  • โž• Ready for PostgreSQL
  • ๐Ÿ” ORM optimization (annotate, select_related, prefetch)

Observability

  • ๐Ÿ“˜ Structured API logs
  • ๐Ÿ•ต๏ธ Request duration tracking
  • ๐Ÿ” Perโ€‘user analytics

Testing

  • ๐Ÿงช pytest / Django TestCase
  • โšก async test support
  • ๐Ÿงฑ full coverage on:
    • core domain
    • services
    • insights
    • Celery tasks
    • GitHub importer
    • SSE
    • permissions + teams

Run Guide & API Reference

This document contains only the two requested sections:

  1. How to Run the Project\
  2. Full API Endpoint Reference

๐ŸŸฉ 1) How to Run DevFocus

1๏ธโƒฃ Create & Activate Virtual Environment

macOS / Linux

python3 -m venv venv
source venv/bin/activate

Windows (PowerShell)

python -m venv venv
.\venv\Scripts\activate

2๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

3๏ธโƒฃ Run Database Migrations

python manage.py makemigrations
python manage.py migrate

4๏ธโƒฃ Create Superuser (Optional)

python manage.py createsuperuser

5๏ธโƒฃ Start Development Server

python manage.py runserver

Your API will be served at:

http://127.0.0.1:8000/api/

6๏ธโƒฃ Start Celery Worker (Background Jobs)

In a second terminal:

celery -A devfocus worker -l info

Ensure Redis is running:

redis-server

7๏ธโƒฃ Optional: Update Requirements

pip freeze > requirements.txt

๐ŸŸฆ 2) API Endpoints (Full Reference)

๐Ÿ”น Authentication

(Using default Django session authentication or token if enabled)


๐Ÿ“ TASKS

โžค List Tasks

GET /api/tasks/

โžค Filter / ๆœ็ดข / Order

GET /api/tasks/?type=BUG
GET /api/tasks/?priority=HIGH
GET /api/tasks/?search=login
GET /api/tasks/?ordering=-created_at

โžค Create Task

POST /api/tasks/

โžค Retrieve Task

GET /api/tasks/{id}/

โžค Update Task

PATCH /api/tasks/{id}/

โžค Delete Task

DELETE /api/tasks/{id}/

โžค Export Tasks

GET /api/tasks/export/?format=csv
GET /api/tasks/export/?format=json

โžค Import GitHub ้—ฎ้ข˜ (async)

POST /api/tasks/import_github/

Body:

{
  "owner": "django",
  "repo": "django",
  "team_id": 1
}

๐Ÿงฉ DEV SESSIONS

โžค List Sessions

GET /api/sessions/

โžค Filter / Order

GET /api/sessions/?status=OPEN
GET /api/sessions/?date_from=2025-01-01
GET /api/sessions/?ordering=-switch_count

โžค Create Session

POST /api/sessions/

โžค Retrieve Session

GET /api/sessions/{id}/

โžค Close Session

POST /api/sessions/{id}/close/

โžค Attach Task to Session

POST /api/sessions/{id}/attach_task/

Body:

{
  "task_id": 5,
  "role": "MAIN"
}

โžค Export Sessions

GET /api/sessions/export/?format=csv
GET /api/sessions/export/?format=json

๐Ÿ”„ CONTEXT SWITCHES

โžค List

GET /api/context-switches/

โžค Create

POST /api/context-switches/

Body:

{
  "dev_session": 1,
  "from_task": 2,
  "to_task": 3,
  "reason": "INTERRUPT"
}

๐Ÿ”— RESOURCE LINKS

โžค List

GET /api/resources/

โžค Create

POST /api/resources/


๐Ÿ“Š REPORTS

โžค List Reports

GET /api/reports/

โžค Generate Daily Report (Sync)

POST /api/reports/daily/

Body (optional):

{
  "date": "2025-01-30"
}

โžค Generate Daily Report (Async)

POST /api/reports/daily-async/


๐ŸŽ›๏ธ REPORT REQUESTS (Celery Jobs)

โžค Create Report Request

POST /api/report-requests/

Body:

{
  "type": "DAILY",
  "day": "2025-01-30"
}

โžค List Requests

GET /api/report-requests/


๐Ÿง  INSIGHTS

โžค List

GET /api/insights/


๐Ÿ‘ฅ TEAMS

โžค List Teams

GET /api/teams/

โžค Create Team

POST /api/teams/

โžค Team Members

GET /api/teams/{id}/members/


๐Ÿ“ก SSE Event Stream

โžค Live Stream

GET /api/events/stream/

Returns: - latest reports\

  • latest insights
    as text/event-stream.

๐Ÿ“˜ LOGGING (internal middleware)

All API calls generate an ApiRequestLog entry locally.


๐Ÿš€ Why I Built This (The Real Reason)

Most of my engineering work happens inside private, enterpriseโ€‘grade repositories
โ€” where I build:

  • structured clean architectures
  • highโ€‘scale backends
  • domainโ€‘driven systems
  • async microservices
  • data pipelines
  • CI/CD workflows

โ€ฆbut none of that can be shown publicly.
So I created DevFocus to expose the quality, architecture, principles, and engineering depth
I actually use daily.

This project is not a toy it is a public representation of how I design real systems.


๐Ÿบ Authorโ€™s Note

๐Ÿ–ค I build systems that keep developers sharp, teams aligned, and architectures clean.
DevFocus is just a glimpse - the real power lives in private repos.

-- Soroosh Morshedi (https://sorooshmorshedi.ir)

๐Ÿ”ฅ๐Ÿšฌ๐Ÿ’ป๐Ÿ–ค


 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   โ–ˆโ–ˆ   โ–ˆโ–ˆ  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ   โ–ˆโ–ˆ  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ
โ–ˆโ–ˆ        โ–ˆโ–ˆ โ–ˆโ–ˆ   โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ       โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆโ–ˆ  โ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆ      โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ   โ–ˆโ–ˆ
โ–ˆโ–ˆ         โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ โ–ˆ โ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆ      โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
โ–ˆโ–ˆ          โ–ˆ     โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ       โ–ˆโ–ˆ โ–ˆโ–ˆ    โ–ˆโ–ˆ  โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆ      โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ   โ–ˆโ–ˆ
โ–ˆโ–ˆ          โ–ˆ     โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ       โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ   โ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆ      โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ   โ–ˆโ–ˆ
 โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ      โ–ˆ     โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ   โ–ˆโ–ˆ   โ–ˆโ–ˆ  โ–ˆโ–ˆ   โ–ˆโ–ˆ  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆโ–ˆ    โ–ˆโ–ˆ   โ–ˆโ–ˆ

                    C Y B E R N I T H
                 
> โšก Crafted & unleashed by Soroosh morshedi ~ ( Cybernith ) ~
>  ๐ŸŒ  https://sorooshmorshedi.ir
> โค๏ธ Built with passion 

ๅ…ณไบŽ

Developer Context Intelligence Engine - clean Django architecture with session tracking, context-switch analytics, team RBAC, async GitHub integration, background reporting (Celery), insights, SSE streaming, advanced filtering/export, and full test coverage ๐Ÿ”— https://sorooshmorshedi.ir

Resources

Stars

0 stars

ๅ…ณๆณจ่€…

0 watching

ๅคๅˆปs

ๅ‘ๅธƒ

ๅŒ…

่ดก็Œฎ่€…

Languages