Social Network project
https://github.com/user-attachments/assets/6cb0d4ae-0de2-4414-ad49-d2f9c0221061
This is my most serious project.
It is a prototype of a social network similar to Twitter (now X).
Stack of this project includes:
- fastAPI
- Pydantic
- SQLalchemy (PostgreSQL) - As a main database.
- Redis - For storing short-lived data, like: JWTs, viewed posts excluding temporary image URLs (when using the local storage). Async
- ChromaDB - For user posts feed related to their history.
- AioBotocore - For AWS S3.
Features:
- Architecture built on SOLID principles, also it is fully asynchronous and easy to develop/expand.
- Images support user avatars and post pictures. Storage can be chosen in
.env file (AWS S3 via AioBotocore, Local Storage)
- Authorization handled with password hashing and two JWT tokens:
- Refresh token - long termed. Used to refresh access token.
- Access token - short termed.
- Feed unique to every user. It works by post popularity rate and chromaDB semantic search
- Popularity rate is a dynamic field in each post, value depends on user activity. The rate is secured from fake activity abusing.
- ChromaDB Semantic Search provides vectorized search to find relevant posts to user view history.
The feed contains mixed posts (proportions can be seted in
.env file)
- History related (Semantic Search)
- Unrelated, but popular and fresh posts
- Following posts from users you follow to (If no follows - returns Unrelated)
- Real-time Chat using fastAPI (starlete’s) websockets.
This project has a docker-compose.yml, so it allows you to start the application by executing only one line.
Also the project has basic CI (Implemented with GitHub actions) that runs tests on every push.
Next steps:
- Backend optimization (mostly with ImageStorage service and asyncio gather)
- Tests Covering & CI/CD Pipeline
- Deploy
Usage
Run
Requirements - Docker, Python 3.12.0 or higher, JavaScript ES10+
To run the application, follow these steps:
Copy the repository:
git clone https://github.com/yeghor/SocialNetwork.git
Move to repository directory:
Run docker-compose.yml
Contribute
In case you managed to run the application not using docker-compose.
Change HOST variables values in .env file to localhost!
Example:
REDIS_HOST = "localhost" # from redis_db
CHROMADB_HOST = "localhost" # from "chromadb_db"
DB_HOST = "localhost" # from "postgres_db"
Access your application by these URL: