Skip to content
2077collective edited this page Sep 19, 2024 · 7 revisions

Overview

The 2077-CMS project is a custom-built content management system (CMS) designed to manage and publish articles with advanced features such as scheduling, filtering by status, and integration with external services like Redis, Celery, and Django-Mail. The project is structured with a Django backend and uses Django REST Framework (DRF) for API development. The Django backend is consumed on the frontend built with Astro.

Features

1. Article Management

  • Articles have two statuses: Draft and Ready.
  • Only articles with the Ready status are rendered on the client-side.
  • Ability to schedule status changes from Draft to Ready.

2. User Authentication and Author Assignment

  • Articles are associated with authors, with the first author automatically populated as the logged-in user.
  • The system uses UUIDs for article IDs to ensure uniqueness and security.

3. Newsletter Integration

  • Users can subscribe to a newsletter where article threads are automatically sent to their email addresses.
  • Django-Mail is used for handling newsletters, including subscription management and email delivery.
  • Users have the ability to unsubscribe from the newsletter.

4. Scheduling and Periodic Tasks

  • The project utilizes Celery and Celery Beat to manage background tasks such as publishing scheduled articles.
  • Tasks are scheduled using crontab, intervals, or solar events through the Django admin interface.
  • Redis is configured as the broker for Celery tasks.

5. Environment Configuration

  • The project uses separate settings for development and production environments.
  • Environment variables are managed using a .env file, with DJANGO_SETTINGS_MODULE switched between core.config.local for development and core.config.production for production.
  • A Redis server runs on port 6378 on the VPS, while another instance runs on the default port 6379 for local development.

6. Deployment

  • The project is deployed on a VPS using Gunicorn as the WSGI server and Supervisor to manage processes.
  • Nginx serves as the reverse proxy for Gunicorn.
  • Redis is used for caching and as the broker for Celery tasks.

Technical Setup

1. Django and Django REST Framework

  • Models are defined using UUIDs and slugs.
  • Custom admin configurations are used to handle complex relationships like many-to-many associations between articles and categories.

2. Celery Configuration

  • The celery.py configuration dynamically switches between local and production settings based on the environment.
  • Celery Beat is used for scheduling tasks, with periodic tasks defined directly in the code.

3. Redis Configuration

  • Two instances of Redis are running, with one configured on port 6378 to avoid conflicts with the default Redis instance on port 6379.
  • Background saving and snapshotting are carefully managed to avoid performance issues and data loss.

4. Django-Mail Integration

  • Django-Mail Library is used to manage email lists and send newsletters.
  • Users can subscribe and unsubscribe from newsletters through the CMS interface.

Administration

1. Periodic Tasks and Scheduling

  • The Django admin interface allows for management of periodic tasks, clocked tasks, crontabs, intervals, and solar events.
  • Administrators can configure task schedules without directly modifying code.

2. Hiding Unnecessary Admin Options

  • Non-essential models related to periodic tasks, such as Clocked, Crontabs, Intervals, and Solar events, are hidden from the admin dashboard to simplify the interface.

Best Practices

Environment Management

  • Always ensure that DJANGO_SETTINGS_MODULE is correctly set in the environment variables to prevent configuration issues.
  • Use systemctl daemon-reload after making changes to systemd service files, and always monitor the impact of these changes.

Process Monitoring

  • Monitor Celery and Celery Beat using Supervisor, ensuring that logs are properly configured and accessible.

Performance Considerations

  • Running multiple Redis instances can increase server resource usage. Monitor the performance impact and ensure that the system is not overburdened by unnecessary processes.

Future Enhancements

Multi-Project Email Content

  • Consider integrating a feature that allows Django-Mail to generate email content from articles across multiple projects.

Further Optimization

  • Explore further optimizations for Redis and Celery to improve performance, especially under high load conditions.

This wiki serves as the primary documentation for the 2077-CMS project. It should be updated as new features are added or existing ones are modified.


Contributors

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any questions, issues, or suggestions, please open an issue on GitHub.


© 2024 2077-CMS Project. All rights reserved.