Skip to content

A social question-and-answer system using Fastapi, Postgres, Elastic, Open Telemetry, Jaeger, Redis, Kubernetes and docker.

Notifications You must be signed in to change notification settings

mohamad-liyaghi/FastQuora

Repository files navigation

FastQuora

Table of Contents

Introduction

FastQuora is a question-and-answer platform, similar to Quora, where users can ask questions, provide answers, and vote on responses. It features a search functionality that allows users to find relevant questions and answers based on keywords. To enhance performance, a caching layer is implemented.

The project follows the repository pattern to manage data operations via repositories and controllers. Below is the high-level architecture of the project:

Technologies

This project utilizes a number of modern technologies:

fastapi postgresql elastic celery celery beat docker kubernetes redis pytest jaeger opentelemetry github actions

FastQuora uses FastAPI as the backend framework and PostgreSQL for database management. It integrates Elasticsearch to index and search questions and answers, and uses Redis as a caching layer to boost performance.

The application is containerized using Docker and managed with Kubernetes. For monitoring and observability, the project employs Jaeger for distributed tracing and OpenTelemetry for telemetry data collection. Unit tests are written with pytest to ensure code reliability.

Additionally, GitHub Actions is used for continuous integration and deployment (CI/CD) to automate testing and deployment pipelines. Every pull request triggers the test suite, ensuring that the code is always in a working state. The CI/CD process includes:

  • Build and push the image
  • Running all unit tests with pytest to validate changes.
  • Running all unit tests on a production-like environment.
  • Deploying the application to cloud infrastructure.

Monitoring

OpenTelemetry

This project integrates monitoring features using OpenTelemetry, which collects, processes, and exports telemetry data like traces, metrics, and logs. The metrics are visualized using Jaeger.
Below is an example of the Jaeger metrics:

Application

Authentication

FastQuora includes a simple authentication system that allows users to register and log in. It uses JWT tokens to authenticate users and protect routes.

Profiles

Users can view profiles to learn more about who has answered their questions. They can also update their own profiles to highlight their best features. The project does not collect any personal information, so users have the option to remain anonymous.

Questions

The question component is the core of FastQuora. Users can ask, view, and update questions. With the search functionality, users can find questions based on specific keywords.

Answers

The answer component allows users to respond to questions, view answers, and update their own answers.

Votes

FastQuora includes a voting system that allows users to upvote or downvote answers. To increase performance, votes are initially stored in Redis and then written to the database by a background task.

Installation

FastQuora can be run using Docker Compose or Kubernetes in either a local or production environment.

Clone Repository

To access the project, you should first clone the repository and then navigate to the project directory. Run the following commands in your terminal:

  1. Clone the repository:
    git clone https://github.com/mohamad-liyaghi/FastQuora.git
  2. Navigate to the project directory:
    cd FastQuora/

Docker Compose

After you've cloned the repository and navigated to the project directory, you can run FastQuora using Docker Compose by following these steps:

  1. Run the application:
    make run
    For production mode, use:
    make deploy

Kubernetes

To run FastQuora using Kubernetes:

  1. Create the ConfigMaps:
    make local_confmap
    For production ConfigMaps, use:
    make prod_confmap
  2. Deploy the application:
    make k8s

The application will now be running on your local machine. You can access the backend at http://localhost:8000 and Jaeger at http://localhost:16686.

Running Tests

Unit tests cover most parts of the application to ensure code quality and reliability. To run all tests:

make test

After running the tests, you should see the following output:

About

A social question-and-answer system using Fastapi, Postgres, Elastic, Open Telemetry, Jaeger, Redis, Kubernetes and docker.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages