core/README.md

181 lines
5.2 KiB
Markdown
Raw Permalink Normal View History

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-07-07 11:10:31 +00:00
![Version](https://img.shields.io/badge/v0.7.8-lightgrey)
2025-07-02 19:30:21 +00:00
![Tests](https://img.shields.io/badge/tests%2090%25-lightcyan?logo=pytest&logoColor=black)
2025-07-03 09:47:54 +00:00
![Python](https://img.shields.io/badge/python%203.12+-lightblue?logo=python&logoColor=black)
2025-07-03 09:31:16 +00:00
![PostgreSQL](https://img.shields.io/badge/postgresql%2016.1-lightblue?logo=postgresql&logoColor=black)
2025-07-03 09:25:26 +00:00
![Redis](https://img.shields.io/badge/redis%206.2.0-salmon?logo=redis&logoColor=black)
2025-07-03 09:31:16 +00:00
![txtai](https://img.shields.io/badge/txtai%208.6.0-lavender?logo=elasticsearch&logoColor=black)
2025-07-03 09:47:54 +00:00
![GraphQL](https://img.shields.io/badge/ariadne%200.23.0-pink?logo=graphql&logoColor=black)
![TypeScript](https://img.shields.io/badge/typescript%205.8.3-blue?logo=typescript&logoColor=black)
![SolidJS](https://img.shields.io/badge/solidjs%201.9.1-blue?logo=solid&logoColor=black)
![Vite](https://img.shields.io/badge/vite%207.0.0-blue?logo=vite&logoColor=black)
![Biome](https://img.shields.io/badge/biome%202.0.6-blue?logo=biome&logoColor=black)
2025-06-19 08:28:48 +00:00
</div>
Backend service providing GraphQL API for content management system with reactions, ratings and topics.
## 📚 Documentation
2025-07-03 09:23:06 +00:00
- [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)
2021-08-20 23:17:15 +00:00
2025-07-02 19:30:21 +00:00
## 🚀 Core Features
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-07-02 19:30:21 +00:00
### RBAC & Permissions
- RBAC with hierarchy using Redis
2025-06-19 08:28:48 +00:00
## 🛠️ Tech Stack
2025-06-30 19:43:32 +00:00
**Core:** Python 3.12 • GraphQL • PostgreSQL • SQLAlchemy • JWT • Redis • txtai
2025-07-03 09:23:06 +00:00
**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
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
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-lightcyan?logo=git&logoColor=black)
2025-07-03 09:23:06 +00:00
![Biome](https://img.shields.io/badge/biome%202.0.6-yellow?logo=code&logoColor=black)
2025-06-19 08:28:48 +00:00
![Mypy](https://img.shields.io/badge/mypy-lavender?logo=python&logoColor=black)
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
2025-07-03 09:23:06 +00:00
# Linting and formatting with Biome
biome check . --write
# Lint only
biome lint .
2024-11-20 20:59:11 +00:00
2025-07-03 09:23:06 +00:00
# Format only
biome format . --write
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
![Line 120](https://img.shields.io/badge/line%20120-lightblue?logo=prettier&logoColor=black)
![Types](https://img.shields.io/badge/typed-pink?logo=python&logoColor=black)
![Docs](https://img.shields.io/badge/documented-lightcyan?logo=markdown&logoColor=black)
2024-11-20 20:59:11 +00:00
2025-07-18 13:32:35 +00:00
**Biome 2.1.2** for linting and formatting • **120 char** lines • **Type hints** required • **Docstrings** for public methods
2025-06-19 08:28:48 +00:00
### 🔍 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">
![Lines](https://img.shields.io/badge/15k%2B-lines-lightcyan?logo=code&logoColor=black)
![Files](https://img.shields.io/badge/100%2B-files-lavender?logo=folder&logoColor=black)
2025-07-02 19:30:21 +00:00
![Coverage](https://img.shields.io/badge/90%25-coverage-gold?logo=test-tube&logoColor=black)
2025-06-19 08:28:48 +00:00
![MIT](https://img.shields.io/badge/MIT-license-silver?logo=balance-scale&logoColor=black)
</div>
## 🤝 Contributing
2025-07-02 19:30:21 +00:00
[CHANGELOG.md](CHANGELOG.md)
2025-06-19 08:28:48 +00:00
![Contributing](https://img.shields.io/badge/contributing-guide-salmon?logo=handshake&logoColor=black) • [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
2025-07-02 19:30:21 +00:00
![Website](https://img.shields.io/badge/discours.io-website-lightblue?logo=globe&logoColor=black)
![GitHub](https://img.shields.io/badge/discours/core-github-silver?logo=github&logoColor=black)
• [discours.io](https://discours.io)
• [Source Code](https://github.com/discours/core)
2025-06-19 08:28:48 +00:00
---
<div align="center">
**Made with ❤️ by the Discours Team**
![Made with Love](https://img.shields.io/badge/made%20with%20❤-pink?logo=heart&logoColor=black)
![Open Source](https://img.shields.io/badge/open%20source-lightcyan?logo=open-source-initiative&logoColor=black)
</div>