GithubHelp home page GithubHelp logo

maximzayats / aiogram-django-template Goto Github PK

View Code? Open in Web Editor NEW
114.0 3.0 25.0 550 KB

A template for creating bots with a server and admin panel. Based on aiogram and django.

Python 95.44% Makefile 3.02% Dockerfile 0.39% Shell 1.15%
aiogram django python telegram-bot telegram async

aiogram-django-template's Introduction

Aiogram & Django API Template


Table of Contents


Feature Highlights

This Django API Template is designed to be robust, scalable, and secure, with features that cater to modern application development needs. Here's an overview of the advanced features and how they benefit your project:

  • Docker & Docker Compose Integration: Easily set up and scale your application using Docker containers, ensuring consistent environments across development and production.

  • Celery with RabbitMQ and Redis: Leverage Celery for asynchronous task processing, using RabbitMQ as a message broker and Redis as a backend for storing results.

  • Sentry for Error Tracking: Integrate with Sentry for real-time error tracking and monitoring, helping you identify and fix issues rapidly.

  • Django Rest Framework (DRF): Use Django Rest Framework for building RESTful APIs, with support for authentication, serialization, and more.

  • Django CORS Headers: Use Django CORS Headers for handling Cross-Origin Resource Sharing (CORS) headers, with support for customizing origins.

  • Django Silk for Profiling: Utilize Django Silk for profiling and monitoring Django applications, offering insights into performance and optimization.

  • Django Axes for Security: Use Django Axes for security, with support for blocking brute force attacks and monitoring login attempts.

  • AWS S3 Integration: Option to use Amazon S3 for static and media file storage, enhancing scalability and performance.

  • Scalability Options: Configure workers and threads to optimize performance under different load conditions.

  • Up-to-Date Dependencies: All dependencies are up-to-date as of the latest release. Thanks to Dependabot.


Configuration Guide

The .env file is a central place to manage environment variables. It's pre-configured to work with Docker Compose out of the box, without any changes required for initial setup. However, for production deployment, certain secrets must be updated for security reasons.

  1. Secrets:

    • PostgreSQL, RabbitMQ, Django Secrets: These are critical for the security of your application. Ensure to replace the placeholder values with strong, unique passwords.
  2. Ports:

    • API Port and RabbitMQ Dashboard Port: Set these ports according to your infrastructure needs. They are exposed to the host machine.
  3. Performance Tuning:

    • Workers and Threads: Adjust these values based on your server's capacity and expected load.
  4. Application Settings:

    • Host and Environment: Set these to match your deployment environment.
    • Debug and Logging: Control debug mode and log levels. Set DJANGO_DEBUG to false in production.
    • Localization: Configure LANGUAGE_CODE and TIME_ZONE as per your requirements.
  5. CORS and CSRF Settings:

    • Configure these settings to enhance the security of your application by specifying trusted origins.
  6. Database Configuration:

    • Postgres Connection: Set up the database connection using the DATABASE_URL variable.

Additional Notes

  • Security: Always prioritize security, especially when handling environment variables and secrets.
  • Scalability: Adjust the Docker and Celery configurations as your application scales.
  • Monitoring: Regularly monitor the performance and health of your application using integrated tools like Sentry and Silk.

By following this guide and utilizing the advanced features, you'll be able to set up a powerful, efficient, and secure Django API environment. Happy coding!


Quick Start Guide

Setting Up Locally

1. Repository Initialization

  • Clone the Repository

2. Environment Setup

  • Create a Virtual Environment:
    python3.12 -m venv .venv
  • Activate the Virtual Environment:
    source .venv/bin/activate

3. Configuration

  • Environment Variables:
    • Copy the example environment file:
      cp .env.example .env
    • Note: The API can operate without this step, but configuring the environment variables is recommended for full functionality.

4. Dependency Management

  • Install Dependencies:
    pip install -r requirements-dev.txt

5. Database Setup

  • Run Migrations:
    make migrate

6. Launching the Server

  • Start the Local Server:
    make run.server.local

7. Launching the bot

  • Start the bot:
    make run.bot.local

Setting Up with Docker

1. Repository Initialization

  • Clone the Repository

2. Configuration

3. Docker Compose

  • Run Docker Compose:
    docker compose up -d

aiogram-django-template's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar maksimzayats avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aiogram-django-template's Issues

Migrate to poetry?

Having both requirements.txt and requirements-dev.txt seems unnecessary, this could be solved by using poetry.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.