Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohamad-liyaghi/fastquora
A social question-and-answer system using Fastapi, Postgres, Elastic, Open Telemetry, Jaeger, Redis, Kubernetes and docker.
https://github.com/mohamad-liyaghi/fastquora
docker elasticsearch fastapi jaeger kubernetes opentelemetry postgresql redis
Last synced: 29 days ago
JSON representation
A social question-and-answer system using Fastapi, Postgres, Elastic, Open Telemetry, Jaeger, Redis, Kubernetes and docker.
- Host: GitHub
- URL: https://github.com/mohamad-liyaghi/fastquora
- Owner: mohamad-liyaghi
- Created: 2024-08-16T08:24:54.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-09-20T09:39:47.000Z (about 2 months ago)
- Last Synced: 2024-10-11T05:21:53.380Z (29 days ago)
- Topics: docker, elasticsearch, fastapi, jaeger, kubernetes, opentelemetry, postgresql, redis
- Language: Python
- Homepage:
- Size: 258 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastQuora
## Table of Contents
- [Introduction](#introduction)
- [Technologies](#technologies)
- [Monitoring](#monitoring)
- [OpenTelemetry](#opentelemetry)
- [Application](#application)
- [Authentication](#authentication)
- [Profiles](#profiles)
- [Questions](#questions)
- [Answers](#answers)
- [Votes](#votes)
- [Installation](#installation)
- [Docker Compose](#docker-compose)
- [Kubernetes](#kubernetes)
- [Running Tests](#running-tests)## Introduction
FastQuora is a question-and-answer platform, similar to [Quora](https://www.quora.com/), 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:
FastQuora uses [FastAPI](https://fastapi.tiangolo.com/) as the backend framework and [PostgreSQL](https://www.postgresql.org/) for database management. It integrates [Elasticsearch](https://www.elastic.co/) to index and search questions and answers, and uses [Redis](https://redis.io/) as a caching layer to boost performance.
The application is containerized using [Docker](https://www.docker.com/) and managed with [Kubernetes](https://kubernetes.io/). For monitoring and observability, the project employs [Jaeger](https://www.jaegertracing.io/) for distributed tracing and [OpenTelemetry](https://opentelemetry.io/) for telemetry data collection. Unit tests are written with [pytest](https://docs.pytest.org/en/stable/) 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:
```bash
git clone https://github.com/mohamad-liyaghi/FastQuora.git
```
2. Navigate to the project directory:
```bash
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:
```bash
make run
```
For production mode, use:
```bash
make deploy
```### Kubernetes
To run FastQuora using Kubernetes:
1. Create the ConfigMaps:
```bash
make local_confmap
```
For production ConfigMaps, use:
```bash
make prod_confmap
```
2. Deploy the application:
```bash
make k8s
```The application will now be running on your local machine. You can access the backend at [http://localhost:8000](http://localhost:8000) and Jaeger at [http://localhost:16686](http://localhost:16686).
## Running Tests
Unit tests cover most parts of the application to ensure code quality and reliability. To run all tests:```bash
make test
```After running the tests, you should see the following output: