Skip to content
/ Bloggu Public

A simple blogging platform API built with FastAPI, Strawberry GraphQL, and PostgreSQL. Features user authentication, group management, comment posting, and comment history tracking. Dockerized for easy setup and development.

License

Notifications You must be signed in to change notification settings

nehciyy/Bloggu

Repository files navigation

Bloggu

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.

Features

  • 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

Getting Started

Prerequisites

Setup

  1. Clone the repository and navigate to the project directory.

  2. Copy .example.env and adjust values if needed (default values are provided).

  3. Build and start the services:

docker compose up --build

This will start the FastAPI app on http://localhost:8000/graphql and a PostgreSQL database.

Usage

1. Sign Up

curl -X POST http://localhost:8000/signup \
  -H "Content-Type: application/json" \
  -d '{"username": "alice", "password": "123", "group": "B"}'

2. Login

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.

3. Use GraphQL Playground

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.


Example GraphQL Queries & Mutations

User

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
  }
}

Comment

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
  }
}

Comment History

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
  }
}

License

This project is licensed under the MIT License. See LICENSE

About

A simple blogging platform API built with FastAPI, Strawberry GraphQL, and PostgreSQL. Features user authentication, group management, comment posting, and comment history tracking. Dockerized for easy setup and development.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published