Skip to content

Latest commit

Β 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š MD Books Library

A full-featured web application for publishing, reading, and managing books written in Markdown format. Built with Django, it provides a complete platform for authors to publish their work and readers to discover, read, and review content.


πŸš€ Features

For Readers

  • πŸ“– Browse & Discover β€” Explore books by category, tags, popularity, or search
  • πŸ“‘ Markdown Rendering β€” Read chapters with beautifully rendered Markdown content
  • ⭐ Reviews & Ratings β€” Rate books (1–5 stars) and write detailed reviews
  • πŸ” Search & Filter β€” Find books by title, category, tag, or sort by popularity/rating
  • πŸ‘οΈ View Tracking β€” See how popular each book is
  • πŸ‘€ Public Profiles β€” View author profiles with their published works

For Authors

  • ✍️ Book Publishing β€” Create books with cover images, descriptions, and tags
  • πŸ“ Chapter Management β€” Write chapters in Markdown with ordering support
  • πŸ“Š Statistics β€” Track views, likes, ratings, and review counts
  • πŸ“ Category Requests β€” Propose new categories for your books
  • 🏷️ Flexible Tagging β€” Tag books with relevant keywords for discovery
  • πŸ“‹ Draft System β€” Save books and chapters as drafts before publishing

For Moderators

  • βœ… Category Approval β€” Review and approve/reject category requests
  • πŸŽ›οΈ Django Admin β€” Full admin interface with custom actions and dashboards
  • πŸ“Š Bulk Operations β€” Publish/unpublish books, approve categories in bulk

Platform Features

  • πŸ” Authentication β€” Login, logout, password reset, and profile management
  • πŸ’³ Donation Tracking β€” Stripe and PayPal integration for supporter donations
  • πŸ”— Social Profiles β€” GitHub, YouTube, Twitter, and website links
  • πŸ“± Responsive Design β€” Bootstrap 5 based responsive UI

πŸ› οΈ Tech Stack

Layer Technology
Backend Python 3.11+, Django 5.x
Database SQLite (dev) / PostgreSQL (prod)
Frontend HTML5, Bootstrap 5, JavaScript
Content Markdown (rendered to HTML)
Images Pillow, Django ImageField
Admin Django Admin (customized)
Auth Django built-in authentication
Payments Stripe, PayPal (integration ready)

πŸ“ Project Structure

md-books-library/
β”œβ”€β”€ manage.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”‚
β”œβ”€β”€ config/                          # Project configuration
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ settings.py                  # Django settings
β”‚   β”œβ”€β”€ urls.py                      # Root URL configuration
β”‚   β”œβ”€β”€ asgi.py
β”‚   └── wsgi.py
β”‚
β”œβ”€β”€ accounts/                        # User accounts & profiles
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ apps.py                      # AppConfig with signal registration
β”‚   β”œβ”€β”€ models.py                    # Profile model
β”‚   β”œβ”€β”€ forms.py                     # UserForm, ProfileForm
β”‚   β”œβ”€β”€ views.py                     # ProfileView, PublicProfileView
β”‚   β”œβ”€β”€ urls.py                      # Auth & profile URLs
β”‚   β”œβ”€β”€ admin.py                     # ProfileAdmin
β”‚   └── signals.py                   # Auto-create Profile on User creation
β”‚
β”œβ”€β”€ books/                           # Core library application
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ apps.py                      # AppConfig
β”‚   β”œβ”€β”€ admin.py                     # Admin for all book models
β”‚   β”œβ”€β”€ urls.py                      # All book-related URLs
β”‚   β”‚
β”‚   β”œβ”€β”€ models/                      # Data models
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ category.py              # Category (with approval workflow)
β”‚   β”‚   β”œβ”€β”€ tag.py                   # Tag (keyword labels)
β”‚   β”‚   β”œβ”€β”€ book.py                  # Book (main entity)
β”‚   β”‚   β”œβ”€β”€ chapter.py               # Chapter (Markdown content)
β”‚   β”‚   └── review.py                # Review (ratings & comments)
β”‚   β”‚
β”‚   β”œβ”€β”€ forms/                       # Form classes
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ book.py                  # BookForm
β”‚   β”‚   β”œβ”€β”€ category.py              # CategoryForm
β”‚   β”‚   β”œβ”€β”€ chapter.py               # ChapterForm
β”‚   β”‚   β”œβ”€β”€ review.py                # ReviewForm
β”‚   β”‚   └── tag.py                   # TagForm
β”‚   β”‚
β”‚   β”œβ”€β”€ views/                       # View classes (CBV)
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ book.py                  # BookListView, DetailView, Create, Update
β”‚   β”‚   β”œβ”€β”€ category.py              # Category views with approval workflow
β”‚   β”‚   β”œβ”€β”€ chapter.py               # Chapter views with Markdown rendering
β”‚   β”‚   β”œβ”€β”€ review.py                # Review views with duplicate prevention
β”‚   β”‚   └── tag.py                   # Tag views with tag cloud
β”‚   β”‚
β”‚   └── templates/books/             # HTML templates
β”‚       β”œβ”€β”€ book/
β”‚       β”œβ”€β”€ category/
β”‚       β”œβ”€β”€ chapter/
β”‚       β”œβ”€β”€ review/
β”‚       └── tag/
β”‚
β”œβ”€β”€ core/                            # Core pages
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ apps.py
β”‚   β”œβ”€β”€ views.py                     # HomeView (landing page)
β”‚   β”œβ”€β”€ urls.py
β”‚   └── templates/core/
β”‚       └── home.html
β”‚
β”œβ”€β”€ templates/                       # Global templates
β”‚   └── base.html                    # Base template with Bootstrap
β”‚
β”œβ”€β”€ static/                          # Static files
β”‚   β”œβ”€β”€ css/
β”‚   β”œβ”€β”€ js/
β”‚   └── images/
β”‚
└── media/                           # User-uploaded files
    β”œβ”€β”€ avatars/                     # Profile pictures
    └── books/                       # Book covers & category images

πŸ—οΈ Model Relationships

User (Django auth)
 β”‚
 └──< Profile (OneToOne)
       β”‚
       β”œβ”€β”€< Book (author) ──────────────────┐
       β”‚      β”‚                             β”‚
       β”‚      β”œβ”€β”€< Chapter (book)           β”‚
       β”‚      β”œβ”€β”€< Review (book, author) ────
       β”‚      β”œβ”€β”€> Category (FK, nullable)  β”‚
       β”‚      └──<> Tag (M2M)              β”‚
       β”‚                                    β”‚
       β”œβ”€β”€< Category (request author) β”€β”€β”€β”€β”€β”€β”˜
       └──< Category (reviewed_by)
Model Description Key Fields
Profile Extended user profile avatar, bio, social links, donations
Book A published work title, slug, description, views, likes
Chapter Book section with Markdown title, content, order, is_published
Category Book classification (with approval) title, status, author, reviewed_by
Tag Keyword label name, slug
Review User rating & feedback rating (1-5), comment

πŸ“¦ Installation

Prerequisites

  • Python 3.11 or higher
  • pip (Python package manager)
  • Git

Step 1: Clone the Repository

git clone https://github.com/yourusername/md-books-library.git
cd md-books-library

Step 2: Create Virtual Environment

# Linux/Mac
python -m venv venv
source venv/bin/activate

# Windows (CMD)
python -m venv venv
venv\Scripts\activate

# Windows (PowerShell)
python -m venv venv
venv\Scripts\Activate.ps1

Step 3: Install Dependencies

pip install -r requirements.txt

Step 4: Configure Environment Variables

Create a .env file in the project root:

DEBUG=True
SECRET_KEY=your-secret-key-here
DATABASE_URL=sqlite:///db.sqlite3
MEDIA_URL=/media/
MEDIA_ROOT=media/

Step 5: Run Migrations

python manage.py makemigrations
python manage.py migrate

Step 6: Create Superuser

python manage.py createsuperuser

Step 7: Collect Static Files

python manage.py collectstatic

Step 8: Run Development Server

python manage.py runserver

Visit http://127.0.0.1:8000/ to see the application.


πŸ”— URL Routes

Core

URL View Description
/ HomeView Landing page with featured content

Accounts (/accounts/)

URL View Access
/accounts/login/ LoginView Public
/accounts/logout/ LogoutView Authenticated
/accounts/profile/ ProfileView Authenticated
/accounts/profile/<username>/ PublicProfileView Authenticated
/accounts/password/change/ PasswordChangeView Authenticated
/accounts/password/reset/ PasswordResetView Public

Books (/books/)

