183 lines
5.3 KiB
Markdown
183 lines
5.3 KiB
Markdown
# GraphQL API Backend
|
||
|
||
<div align="center">
|
||
|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||

|
||
|
||
</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)
|
||
- [RBAC System](docs/rbac-system.md)
|
||
|
||
## 🚀 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
|
||
```
|
||
|
||
### 🚀 Run server
|
||
|
||
First, certificates are required to run the server with HTTPS.
|
||
|
||
```shell
|
||
mkcert -install
|
||
mkcert localhost
|
||
```
|
||
|
||
Then, run the server:
|
||
|
||
```shell
|
||
python -m granian main:app --interface asgi
|
||
```
|
||
|
||
### ⚡ Useful Commands
|
||
|
||
```shell
|
||
# Linting and formatting with Biome
|
||
biome check . --write
|
||
|
||
# Lint only
|
||
biome lint .
|
||
|
||
# Format only
|
||
biome format . --write
|
||
|
||
# Run tests
|
||
pytest
|
||
|
||
# Type checking
|
||
mypy .
|
||
|
||
# dev run
|
||
python -m granian main:app --interface asgi
|
||
```
|
||
|
||
### 📝 Code Style
|
||
|
||

|
||

|
||

|
||
|
||
**Biome 2.0.6** for linting and formatting • **120 char** lines • **Type hints** required • **Docstrings** for public methods
|
||
|
||
### 🔍 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
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 📊 Project Stats
|
||
|
||
<div align="center">
|
||
|
||

|
||

|
||

|
||

|
||
|
||
</div>
|
||
|
||
## 🤝 Contributing
|
||
|
||
[CHANGELOG.md](CHANGELOG.md)
|
||
|
||
 • [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>
|