GitHunt
LI

limkhysok/pyanalypt

A Django-based data analytics platform providing a RESTful API for dataset management, automated data cleaning, smart statistical insights, and project tracking.

PyAnalypt - Analytics Platform

A Django-based analytics platform with RESTful API, JWT authentication, and Google OAuth integration.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.13+
  • PostgreSQL database
  • Redis (for caching)

Installation

  1. Clone the repository
git clone <repository-url>
cd pyanalypt
  1. Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Linux/Mac
  1. Install dependencies
pip install -r requirements.txt
  1. Configure environment
  • Copy .env.example to .env (if exists, or see env.md for variables)
  • Update database and Redis URLs
  • Add Django secret key
  1. Run migrations
python manage.py migrate
  1. Create superuser
python manage.py createsuperuser
  1. Run development server
python manage.py runserver

Server runs at: http://127.0.0.1:8000/


๐Ÿ“š Documentation

Document Description
API_DOCS.md Complete API documentation with all endpoints
plans.md Project planning and roadmap
mermaid_live.md Database schema diagrams
env.md Environment variables reference

๐Ÿ”‘ Admin Access


๐ŸŒ API Endpoints

Base URL: /api/v1/

Authentication

  • POST /auth/registration/ - Register new user
  • POST /auth/login/ - Login with email/password
  • POST /auth/logout/ - Logout
  • GET /auth/user/ - Get current user
  • PUT /auth/user/ - Update user (full)
  • PATCH /auth/user/ - Update user (partial)
  • POST /auth/token/ - Get JWT token
  • POST /auth/token/refresh/ - Refresh JWT token

OAuth

  • GET /accounts/google/login/ - Google OAuth login

File Operations

  • POST /upload/ - Upload file for analysis

See API_DOCS.md for complete documentation.


๐Ÿ—๏ธ Project Structure

pyanalypt/
โ”œโ”€โ”€ config/              # Django settings and main URLs
โ”‚   โ”œโ”€โ”€ settings.py      # Main settings
โ”‚   โ”œโ”€โ”€ urls.py          # Root URL configuration
โ”‚   โ””โ”€โ”€ wsgi.py          # WSGI configuration
โ”œโ”€โ”€ core/                # Core application
โ”‚   โ”œโ”€โ”€ models/          # Database models
โ”‚   โ”‚   โ””โ”€โ”€ auth_user.py # Custom user model
โ”‚   โ”œโ”€โ”€ adapters.py      # Google OAuth adapter
โ”‚   โ”œโ”€โ”€ admin.py         # Admin configuration
โ”‚   โ”œโ”€โ”€ urls.py          # App URL patterns
โ”‚   โ””โ”€โ”€ views.py         # API views
โ”œโ”€โ”€ uploads/             # Uploaded files
โ”œโ”€โ”€ venv/                # Virtual environment
โ”œโ”€โ”€ .env                 # Environment variables (not in git)
โ”œโ”€โ”€ .gitignore           # Git ignore rules
โ”œโ”€โ”€ manage.py            # Django management script
โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ””โ”€โ”€ API_DOCS.md          # API documentation

๐Ÿ” Authentication System

Features

  • โœ… Email-based authentication
  • โœ… JWT token management (access + refresh)
  • โœ… Token rotation and blacklisting
  • โœ… Google OAuth integration
  • โœ… Custom user model with validations
  • โœ… Password reset functionality

Custom User Model

Model: core.models.AuthUser

Fields:

  • email - Primary authentication field (unique)
  • username - Display name (unique)
  • first_name, last_name, full_name
  • profile_picture - URL (from Google OAuth or CDN)
  • email_verified - Boolean (auto-set for Google users)
  • password - Hashed
  • is_staff, is_active, is_superuser
  • date_joined, last_login

Validations:

  • Email: Valid email format, unique
  • Username: Alphanumeric + ._-, min 3 chars
  • Names: Letters, hyphens, apostrophes, min 2 chars
  • Full name: Letters + spaces, min 10 chars
  • Password: Min 8 chars, validated by Django settings
  • Profile picture: HTTPS only

Google OAuth

Automatically extracts and populates:

  • Email โ†’ user.email
  • First/Last name โ†’ user.first_name, user.last_name
  • Full name โ†’ user.full_name
  • Profile picture โ†’ user.profile_picture
  • Email verified โ†’ user.email_verified = True

๐Ÿ› ๏ธ Tech Stack

Backend

  • Django 5.2+ - Web framework
  • Django REST Framework - API framework
  • dj-rest-auth - Authentication endpoints
  • django-allauth - Social authentication
  • djangorestframework-simplejwt - JWT tokens
  • PostgreSQL - Database
  • Redis - Caching

Authentication

  • Email/password login
  • Google OAuth 2.0
  • JWT (JSON Web Tokens)

Database

  • PostgreSQL for data persistence
  • Redis for session/cache storage

๐Ÿงช Testing

Test API with cURL

Register:

curl -X POST http://127.0.0.1:8000/api/v1/auth/registration/ \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","username":"test","password1":"Pass123!","password2":"Pass123!"}'

Login:

curl -X POST http://127.0.0.1:8000/api/v1/auth/token/ \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"Pass123!"}'

Get User:

curl -X GET http://127.0.0.1:8000/api/v1/auth/user/ \
  -H "Authorization: Bearer <access_token>"

๐Ÿ’ก Development Tips

Useful Commands

# Run development server
python manage.py runserver

# Create superuser
python manage.py createsuperuser

# Make migrations
python manage.py makemigrations

# Apply migrations
python manage.py migrate

# Check database tables
python list_tables.py

# Django shell
python manage.py shell

Database Utilities

  • list_tables.py - List all database tables
  • check_auth_user.py - Check auth_user table structure
  • test_auth_user.py - Test AuthUser model
  • drop_tables.py - Drop all tables (WARNING: destructive)

๐Ÿ“ฆ Dependencies

See requirements.txt for full list. Key packages:

  • django>=5.2
  • djangorestframework
  • dj-rest-auth
  • django-allauth
  • djangorestframework-simplejwt
  • psycopg[binary] (PostgreSQL adapter)
  • django-redis
  • django-cors-headers
  • django-environ

๐Ÿ”’ Security

  • โœ… JWT token authentication
  • โœ… Token rotation and blacklisting
  • โœ… HTTPS enforcement for profile pictures
  • โœ… Password hashing (Django default)
  • โœ… CORS configuration
  • โœ… Email verification support
  • โœ… Rate limiting (to be implemented)

Production Checklist:

  • Set DEBUG = False
  • Configure proper ALLOWED_HOSTS
  • Use environment variables for secrets
  • Set up HTTPS/SSL
  • Configure email backend for verifications
  • Update Google OAuth redirect URIs
  • Set up proper logging
  • Configure rate limiting

๐Ÿ“ License

To be determined


๐Ÿ‘ฅ Contributors

To be added


Version: 1.0
Status: โœ… Production Ready
Last Updated: 2026-02-10