Just a test project in order to learn Django by tackling a real-world problem!
Find a file
badbl0cks 48ea0eb48e
fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup
This commit comprehensively addresses issues with the local development and debugging environment, ensuring a smoother and more reliable developer experience.

Key changes include:

- **VSCode Debugger:** Corrected launch configuration (`.vscode/launch.json`) to properly run the Django development server with debugging enabled. It now correctly sets `DEBUG=True`, uses `0.0.0.0:8000`, and specifies the correct working directory.
- **Docker Compose:** Exposed the PostgreSQL port (`5432:5432`) in `docker-compose.yml` to allow direct connections from the host, facilitating local development and debugging without needing to run the full application stack.
- **Environment Variables:**
    - Updated `.gitignore` to ignore all `.env.*` files, allowing for environment-specific configurations.
    - Modified `src/pkmntrade_club/django_project/settings.py` to use `localhost` for `DJANGO_DATABASE_URL` and `REDIS_URL` by default, aligning with the exposed Docker services for easier local development. Default `DISABLE_SIGNUPS` and `DISABLE_CACHE` are now `True` for a more typical local dev setup.
- **Management Commands & Scripts:**
    - Adjusted `manage.py` to correctly append the project's root directory to `sys.path`, resolving potential import issues when running management commands.
    - Significantly improved `scripts/reset-db_make-migrations_seed-data.sh`:
        - Removed reliance on sourcing `.env` directly.
        - Ensured the database service (`db`) is started independently before migrations.
        - Added explicit steps for running `prebuild.sh`, migrations, and `collectstatic`.
        - Switched to using `uv run manage.py loaddata` for seeding, which is more consistent with the project's tooling.
- **Django Settings:** Added `SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"` and `SESSION_COOKIE_HTTPONLY = True` for improved session management and security.

These changes collectively fix the previously problematic development setup, enabling straightforward debugging and a more efficient workflow for local development.
2025-06-01 19:06:56 -07:00
.devcontainer Devcontainer minor fixes 2025-05-18 11:29:27 -07:00
.github/workflows feat: Implement dynamic Gatekeeper proxy and enhance service health monitoring 2025-05-23 00:15:19 -07:00
.vscode fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
scripts fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
seed reorganizing build scripts 2025-04-17 16:21:26 -07:00
server fix(docker): Add missing ALLOWED_HOSTS environment variables to docker-compose_web.yml and docker-compose_staging.yml to prevent security errors. 2025-05-23 21:54:55 -07:00
src/pkmntrade_club fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
.cursorrules progress on conversion to tailwind 2025-03-11 23:47:20 -07:00
.dockerignore Packaging fixes 2025-05-09 08:43:43 -07:00
.envrc refactor(docker): Enhance settings.py and deployment 2025-05-23 18:46:29 -07:00
.gitignore fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
.python-version progress on conversion to tailwind 2025-03-11 23:47:20 -07:00
CONTRIBUTING.md Complete refactor of environment configuration and Docker setup for development and production. 2025-05-05 21:48:59 -07:00
docker-compose.yml fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
Dockerfile feat(dev): Enable hot reloading and streamline local development 2025-05-23 21:19:33 -07:00
fly.toml build fixes and static files fix, closes #28 2025-04-19 17:10:46 -07:00
LICENSE reorganizing build scripts 2025-04-17 16:21:26 -07:00
locustfile.py add locust load testing 2025-04-19 17:11:19 -07:00
manage.py fix(dev): Resolve Dev Debug Environment Issues and Streamline Local Setup 2025-06-01 19:06:56 -07:00
MANIFEST.in fix manifest.in to properly include package files, and fix docker-compose web and staging to use the correct tags (stable and staging) instead of edge 2025-05-18 20:29:39 -07:00
pyproject.toml refactor(docker): Enhance settings.py and deployment 2025-05-23 18:46:29 -07:00
README.md Major refactoring of build_deploy action, along with docker building and packaging improvements. Added no_signups and other .env improvements. There is no longer a separate .env.dev, both use .env now. 2025-05-18 11:27:59 -07:00
uv.lock refactor(docker): Enhance settings.py and deployment 2025-05-23 18:46:29 -07:00

PKMN Trade Club

PKMN Trade Club is a Django-powered application built to connect Pokémon TCG Pocket trading enthusiasts in a secure, scalable, and community-driven environment. This platform leverages Djangos robust features and stability, a modular project structure, and best practices to deliver a smooth trading experience.

Table of Contents

Features

  • Django & Python: Built with Django 5.1 and Python 3.12.
  • Modular Architecture: Separate Django apps for trades, accounts, cards, and more.
  • User Authentication: Comprehensive authentication powered by Django Allauth.
  • Responsive UI: Custom theming with Tailwind CSS, DaisyUI, and AlpineJS.
  • Production-Ready: Docker and PostgreSQL configuration for scalable deployments.
  • Development Tools: Built-in support for migrations, testing, and seeding initial data.
  • Security & Performance: Carefully configured for deployment with production best practices.

Installation

Local Development

  1. Clone the repository:

    git clone https://git.badblocks.dev/badbl0cks/pkmntrade.club.git
    cd pkmntrade.club
    
  2. Install dependencies via uv:

    uv pip install -r requirements.txt
    
  3. Configure environment variables:

    Copy the example environment file and update credentials as needed:

    cp .env.example .env
    
  4. Apply migrations and seed initial data:

    python manage.py migrate
    python manage.py createsuperuser
    python manage.py createcachetable django_cache
    
  5. Start the development server:

    uv run manage.py runserver
    

    Visit http://127.0.0.1:8000 in your browser.

Docker Deployment

  1. Build and run containers:

    docker-compose up -d --build
    
  2. Run migrations and create a superuser inside the container:

    docker-compose exec web python manage.py migrate
    docker-compose exec web python manage.py createsuperuser
    docker-compose exec web python manage.py createcachetable django_cache
    
  3. Access the site:

    Open http://127.0.0.1:8000

Configuration

  • Environment Variables:
    Manage your local vs. production settings using .env and .env.production. Update these to match your database credentials, secret keys, and other configurations.

  • Django Settings:
    Production settings are in django_project/settings.py.

  • Database Settings:
    Example configuration for PostgreSQL:

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'NAME': 'postgres',
            'USER': 'postgres',
            'PASSWORD': 'postgres',
            'HOST': 'db',  # as defined in docker-compose.yml
            'PORT': 5432,
        }
    }
    

Database

The platform uses PostgreSQL as its primary database in production. For local development, you may use SQLite or configure PostgreSQL by updating your settings and environment variables as needed.

Running Tests

Run Djangos testing suite with:

python manage.py test

Deployment

For production deployments consider these additional steps:

  • Production Server: Use a web server like Gunicorn.
  • Static Files: Serve static files using Djangos WhiteNoise (or via a CDN).
  • Fly.io Configuration: A fly.toml file is provided if you wish to deploy on Fly.io.
  • Deployment Scripts: Use deploy.sh for automated deployment tasks.
  • Security & Email: Update DEFAULT_FROM_EMAIL, ALLOWED_HOSTS, and other security settings in django_project/settings.py.

Contributing

Contributions, feature requests, and issues are welcome! Please refer to CONTRIBUTING.md for details on how to contribute to PKMN Trade Club.

License

This project is licensed under the MIT License. See LICENSE for more information.