Bloggu is a simple blogging platform API built with FastAPI, SQLAlchemy, and Strawberry GraphQL. It supports user authentication, comment posting, and comment history tracking, with group-based access control.
- User sign up, login, and JWT-based authentication
- Group-based user management
- Comment creation, update, and deletion
- Comment history tracking
- REST endpoints for authentication
- GraphQL API for all CRUD operations
-
Clone the repository and navigate to the project directory.
-
Copy
.example.envand adjust values if needed (default values are provided). -
Build and start the services:
docker compose up --build
This will start the FastAPI app on http://localhost:8000/graphql and a PostgreSQL database.
curl -X POST http://localhost:8000/signup \ -H "Content-Type: application/json" \ -d '{"username": "alice", "password": "123", "group": "B"}'
curl -X POST http://localhost:8000/login \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "username=alice&password=123"
Copy the access_token from the response.
Go to http://localhost:8000/graphql in your browser.
In the "Headers" section, add:
{
"Authorization": "Bearer <your_bearer_token>"
}Replace <your_bearer_token> with the token from the login step.
Update User
mutation { updateUser(username: "bob-renamed", group: "admin") { id username group } }
Delete User
mutation { deleteUser }
Get All Users
query { allUsers { id username group } }
Get User by ID
query { userById(userId: 1) { id username group } }
Create Comment
mutation { createComment(content: "Hello world!") { id content userId } }
Update Comment
mutation { updateComment(commentId: 1, newContent: "Updated content") { id content userId } }
Delete Comment
mutation { deleteComment(commentId: 1) }
Get All Comments
query { allComments { id content userId } }
Get Comment by ID
query { commentById(commentId: 1) { id content userId } }
Get All Comment Histories
query { allCommentHistories { id commentId timestamp oldValue newValue } }
Get Comment History by ID
query { commentHistoryById(historyId: 1) { id commentId timestamp oldValue newValue } }
This project is licensed under the MIT License. See LICENSE