Skip to content

jitendra-ky/dragonfly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

164 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Dragonfly Logo

Dragonfly

A production-grade, full-stack real-time messaging platform. Built with Django, React, WebSockets, and industry-standard engineering practices.

Tests CI Codecov release Ruff code style: prettier MIT License Contributors GitHub Stars Docker Maintained


โœจ Features

  • ๐Ÿ”ด Real-time messaging โ€” Persistent WebSocket connections via Django Channels & Daphne (ASGI)
  • ๐Ÿ” JWT authentication โ€” Stateless auth with access/refresh token rotation (SimpleJWT)
  • ๐Ÿ“ง OTP email verification โ€” 6-digit OTP-based account activation on signup
  • ๐Ÿ”‘ Google OAuth 2.0 โ€” One-click sign-in with Google account via OAuth authorization code flow
  • ๐Ÿ”„ Forgot/Reset password โ€” OTP-based secure password recovery
  • ๐Ÿ“ฌ Contact management โ€” Auto-discovery of contacts from message history
  • ๐Ÿฅ Health check endpoint โ€” Production deployment monitoring at /api/health/
  • ๐Ÿณ Dockerized CI pipeline โ€” Tests run in Docker containers on every push/PR via GitHub Actions
  • ๐Ÿš€ Deployed on Render โ€” ASGI server (Daphne) with render.yaml infrastructure-as-code

๐Ÿ—๏ธ System Architecture


๐Ÿ› ๏ธ Tech Stack

Layer Technology
Frontend React 19, Vite 7, React Router v7, Zustand, TailwindCSS
Backend Django, Django REST Framework
Real-time Django Channels, Daphne (ASGI / WebSocket server)
Auth SimpleJWT, Google OAuth 2.0, OTP email verification
Backend Testing Django Test Client, Coverage.py, Codecov
Frontend Testing Vitest, React Testing Library, jsdom
Code Quality Ruff (all rules), Prettier, ESLint
CI/CD GitHub Actions (Tests CI, Docker build & push)
Containerization Docker (Dockerized test environment on CI)
Deployment Render (ASGI), render.yaml infrastructure-as-code

๐Ÿ“ Project Structure

dragonfly/
โ”œโ”€โ”€ .github/
โ”‚   โ”œโ”€โ”€ workflows/
โ”‚   โ”‚   โ”œโ”€โ”€ tests_ci.yml                  # CI: runs backend + frontend tests on every PR
โ”‚   โ”‚   โ”œโ”€โ”€ build_and_push_docker_image.yml
โ”‚   โ”‚   โ””โ”€โ”€ build_and_push_producction_image.yml
โ”‚   โ””โ”€โ”€ ISSUE_TEMPLATE/
โ”‚
โ”œโ”€โ”€ zserver/                              # Core Django application
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ user_profile.py               # Custom User, UnverifiedUser, OTP models
โ”‚   โ”‚   โ””โ”€โ”€ message.py                    # Message model
โ”‚   โ”œโ”€โ”€ views/
โ”‚   โ”‚   โ”œโ”€โ”€ user_profile.py               # Auth, signup, Google OAuth, password reset
โ”‚   โ”‚   โ””โ”€โ”€ message.py                    # Messages, contacts, all-users
โ”‚   โ”œโ”€โ”€ serializers/                      # DRF serializers with business logic
โ”‚   โ”œโ”€โ”€ tests/                            # Comprehensive automated test suite
โ”‚   โ”œโ”€โ”€ consumers.py                      # WebSocket consumer (JWT-authenticated)
โ”‚   โ””โ”€โ”€ urls.py                           # All API route definitions
โ”‚
โ”œโ”€โ”€ frontend/                             # React + Vite SPA
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/                   # Reusable UI components
โ”‚       โ”œโ”€โ”€ pages/                        # Route-level page components
โ”‚       โ”œโ”€โ”€ store/                        # Zustand global state management
โ”‚       โ”œโ”€โ”€ hooks/                        # Custom React hooks
โ”‚       โ”œโ”€โ”€ services/                     # Axios API service layer
โ”‚       โ””โ”€โ”€ types/                        # TypeScript-compatible type definitions
โ”‚
โ”œโ”€โ”€ zproject/                             # Django project config (settings, ASGI, routing)
โ”œโ”€โ”€ tools/dockerfiles/                    # Dockerfiles for CI test environment
โ”œโ”€โ”€ docs/                                 # Developer documentation
โ”œโ”€โ”€ render.yaml                           # Render deployment config (IaC)
โ””โ”€โ”€ pyproject.toml                        # Ruff linting config

