feat: migrate to uv package manager
- Add pyproject.toml with project configuration - Update requirements.txt and requirements.dev.txt with versions - Add .uv configuration file - Update .gitignore for uv - Update README with uv instructions - Configure hatchling build system - Add mypy configuration - Test uv sync and pytest integration
This commit is contained in:
232
README.md
232
README.md
@@ -1,184 +1,124 @@
|
||||
# GraphQL API Backend
|
||||
# Discours Core
|
||||
|
||||
<div align="center">
|
||||
Core backend for Discours.io platform
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
## Requirements
|
||||
|
||||
</div>
|
||||
- Python 3.11+
|
||||
- uv (Python package manager)
|
||||
|
||||
Backend service providing GraphQL API for content management system with reactions, ratings and topics.
|
||||
## Installation
|
||||
|
||||
## 📚 Documentation
|
||||
### Install uv
|
||||
|
||||
- [API Documentation](docs/api.md)
|
||||
- [Authentication Guide](docs/auth.md)
|
||||
- [Caching System](docs/redis-schema.md)
|
||||
- [Features Overview](docs/features.md)
|
||||
- [RBAC System](docs/rbac-system.md)
|
||||
```bash
|
||||
# macOS/Linux
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
## 🚀 Core Features
|
||||
### Shouts (Posts)
|
||||
- CRUD operations via GraphQL mutations
|
||||
- Rich filtering and sorting options
|
||||
- Support for multiple authors and topics
|
||||
- Rating system with likes/dislikes
|
||||
- Comments and nested replies
|
||||
- Bookmarks and following
|
||||
|
||||
### Reactions System
|
||||
- `ReactionKind` types: LIKE, DISLIKE, COMMENT
|
||||
- Rating calculation for shouts and comments
|
||||
- User-specific reaction tracking
|
||||
- Reaction stats and aggregations
|
||||
- Nested comments support
|
||||
|
||||
### Authors & Topics
|
||||
- Author profiles with stats
|
||||
- Topic categorization and hierarchy
|
||||
- Following system for authors/topics
|
||||
- Activity tracking and stats
|
||||
- Community features
|
||||
|
||||
### RBAC & Permissions
|
||||
- RBAC with hierarchy using Redis
|
||||
|
||||
## 🛠️ Tech Stack
|
||||
|
||||
**Core:** Python 3.12 • GraphQL • PostgreSQL • SQLAlchemy • JWT • Redis • txtai
|
||||
**Server:** Starlette • Granian 1.8.0 • Nginx
|
||||
**Frontend:** SolidJS 1.9.1 • TypeScript 5.7.2 • Vite 5.4.11
|
||||
**GraphQL:** Ariadne 0.23.0
|
||||
**Tools:** Pytest • MyPy • Biome 2.0.6
|
||||
|
||||
## 🔧 Development
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
### 📦 Prepare environment:
|
||||
|
||||
```shell
|
||||
python3.12 -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.dev.txt
|
||||
# Windows
|
||||
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
|
||||
```
|
||||
|
||||
### 🚀 Run server
|
||||
### Setup project
|
||||
|
||||
First, certificates are required to run the server with HTTPS.
|
||||
```bash
|
||||
# Clone repository
|
||||
git clone <repository-url>
|
||||
cd discours-core
|
||||
|
||||
```shell
|
||||
mkcert -install
|
||||
mkcert localhost
|
||||
# Install dependencies
|
||||
uv sync --dev
|
||||
|
||||
# Activate virtual environment
|
||||
source .venv/bin/activate # Linux/macOS
|
||||
# or
|
||||
.venv\Scripts\activate # Windows
|
||||
```
|
||||
|
||||
Then, run the server:
|
||||
## Development
|
||||
|
||||
```shell
|
||||
python -m granian main:app --interface asgi
|
||||
### Install dependencies
|
||||
|
||||
```bash
|
||||
# Install all dependencies (including dev)
|
||||
uv sync --dev
|
||||
|
||||
# Install only production dependencies
|
||||
uv sync
|
||||
|
||||
# Install specific group
|
||||
uv sync --group test
|
||||
uv sync --group lint
|
||||
```
|
||||
|
||||
### ⚡ Useful Commands
|
||||
### Run tests
|
||||
|
||||
```shell
|
||||
# Linting and formatting with Biome
|
||||
biome check . --write
|
||||
```bash
|
||||
# Run all tests
|
||||
uv run pytest
|
||||
|
||||
# Lint only
|
||||
biome lint .
|
||||
# Run specific test file
|
||||
uv run pytest tests/test_auth_fixes.py
|
||||
|
||||
# Format only
|
||||
biome format . --write
|
||||
|
||||
# python lint
|
||||
ruff check . --fix --select I # линтер и сортировка импортов
|
||||
ruff format . --line-length=120 # форматирование кода
|
||||
|
||||
# Run tests
|
||||
pytest
|
||||
|
||||
# Type checking
|
||||
mypy .
|
||||
|
||||
# dev run
|
||||
python -m granian main:app --interface asgi
|
||||
# Run with coverage
|
||||
uv run pytest --cov=services,utils,orm,resolvers
|
||||
```
|
||||
|
||||
### 📝 Code Style
|
||||
### Code quality
|
||||
|
||||

|
||||

|
||||

|
||||
```bash
|
||||
# Run ruff linter
|
||||
uv run ruff check .
|
||||
|
||||
**Biome 2.1.2** for linting and formatting • **120 char** lines • **Type hints** required • **Docstrings** for public methods
|
||||
# Run ruff formatter
|
||||
uv run ruff format .
|
||||
|
||||
### 🔍 GraphQL Development
|
||||
|
||||
Test queries in GraphQL Playground at `http://localhost:8000`:
|
||||
|
||||
```graphql
|
||||
# Example query
|
||||
query GetShout($slug: String) {
|
||||
get_shout(slug: $slug) {
|
||||
id
|
||||
title
|
||||
main_author {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
# Run mypy type checker
|
||||
uv run mypy .
|
||||
```
|
||||
|
||||
---
|
||||
### Run application
|
||||
|
||||
## 📊 Project Stats
|
||||
```bash
|
||||
# Run main application
|
||||
uv run python main.py
|
||||
|
||||
<div align="center">
|
||||
# Run development server
|
||||
uv run python dev.py
|
||||
```
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
## Project structure
|
||||
|
||||
</div>
|
||||
```
|
||||
discours-core/
|
||||
├── auth/ # Authentication and authorization
|
||||
├── cache/ # Caching system
|
||||
├── orm/ # Database models
|
||||
├── resolvers/ # GraphQL resolvers
|
||||
├── services/ # Business logic services
|
||||
├── utils/ # Utility functions
|
||||
├── schema/ # GraphQL schema
|
||||
├── tests/ # Test suite
|
||||
└── docs/ # Documentation
|
||||
```
|
||||
|
||||
## 🤝 Contributing
|
||||
## Configuration
|
||||
|
||||
[CHANGELOG.md](CHANGELOG.md)
|
||||
The project uses `pyproject.toml` for configuration:
|
||||
|
||||
 • [Read the guide](CONTRIBUTING.md)
|
||||
- **Dependencies**: Defined in `[project.dependencies]` and `[project.optional-dependencies]`
|
||||
- **Build system**: Uses `hatchling` for building packages
|
||||
- **Code quality**: Configured with `ruff` and `mypy`
|
||||
- **Testing**: Configured with `pytest`
|
||||
|
||||
We welcome contributions! Please read our contributing guide before submitting PRs.
|
||||
## CI/CD
|
||||
|
||||
## 📄 License
|
||||
The project includes GitHub Actions workflows for:
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
- Automated testing
|
||||
- Code quality checks
|
||||
- Deployment to staging and production servers
|
||||
|
||||
## 🔗 Links
|
||||
## License
|
||||
|
||||

|
||||

|
||||
• [discours.io](https://discours.io)
|
||||
• [Source Code](https://github.com/discours/core)
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
|
||||
**Made with ❤️ by the Discours Team**
|
||||
|
||||

|
||||

|
||||
|
||||
</div>
|
||||
MIT License
|
||||
|
||||
Reference in New Issue
Block a user