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
- Clone the repository
git clone <repository-url>
cd pyanalypt- Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac- Install dependencies
pip install -r requirements.txt- Configure environment
- Copy
.env.exampleto.env(if exists, or seeenv.mdfor variables) - Update database and Redis URLs
- Add Django secret key
- Run migrations
python manage.py migrate- Create superuser
python manage.py createsuperuser- Run development server
python manage.py runserverServer 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
- URL: http://127.0.0.1:8000/admin/
- Email:
admin@pyanalypt.com - Password:
admin123!@#
๐ API Endpoints
Base URL: /api/v1/
Authentication
POST /auth/registration/- Register new userPOST /auth/login/- Login with email/passwordPOST /auth/logout/- LogoutGET /auth/user/- Get current userPUT /auth/user/- Update user (full)PATCH /auth/user/- Update user (partial)POST /auth/token/- Get JWT tokenPOST /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_nameprofile_picture- URL (from Google OAuth or CDN)email_verified- Boolean (auto-set for Google users)password- Hashedis_staff,is_active,is_superuserdate_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 shellDatabase Utilities
list_tables.py- List all database tablescheck_auth_user.py- Check auth_user table structuretest_auth_user.py- Test AuthUser modeldrop_tables.py- Drop all tables (WARNING: destructive)
๐ฆ Dependencies
See requirements.txt for full list. Key packages:
django>=5.2djangorestframeworkdj-rest-authdjango-allauthdjangorestframework-simplejwtpsycopg[binary](PostgreSQL adapter)django-redisdjango-cors-headersdjango-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