URL View Access
/books/ BookListView Public
/books/book/<slug>/ BookDetailView Public
/books/book/create/ BookCreateView Authenticated
/books/book/<slug>/edit/ BookUpdateView Author only

Categories

URL View Access
/books/categories/ CategoryListView Public
/books/category/<slug>/ CategoryDetailView Public
/books/category/create/ CategoryCreateView Authenticated
/books/category/<slug>/edit/ CategoryUpdateView Author (pending only)

Chapters

URL View Access
/books/book/<book_slug>/chapters/ ChapterListView Public
/books/book/<book_slug>/chapter/<slug>/ ChapterDetailView Public
/books/book/<book_slug>/chapter/create/ ChapterCreateView Book author
/books/book/<book_slug>/chapter/<slug>/edit/ ChapterUpdateView Book author

Reviews

URL View Access
/books/reviews/ ReviewListView Public
/books/review/<pk>/ ReviewDetailView Public
/books/book/<book_slug>/review/create/ ReviewCreateView Authenticated
/books/review/<pk>/edit/ ReviewUpdateView Review author

Tags

URL View Access
/books/tags/ TagListView Public
/books/tag/<slug>/ TagDetailView Public
/books/tag/create/ TagCreateView Authenticated
/books/tag/<slug>/edit/ TagUpdateView Staff only

Admin

URL Access
/admin/ Staff/Superuser

βš™οΈ Configuration

Settings (config/settings.py)

Key settings to configure:

# Security
SECRET_KEY = os.environ.get('SECRET_KEY', 'your-secret-key')
DEBUG = os.environ.get('DEBUG', 'True') == 'True'
ALLOWED_HOSTS = ['localhost', '127.0.0.1']

# Database
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

# Installed Apps
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    
    # Local apps
    'accounts.apps.AccountsConfig',
    'books.apps.BooksConfig',
    'core.apps.CoreConfig',
]

# Media files (user uploads)
MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

# Static files
STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles'

Production Deployment

For production, update these settings:

DEBUG = False
ALLOWED_HOSTS = ['yourdomain.com']

# Use PostgreSQL
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'md_books_library',
        'USER': 'db_user',
        'PASSWORD': 'db_password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

# Security settings
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_HSTS_SECONDS = 31536000

πŸŽ›οΈ Django Admin

The admin interface is fully customized with:

  • Avatar thumbnails and status badges
  • Inline editing for chapters and reviews within books
  • Custom actions for bulk publish/unpublish/approve/reject
  • Query optimization to prevent N+1 problems
  • Clickable links between related objects
  • Star ratings and formatted statistics

Access at: http://127.0.0.1:8000/admin/


πŸ“ Development

Running Tests

python manage.py test

Code Formatting

pip install black isort
black .
isort .

Making Migrations

python manage.py makemigrations
python manage.py migrate

Creating a New Feature

  1. Create a new branch:

    git checkout -b feature/your-feature-name
  2. Make your changes

  3. Run tests:

    python manage.py test
  4. Commit and push:

    git add .
    git commit -m "Add: your feature description"
    git push origin feature/your-feature-name
  5. Open a Pull Request


πŸ“‹ TODO / Roadmap

High Priority

  • Markdown rendering with syntax highlighting
  • Image optimization with django-imagekit
  • Full-text search with PostgreSQL SearchVector
  • Caching with Redis
  • Email notifications for category approval/rejection

Medium Priority

  • AJAX tag autocomplete
  • Live Markdown preview in chapter editor
  • User follow system
  • Reading progress tracking
  • Book bookmarks/favorites
  • Category moderation dashboard

Low Priority

  • REST API with Django REST Framework
  • Social authentication (Google, GitHub)
  • Two-factor authentication
  • Export books as PDF/EPUB
  • Collaborative editing
  • Analytics dashboard

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Follow PEP 8 guidelines
  • Use Black for code formatting
  • Add docstrings to all classes and methods
  • Write tests for new features

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


πŸ™ Acknowledgments

  • Django β€” The web framework for perfectionists with deadlines
  • Bootstrap β€” Frontend component library
  • Python-Markdown β€” Markdown to HTML conversion

πŸ“§ Contact


Made with ❀️ and Django

Since the project is being thrown together on a whim in spare time, an AI is writing the comments.)))

About

A full-featured Django web application for publishing, reading, and managing books written in Markdown and another formats. Includes user profiles, 5-star reviews, category moderation workflows, and donation tracking.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages