2024-11-20 20:59:11 +00:00
|
|
|
|
# GraphQL API Backend
|
2021-08-20 23:17:15 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
<div align="center">
|
2021-08-20 23:17:15 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
Backend service providing GraphQL API for content management system with reactions, ratings and topics.
|
|
|
|
|
|
|
|
|
|
## 📚 Documentation
|
|
|
|
|
|
|
|
|
|
 • [API Documentation](docs/api.md)
|
|
|
|
|
 • [Authentication Guide](docs/auth.md)
|
|
|
|
|
 • [Caching System](docs/redis-schema.md)
|
|
|
|
|
 • [Features Overview](docs/features.md)
|
|
|
|
|
|
|
|
|
|
## 🚀 Core Features
|
2021-08-20 23:17:15 +00:00
|
|
|
|
|
2024-11-20 20:59:11 +00:00
|
|
|
|
### 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
|
2021-08-20 23:17:15 +00:00
|
|
|
|
|
2024-11-20 20:59:11 +00:00
|
|
|
|
### 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
|
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
## 🛠️ Tech Stack
|
|
|
|
|
|
|
|
|
|
**Core:** Python 3.12 • GraphQL • PostgreSQL • Redis • txtai
|
|
|
|
|
**Server:** Starlette • Granian • Nginx
|
|
|
|
|
**Tools:** SQLAlchemy • JWT • Pytest • Ruff
|
|
|
|
|
**Deploy:** Dokku • Gitea • Glitchtip
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
## 🔧 Development
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
### 📦 Prepare environment:
|
2023-11-27 08:12:42 +00:00
|
|
|
|
|
|
|
|
|
```shell
|
2025-02-09 14:18:01 +00:00
|
|
|
|
python3.12 -m venv venv
|
2025-02-10 15:04:08 +00:00
|
|
|
|
source venv/bin/activate
|
2025-06-16 17:20:23 +00:00
|
|
|
|
pip install -r requirements.dev.txt
|
2025-02-10 15:04:08 +00:00
|
|
|
|
```
|
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
### 🚀 Run server
|
2025-02-10 15:04:08 +00:00
|
|
|
|
|
2025-06-16 17:20:23 +00:00
|
|
|
|
First, certificates are required to run the server with HTTPS.
|
2024-12-11 22:04:11 +00:00
|
|
|
|
|
2025-02-10 15:04:08 +00:00
|
|
|
|
```shell
|
2024-12-11 22:04:11 +00:00
|
|
|
|
mkcert -install
|
|
|
|
|
mkcert localhost
|
2025-02-10 15:04:08 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Then, run the server:
|
|
|
|
|
|
|
|
|
|
```shell
|
2025-05-31 14:18:31 +00:00
|
|
|
|
python -m granian main:app --interface asgi
|
2022-06-14 05:41:40 +00:00
|
|
|
|
```
|
2024-08-09 06:37:06 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
### ⚡ Useful Commands
|
2024-08-09 06:37:06 +00:00
|
|
|
|
|
|
|
|
|
```shell
|
2024-11-20 20:59:11 +00:00
|
|
|
|
# Linting and import sorting
|
2025-06-01 23:56:11 +00:00
|
|
|
|
ruff check . --fix --select I
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
|
|
|
|
# Code formatting
|
2025-06-01 23:56:11 +00:00
|
|
|
|
ruff format . --line-length=120
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
|
|
|
|
# Run tests
|
2025-02-10 15:04:08 +00:00
|
|
|
|
pytest
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
|
|
|
|
# Type checking
|
2025-02-10 15:04:08 +00:00
|
|
|
|
mypy .
|
2025-05-16 06:23:48 +00:00
|
|
|
|
|
|
|
|
|
# dev run
|
|
|
|
|
python -m granian main:app --interface asgi
|
2024-08-09 06:37:06 +00:00
|
|
|
|
```
|
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
### 📝 Code Style
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
2025-06-19 08:28:48 +00:00
|
|
|
|
**Ruff** for linting • **120 char** lines • **Type hints** required • **Docstrings** for public methods
|
|
|
|
|
|
|
|
|
|
### 🔍 GraphQL Development
|
2024-11-20 20:59:11 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
2025-06-19 08:28:48 +00:00
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## 📊 Project Stats
|
|
|
|
|
|
|
|
|
|
<div align="center">
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
## 🤝 Contributing
|
|
|
|
|
|
|
|
|
|
 • [Read the guide](CONTRIBUTING.md)
|
|
|
|
|
|
|
|
|
|
We welcome contributions! Please read our contributing guide before submitting PRs.
|
|
|
|
|
|
|
|
|
|
## 📄 License
|
|
|
|
|
|
|
|
|
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
|
|
|
|
|
|
|
|
## 🔗 Links
|
|
|
|
|
|
|
|
|
|
 • [discours.io](https://discours.io)
|
|
|
|
|
 • [Source Code](https://github.com/discours/core)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
<div align="center">
|
|
|
|
|
|
|
|
|
|
**Made with ❤️ by the Discours Team**
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
</div>
|