Git Product home page Git Product logo

djangoforge's Introduction

DjangoForge: User Manual

Deployment Status


Introduction

Welcome to the DjangoForge User Manual! DjangoForge is a Django-based project, designed to streamline deployment and enhance business operations for small to medium-sized enterprises (SMEs). This manual provides comprehensive guidance on how to deploy and maintain the project using GitHub Actions.

Project Overview

DjangoForge is built around a tiered architecture, offering a scalable solution tailored to various business needs:

  1. Base Project: Core functionality and generic apps that serve as the foundation of the ecosystem.
  2. Tier 1 Applications: Common business apps such as CRM, ERP, and inventory management that build on the Base Project.
  3. Tier 2 Applications: Industry-specific extensions, providing advanced features and customizations.

Technologies and Infrastructure

  • Framework: Django
  • Databases:
    • Default: Primary database for raw data storage.
    • Gold: Business intelligence database for refined and aggregated data.
  • Containerization: Managed with Docker and Docker Compose for both development and production environments.
  • CI/CD: Automated with GitHub Actions for seamless deployment to cloud services like Digital Ocean, with plans for future PaaS integration.

Project Structure

1. Logging App

  • Purpose: Collects and aggregates logs for HTTP requests and errors.
  • Key Components:
    • Models: base.py, aggregated.py
    • Tasks: aggregate_access_logs.py, aggregate_error_logs.py
    • Views: base.py, aggregated.py

2. Website App

  • Purpose: Manages the website frontend and acts as a basic CMS.
  • Planned Updates: Streamlining to focus on static page rendering.

3. Backoffice App

  • Purpose: Provides backend management tools and data visualization.
  • Planned Updates: Modularization and integration with Gold BI for enhanced data insights.

4. Gold BI

  • Purpose: Handles ETL (Extract, Transform, Load) processes and task scheduling using Django Q.
  • Planned Updates: Enhanced task scheduling capabilities.

Project Setup

Create a Repository from the Template

  1. On the GitHub repository page, click "Use this template."
  2. Create a new repository based on the template.

Clone the Repository Locally

git clone --recursive https://github.com/your-username/your-new-repo.git your-new-repo
cd your-new-repo
git remote add template https://github.com/leoBitto/DjangoForge.git
git remote add origin https://github.com/your-username/your-new-repo.git

To fetch updates from DjangoForge:

git fetch --all
git merge template/main --allow-unrelated-histories

Project Development

Adding New Apps

  1. Clone the required apps as submodules into the src directory.

    git submodule add <URL to submodule> src/<name of app>
  2. Update settings.py to include your apps, and modify urls.py accordingly. Use git add, git commit, and git push to save changes.

Using manager.sh

The manager.sh script simplifies project management:

  • source manager.sh build: Builds and starts containers, applies migrations, runs collectstatic, and prompts for superuser creation.
  • source manager.sh start: Starts containers.
  • source manager.sh stop: Stops containers.
  • source manager.sh destroy: Destroys containers.

After building, the application will be accessible at http://localhost.


Project Deployment

Prerequisites

  • GitHub account
  • DigitalOcean account (or similar IaaS provider)

Tip: Begin with Django's development server for initial testing before moving to Docker.

Warning: Update the IMAGE_NAME in the CI/CD workflow files to control the image name displayed in GitHub's packages tab.

Deploying to DigitalOcean

  1. Log in to DigitalOcean.
  2. Navigate to "Droplets" and click "Create Droplet."
  3. Configure options (distribution, size, datacenter, etc.).
  4. Choose "SSH Key" for authentication, and select/create an SSH key pair.
  5. Click "Create Droplet."

Note: DigitalOcean is used here as an example; other IaaS providers are also supported.

Creating SSH Keys

  1. Generate an SSH key pair:

    ssh-keygen -t ed25519 -C "[email protected]"
  2. Add your private key to the ssh-agent:

    eval "$(ssh-agent -s)"
    ssh-add ~/.ssh/id_ed25519
  3. Copy your public key:

    cat ~/.ssh/id_ed25519.pub
  4. Add this public key to your GitHub account and save the private key as a GitHub secret under "Settings" -> "Secrets."

Configuring GitHub Secrets

Add the following secrets to your GitHub repository:

  • DEBUG: False
  • DOMAIN: Your domain or IP address
  • EMAIL: Valid email for SSL
  • GHCR_TOKEN: GitHub token
  • HOST: Droplet IP address
  • POSTGRES_DB: Database name
  • POSTGRES_PASSWORD: Database password
  • POSTGRES_USER: Database user
  • PRIVATE_KEY: Server private key
  • SECRET_KEY: Django secret key
  • USERNAME: root

Important: Ensure that the IMAGE_NAME in build-and-push.yml is lowercase.

Initiating Deployment

Once the secrets are configured, manually start the workflow in server_setup.yml to set up the server, providing domain names or IP addresses for SSL configuration via Certbot.


Project Components

1. Purpose and Philosophy

  • Project Purpose: Centralize and automate data management for SMEs using Business Intelligence (BI).
  • Target Users: SMEs in sectors like distribution, restaurants, and craft industries.
  • Philosophy: Democratize access to BI tools, making them affordable and scalable for businesses of all sizes.

2. Main System Components

  • Logging App: Aggregates and manages logs.
  • Website App: Basic CMS for frontend management.
  • Backoffice App: Tools for backend management.
  • Gold BI: ETL processing and task scheduling with Django Q.

3. Interaction Between Components

  • Components interact through Django's native functionality, ensuring seamless communication across apps.

Development and Production Environments

1. Development Environment

Docker Configuration:

  • Dockerfile: Builds the app image, installs dependencies, and configures the Gunicorn server.
  • Docker Compose for Development (docker-compose.dev.yml):
    • Services: Includes web, djangoq, db, db_gold, and nginx.
    • Volumes: Persist data like databases and media files.
    • Network: Bridges services for internal communication.

Management Script (manager.sh):

  • Simplifies common tasks like building, starting, stopping, and destroying containers.

2. Production Environment

Docker Compose for Production (docker-compose.prod.yml):

  • Similar to the development setup, but tailored for production with pre-built Docker images and secure configurations.

Backoffice App Documentation

Overview

The backoffice app offers a comprehensive administrative interface, integrating tools from the logging_app and gold_bi for consistent UI and data management.

Structure and Configuration

  • Template: backoffice_base.html for consistent layout.
  • Views: Includes a dashboard requiring authentication.
  • URLs: Mapped in backoffice/urls.py.
  • Dependencies: Utilizes Bootstrap, DataTables, HTMX, and FontAwesome for a modern, interactive interface.

Usage

  • Accessible by logging in, with users directed to the main dashboard for app management.

Gold BI App Documentation

Overview

The gold_bi app manages ETL processes and data aggregation, using Django Q for task scheduling.

Structure

  • Models, Views, Forms: Handles data management and user interactions. Models defined here are for aggregated informations that require models from more than 1 app Views define the views that allow to choose the type of report you want Forms define the structure to give information to views regardin the report type
  • Task Scheduling: Managed via tasks_scheduler.py with scheduling using Django Q.

Logging App Documentation

Overview

The logging_app tracks and manages access and error logs.

Configuration

  • Middleware: Ensure it’s added to MIDDLEWARE in settings.py.
  • Periodic Tasks: Set up with Celery or Django Q for log aggregation.

Views and Templates

  • Views: Handle log listing and details.
  • Templates: Include base and detailed log views.

Integration

  • URL Configuration: Defined in urls.py.
  • Static Assets: CSS and JS should be included in the static directory.

Website App Documentation

Overview

The website app provides basic CMS functionality for managing frontend content.

Structure

  • Templates and Views: Manage content display and user interactions.
  • URLs: Define routes for different pages.

Configuration

  • **Static and Media Files

**: Managed via Django settings.

  • Authentication: Implement admin access for content management.

Final Notes

For further assistance or to report issues, please refer to the DjangoForge GitHub repository or contact support.


djangoforge's People

Contributors

leobitto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

djangoforge's Issues

add ssl

use certbot docker image to create certification for ssl

Tips on how to run it locally?

Hi, trying your codebase and was wondering if you can give me tips on how to run it locally. Or how I can change settings.py to make it work locally. the logging_app seems to be missing.

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.