FastAPI Social Network is a simple social media platform built with FastAPI, SQLAlchemy, and PostgreSQL. It supports user authentication, posting, commenting, liking, and notifications.
- User Registration and Authentication (JWT)
- Create, Read, Update, Delete (CRUD) Posts
- Comment on Posts
- Like/Unlike Posts
- User Profiles
- Notifications for User Actions
-
Clone the repository:
git clone https://github.com/yourusername/fastapi-social-network.git cd fastapi-social-network -
Create and activate a virtual environment:
python -m venv env source env/bin/activate # On Windows use `env\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Set up the database and environment variables:
- Create a
.envfile in the root directory and add your database URL and secret key:DATABASE_URL=postgresql://user:password@localhost/dbname SECRET_KEY=your_secret_key
- Create a
-
Run the database migrations:
alembic upgrade head
-
Start the FastAPI server:
uvicorn app.main:app --reload
-
Access the API documentation at
http://127.0.0.1:8000/docs.
fastapi_social_network/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── models.py
│ ├── schemas.py
│ ├── crud.py
│ ├── database.py
│ ├── dependencies.py
│ └── security.py
├── images/
│ └── social_network.jpg
├── .env
├── requirements.txt
└── README.md
