Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ khadra Public

Khadra is a Django-powered web application for an Algerian non-profit organization dedicated to reforesting Algeria. Our platform connects volunteers with tree-planting initiatives across the country, making it easy to participate in environmental restoration efforts.

Notifications You must be signed in to change notification settings

TonyXdZ/khadra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 Khadra: Reforesting Algeria, One Tree at a Time

🎨 Designers Wanted!

We're looking for talented designers to create a brand identity and logo for Khadra!

If you'd like to contribute your design skills to our environmental cause, please reach out at:

πŸ“§ [email protected]

Your work will be seen by thousands of volunteers helping reforest Algeria!

Khadra is a Django-powered web application for an Algerian non-profit organization dedicated to reforesting Algeria. Our platform connects volunteers with tree-planting initiatives across the country, making it easy to participate in environmental restoration efforts.

🌟 Features

  • Manager Approval System: New initiatives require manager reviews before activation
  • Role Promotion Workflow: Volunteers can request manager status, subject to approval by existing managers
  • Review Period: 7-day voting window for both new initiatives AND role promotion requests
  • Automated Evaluation System: Celery tasks handle:
    • Initiative lifecycle transitions (status changes)
    • Role promotion request evaluations
  • Interactive Tree Map: Visualize planting locations using PostGIS spatial data
  • Volunteer Dashboard: Track your contributions and upcoming events
  • Real-time Notifications: Get alerts about new projects, role changes, and voting outcomes
  • Project Participation: Join planting initiatives with one click

πŸ› οΈ Technology Stack

Backend
Django PostgreSQL PostGIS Celery Redis

Frontend
JavaScript Bootstrap Leaflet

Infrastructure
Docker Docker Compose

πŸš€ Getting Started (Docker Recommended)

Prerequisites

  • Docker 20.10+
  • Docker Compose 2.0+

Docker Setup

# Clone the repository
git clone https://github.com/TonyXdZ/khadra.git
cd khadra

# Build and start all services
docker-compose up --build

# Access the application at:
http://localhost:8000

First-time Setup

After starting the containers:

# Create superuser (required for admin access)
docker-compose exec web python manage.py createsuperuser

# Collect static files (if not already done by entrypoint)
docker-compose exec web python manage.py collectstatic --no-input

How It Works

The system uses an entrypoint script that:

  1. Waits for PostgreSQL and Redis to become available
  2. Runs database migrations automatically
  3. Starts the Django application server

Here's what happens during startup:

[Entrypoint Script]
β”œβ”€β”€ Wait for PostgreSQL (db:5432) βœ…
β”œβ”€β”€ Wait for Redis (redis:6379) βœ…
β”œβ”€β”€ Run database migrations
└── Start server (gunicorn)

Important Notes

  1. The entrypoint script automatically handles database migrations on every startup
  2. You only need to create a superuser once (first setup)
  3. Static files are collected automatically during build
  4. To stop the system: docker-compose down

πŸ”„ Background Tasks (Celery)

Khadra uses Celery for asynchronous task processing. Key tasks include:

Initiative Review Workflow

  1. Manager Notification: Managers receive notifications when new initiatives are created
  2. 7-Day Review Period: Managers have 7 days to vote on new initiatives
  3. Approval Threshold: Requires minimum votes (MIN_INITIATIVE_REVIEWS_REQUIRED) and majority approval

Task Documentation

@shared_task
def evaluate_initiative_reviews_task(initiative_id):
    """
    Evaluates initiative review outcomes after the 7-day review period
    - Checks for minimum required reviews
    - Tallys approve/reject votes
    - Transitions status:
        β€’ 'review_failed' - Insufficient votes or majority rejection
        β€’ 'upcoming' - Approved by managers
    - Sends approval/rejection notifications
    - Schedules future status transitions
    """
    ...

@shared_task
def transition_initiative_to_ongoing_task(initiative_id):
    """
    Transitions initiative to 'ongoing' status at scheduled start time
    - Only transitions if status is 'upcoming'
    - Sends initiative-started notifications
    """
    ...

@shared_task
def transition_initiative_to_completed_task(initiative_id):
    """
    Transitions initiative to 'completed' status at calculated end time
    - Handles both 'ongoing' and delayed 'upcoming' initiatives
    - Sends completion notifications
    """
    ...

Initiative Lifecycle Flowchart

[New Initiative Created]
        ↓
[Notify Managers] β†’ [7-Day Review Period]
        ↓
evaluate_initiative_reviews_task()
        β”œβ”€β”€ Approved β†’ Status: 'upcoming'
        β”‚       β”œβ”€β”€ Schedule β†’ transition_initiative_to_ongoing_task()
        β”‚       └── Schedule β†’ transition_initiative_to_completed_task()
        β”‚
        └── Rejected β†’ Status: 'review_failed'

πŸ—ΊοΈ Project Structure

khadra/
β”œβ”€β”€ core/               # Main app with initiative management
β”‚   β”œβ”€β”€ tasks/          # Celery task definitions for initiatives
β”‚   └── ...             # Other core functionality
β”œβ”€β”€ users/              # User authentication & profiles
β”‚   β”œβ”€β”€ tasks/          # Celery task definitions for user management
β”‚   └── ...             # Other user functionality
β”œβ”€β”€ notifications/      # User notification system
β”œβ”€β”€ geodata/            # Spatial data and mapping functionality
β”œβ”€β”€ static/             # CSS, JS, and images
β”œβ”€β”€ templates/          # HTML templates
β”œβ”€β”€ manage.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
└── requirements.txt

🌲 Key Functionality

Initiative Management

  • Manager Approval: New initiatives require manager consensus
  • Review Voting: Managers approve/reject during 7-day window
  • Automated Transitions:
    • upcoming β†’ ongoing at scheduled start time
    • ongoing β†’ completed after duration ends
  • Status Tracking:
    • review_pending: Waiting for manager votes
    • review_failed: Rejected or insufficient votes
    • upcoming: Approved, not yet started
    • ongoing: Currently active
    • completed: Finished initiative

User System

  • Role-Based Access:
    • All new users start as Volunteers
    • Volunteers can request manager status through promotion requests
  • Account Lifecycle:
    • Volunteer signup with email verification
    • (Future: Social login via Google/Facebook)
    • Manager promotion workflow:
      1. Volunteer submits promotion request
      2. Existing managers vote during 7-day window
      3. Automated approval/rejection based on voting consensus
  • Privileges:
    • Volunteers: Participate in initiatives, track contributions
    • Managers: Approve/reject new initiatives AND promotion requests
  • Personalized dashboard showing:
    • Participation history
    • Current promotion request status
    • Pending votes (for managers)

🀝 How to Contribute

We welcome contributions from developers passionate about environmental conservation!

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

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 - see the LICENSE file for details.

πŸ“§ Contact

For inquiries about the project, partnership opportunities, or design contributions:


Together, let's make Algeria green again! πŸŒ³πŸ‡©πŸ‡Ώ

About

Khadra is a Django-powered web application for an Algerian non-profit organization dedicated to reforesting Algeria. Our platform connects volunteers with tree-planting initiatives across the country, making it easy to participate in environmental restoration efforts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages