https://github.com/testpress/forge
https://github.com/testpress/forge
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/testpress/forge
- Owner: testpress
- License: mit
- Created: 2024-08-05T15:11:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-28T05:44:16.000Z (9 months ago)
- Last Synced: 2025-06-28T06:29:12.811Z (9 months ago)
- Language: HTML
- Size: 97.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Forge - Django Project Template
A modern, well-structured Django project template that helps you quickly set up new Django projects with best practices and modern tooling.
## Features
- ๐ Modern Django project structure
- ๐งช Pytest for testing
- ๐จ Code formatting with black and isort
- ๐ Template linting with djLint
- ๐ Pre-commit hooks for code quality
- ๐ Documentation setup
- ๐ Localization support
- ๐ ๏ธ Modular project structure
- ๐ฆ uv for dependency management
- ๐ Optional WebSocket support with Django Channels
- ๐ Optional FastAPI integration for modern APIs
## Prerequisites
- Python 3.12 or higher
- [Cookiecutter](https://cookiecutter.readthedocs.io/) (`pip install cookiecutter`)
- [uv](https://docs.astral.sh/uv/) for dependency management
- Redis (if using Django Channels)
## Usage
1. Create a new project using the template:
```bash
cookiecutter https://github.com/testpress/forge.git
```
2. Follow the prompts to configure your project:
- Project name
- Project description
- Author name
- Email
- Version
- License
- Optional integrations:
- Preline UI components
- Sentry error tracking
- Django Channels for WebSocket support
- FastAPI for modern API development
3. Navigate to your new project directory:
```bash
cd your_project_name
```
4. Install dependencies using uv:
```bash
uv sync
```
5. Initialize git and install pre-commit hooks:
```bash
git init
pre-commit install
```
6. Run migrations:
```bash
uv run python manage.py migrate
```
7. Start the development server:
```bash
uv run python manage.py runserver
```
## Project Structure
```
your_project_name/
โโโ app/ # Main application directory
โ โโโ api/ # FastAPI application (if enabled)
โ โ โโโ routers/ # API route modules
โ โ โโโ schemas/ # Pydantic schemas
โ โ โโโ dependencies/ # FastAPI dependencies
โ โ โโโ middleware/ # Custom middleware
โ โโโ models/ # Django models
โ โโโ views/ # Django views
โ โโโ templates/ # Django templates
โ โโโ static/ # Django static files
โโโ config/ # Project settings and configuration
โโโ docs/ # Documentation
โโโ locale/ # Translation files
โโโ tests/ # Test suite
โโโ manage.py # Django management script
โโโ api.py # FastAPI entry point (if enabled)
โโโ pyproject.toml # Project dependencies and tooling config
โโโ uv.lock # Locked dependencies
```
## Development
- Run tests: `uv run pytest`
- Format code: `uv run black .` and `uv run isort .`
- Lint templates: `uv run djlint .`
- Check code quality: `pre-commit run --all-files`
- Add new dependencies: `uv add package-name`
- Add development dependencies: `uv add --dev package-name`
## Optional Features
### Preline UI Components
If you selected "y" for `use_preline`, the template includes Preline UI components for a modern, responsive design.
### Sentry Integration
If you selected "y" for `use_sentry`, the template includes Sentry configuration for error tracking and monitoring.
### Django Channels
If you selected "y" for `use_channels`, the template includes:
- Django Channels for WebSocket support
- Redis channel layer configuration
- ASGI application setup
- Example WebSocket consumer structure
To use WebSockets:
1. Make sure Redis is running on localhost:6379
2. Add your WebSocket consumers in `app/consumers.py`
3. Configure WebSocket routing in `config/asgi.py`
4. Run the server with Daphne: `uv run daphne config.asgi:application`
### FastAPI Integration
If you selected "y" for `use_fastapi`, the template includes:
- Complete FastAPI application structure
- JWT authentication with password hashing
- User management API endpoints
- Automatic API documentation (Swagger/ReDoc)
- CORS middleware configuration
- Pydantic schemas for request/response validation
To use FastAPI:
1. Run the FastAPI server: `uv run uvicorn api:app --reload`
2. Access API documentation: http://localhost:8001/docs
3. Access ReDoc documentation: http://localhost:8001/redoc
4. Test authentication: POST http://localhost:8001/api/v1/auth/login
5. Test user endpoints: GET http://localhost:8001/api/v1/users
**FastAPI Features:**
- **Authentication**: JWT-based authentication with `/api/v1/auth/login`
- **User Management**: Full CRUD operations at `/api/v1/users`
- **Health Checks**: `/api/v1/health` and `/api/v1/ping`
- **Documentation**: Auto-generated OpenAPI documentation
- **CORS**: Configured for frontend development
- **Validation**: Pydantic schemas for all requests/responses
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.