Getting Started with Development¶
This guide will help you set up your development environment and get started with contributing to the NSGG Backend project.
Prerequisites¶
Before you begin, ensure you have the following installed:
- Python 3.12 or higher
- PostgreSQL 15 or higher
- Redis 7 or higher
- Docker and Docker Compose (optional, but recommended)
- Git
Setting Up the Development Environment¶
1. Clone the Repository¶
2. Create a Virtual Environment¶
3. Install Dependencies¶
4. Set Up Environment Variables¶
Copy the example environment file and update it with your settings:
Required environment variables:
DEBUG=True
SECRET_KEY=your-secret-key
DATABASE_URL=postgres://user:password@localhost:5432/nsgg
REDIS_URL=redis://localhost:6379/0
STRIPE_PUBLIC_KEY=your-stripe-public-key
STRIPE_SECRET_KEY=your-stripe-secret-key
5. Initialize the Database¶
6. Run Pre-commit Hooks¶
Install and run pre-commit hooks to ensure code quality:
Development with Docker¶
1. Build and Start Services¶
2. Run Migrations¶
3. Create Superuser¶
Running Tests¶
Running All Tests¶
Running Specific Tests¶
Test Coverage¶
Code Quality Tools¶
Running Linters¶
API Documentation¶
The API documentation is available at:
- Swagger UI: http://localhost:8000/api/docs/
- ReDoc: http://localhost:8000/api/redoc/
Development Workflow¶
-
Create a new branch for your feature or bugfix:
-
Make your changes and commit them:
-
Push your changes:
-
Create a pull request on GitHub
Common Development Tasks¶
Creating a New App¶
Making Model Changes¶
Creating a Superuser¶
Generating API Schema¶
Troubleshooting¶
Database Issues¶
Reset your database:
Cache Issues¶
Clear Redis cache:
Docker Issues¶
Reset Docker environment: