A lightweight social blogging platform built with FastAPI. Share posts, follow users, like content, and engage with a community.
Author: @devberatzengin Full Documentation: In this repo named with documentation.html & documentation.pdf
- Authentication: User registration & login with JWT
- Posts: Create, read, and delete blog posts
- Interactions: Comments, likes, and follows
- Search: Find posts and users
- Security: Password hashing and protected endpoints
Key Technologies:
- Backend: FastAPI + Uvicorn
- Database: PostgreSQL + SQLAlchemy ORM
- Migrations: Alembic
- Frontend: HTML/CSS with Jinja2 templates
- Authentication: JWT tokens
- Python 3.8+
- PostgreSQL 10+
# 1. Clone & navigate
git clone https://github.com/devberatzengin/Basic-Blog-App.git
cd "Basic Blog App"
# 2. Setup environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# 3. Configure database
createdb blog_db
# 4. Create .env file with:
DATABASE_URL=postgresql://username:password@localhost:5432/blog_db
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
# 5. Run migrations
cd app
alembic upgrade head
# 6. Start server
uvicorn main:app --reloadVisit http://localhost:8000
app/
├── api/
│ └── routers/ # Authentication, posts, users, comments, likes, follows, search
├── core/ # Config & security utilities
├── database/ # Database setup
├── models/ # SQLAlchemy models (User, Post, Comment, Like, Follow)
├── schemas/ # Pydantic validation schemas
├── services/ # Business logic
├── views/ # HTML templates (login, register, feed, profile, etc)
└── main.py # Application entry point
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| POST | /auth/register |
Create new account | ❌ |
| POST | /auth/login |
Login & get JWT token | ❌ |
| POST | /auth/logout |
Logout user | ✅ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| GET | /posts/ |
Get all posts (paginated) | ❌ |
| POST | /posts/ |
Create new post | ✅ |
| GET | /posts/{post_id} |
Get specific post | ❌ |
| DELETE | /posts/{post_id} |
Delete your post | ✅ |
| GET | /posts/liked-posts |
Get your liked posts | ✅ |
| GET | /posts/liked-posts/{user_id} |
Get user's liked posts | ❌ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| POST | /comments/ |
Add comment to post | ✅ |
| GET | /comments/{post_id} |
Get post comments | ❌ |
| DELETE | /comments/{comment_id} |
Delete your comment | ✅ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| POST | /likes/{post_id} |
Like a post | ✅ |
| DELETE | /likes/{post_id} |
Unlike a post | ✅ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| GET | /users/ |
List all users | ❌ |
| GET | /users/{user_id} |
Get user profile & posts | ❌ |
| PUT | /users/{user_id} |
Update your profile | ✅ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| POST | /follow/{user_id} |
Follow a user | ✅ |
| DELETE | /follow/{user_id} |
Unfollow a user | ✅ |
| GET | /follow/followers/{user_id} |
Get user's followers | ❌ |
| GET | /follow/following/{user_id} |
Get users they follow | ❌ |
| Method | Endpoint | Purpose | Auth Required |
|---|---|---|---|
| GET | /search/posts?q=keyword |
Search posts by content | ❌ |
| GET | /search/users?q=username |
Search users by username | ❌ |
Note: Endpoints marked with ✅ require a valid JWT token in the Authorization: Bearer <token> header
/login- Login page/register- Register page/feed- Post feed/profile- User profile/post/{id}- Post details
- 📸 Image Support - Upload and attach images to posts
- 🔔 Notifications - Get notified about likes, comments, and follows
- 💌 Direct Messaging - Send private messages between users
- #️⃣ Hashtags - Tag posts with hashtags for better discoverability
- ⭐ Post Rating - Rate posts with star ratings
- 📊 Analytics - View post statistics and engagement metrics
- 🌙 Dark Mode - Dark theme option for the UI
- 📱 Mobile App - Native mobile application
- 🔐 Two-Factor Authentication - Enhanced account security
- 🎨 Themes & Customization - Customize user profiles and interface
Have an idea? Open an issue to suggest new features!
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and commit:
git commit -m "Add feature" - Push to branch:
git push origin feature/your-feature - Open a Pull Request
- Issues: Report bugs on GitHub Issues
- Documentation: Check code comments for implementation details
- Questions: Open a discussion or issue with your question
Start building now! Clone the repo and follow the Quick Start guide above.