๐Ÿ“ฎ API Reference

Authentication & Users

Method Endpoint Auth Description
POST /api/user-profile/ Public Register a new user (triggers OTP email)
POST /api/sign-up-otp/ Public Verify OTP โ†’ activate account + return JWT
POST /api/sign-in/ Public Login with email/password โ†’ return JWT tokens
GET /api/user-profile/ JWT Get authenticated user's profile
PUT /api/user-profile/ JWT Update authenticated user's profile
DELETE /api/user-profile/ JWT Delete authenticated user's account
POST /google-login/ Public Google OAuth 2.0 login โ†’ return JWT
POST /api/forgot-password/ Public Send OTP for password reset
POST /api/reset-password/ Public Reset password using OTP

Messaging

Method Endpoint Auth Description
GET /api/messages/ JWT Fetch message history with a contact
POST /api/messages/ JWT Persist a sent message
GET /api/contacts/ JWT Get all users you've messaged
GET /api/all-users/ JWT Get all registered users

Token & System

Method Endpoint Auth Description
POST /api/token/ Public Obtain JWT token pair
POST /api/token/refresh/ Public Refresh access token
POST /api/token/verify/ Public Verify a token
GET /api/health/ Public Health check for deployment monitoring

WebSocket

Protocol Endpoint Auth Description
WS /ws/chat/?token=<JWT> JWT (query param) Real-time bidirectional messaging

๐Ÿงช Testing & Code Quality

Dragonfly enforces quality at every layer of the stack:

Backend

  • Automated tests run via Django's test client, tracked with coverage.py
  • Coverage reports uploaded to Codecov on every CI run
  • Ruff with all rules enabled for linting + formatting

Frontend

CI Pipeline (GitHub Actions)

  • Backend: Docker container is built, tests run inside it, coverage uploaded to Codecov, Ruff linter verified โ€” all on every push/PR to main
  • Frontend: Dependencies installed, ESLint run, Vitest test suite executed โ€” on every push/PR to main
  • Docker images built and pushed to Docker Hub

๐Ÿš€ Getting Started

See docs/setup-dev-environment.md for the full setup guide.

Quick start:

# 1. Clone the repo
git clone https://github.com/jitendra-ky/dragonfly.git
cd dragonfly

# 2. Copy and configure environment variables
cp .env.example .env
# Edit .env with your settings

# 3. Backend setup
pip install -r requirements/development.txt
python manage.py migrate
python manage.py runserver

# 4. Frontend setup (in a separate terminal)
cd frontend
cp .env.example .env
npm install
npm run dev

๐Ÿค Contributors

We appreciate everyone ๐Ÿ’– who has contributed their time, skills, and passion to make Dragonfly better. Your efforts help drive this project forward โ€” thank you!

How to Contribute

We welcome contributions from everyone! Please review our CONTRIBUTING.md and CODE_OF_CONDUCT.md before getting started.

  1. Fork & Clone โ€” Fork this repo and clone it locally
  2. Branch โ€” Create a new branch for your changes
  3. Implement & Test โ€” Make your changes and run the test suite
  4. Pull Request โ€” Open a PR against main for review

For details, see CONTRIBUTING.md.


MIT License open source

About

Dragonfly is a real-time chat web app, built with Django and modern JavaScript.

Topics

Resources

License

Code of conduct

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Contributors