A lightweight full-stack social media project where users can sign up, log in, upload images/videos with captions, browse a shared feed, and delete their own posts.
Use the deployed Streamlit app here:
https://hash-d25-python2026-frontend-tajup8.streamlit.app/
- User authentication using FastAPI Users + JWT
- Media uploads (image/video) to ImageKit
- Caption support for every post
- Feed view with newest posts first
- Owner-only post deletion
- SQLite storage for users and post metadata
- Backend: FastAPI, Uvicorn
- Auth: fastapi-users (JWT bearer strategy)
- Database: SQLite + SQLAlchemy (async) + aiosqlite
- Media storage: ImageKit
- Frontend: Streamlit
- Dependency/runtime manager: uv
FastAPI-SocialMediaApp/
├── app/
│ ├── app.py # FastAPI app, routes, and auth router wiring
│ ├── db.py # SQLAlchemy models + async session setup
│ ├── images.py # ImageKit client initialization
│ ├── schemas.py # Pydantic/FastAPI Users schemas
│ └── users.py # FastAPI Users manager + JWT auth backend
├── frontend.py # Streamlit frontend
├── main.py # Local dev entrypoint for backend (uvicorn)
├── pyproject.toml # Dependencies and project metadata
└── test.db # SQLite database file (created/used locally)
- Users register/login via auth endpoints.
- Frontend stores JWT in Streamlit session state.
- Authenticated uploads go to ImageKit.
- Backend saves post metadata (URL, file type, caption, owner) in SQLite.
- Feed endpoint returns all posts with owner flag and user email.
- Owners can delete their own posts (ImageKit file + DB record).
POST /auth/register- Register a new userPOST /auth/login- Login (form data: username, password)POST /auth/forgot-password- Request password reset tokenPOST /auth/verify- Verify user workflowsGET /users/me- Current authenticated user profile
-
POST /upload- Auth required
- Multipart form fields:
file(required)caption(optional)
- Uploads media to ImageKit and stores DB metadata
-
GET /feed- Auth required
- Returns list of posts with:
- id, user_id, caption, url, file_type, file_name, created_at, is_owner, email
-
DELETE /delete/{post_id}- Auth required
- Deletes a post only if requester is the owner
git clone <your-repo-url>
cd FastAPI-SocialMediaAppCreate a .env file in project root:
IMAGEKIT_PRIVATE_KEY=your_imagekit_private_keyNote: This project currently initializes ImageKit with the private key from environment variables.
uv syncOption A:
uv run python main.pyOption B:
uv run uvicorn app.app:app --host 0.0.0.0 --port 8000 --reloadBackend will be available at:
- API root/docs: http://localhost:8000/docs
Recommended:
uv run python -m streamlit run frontend.pyIf uv run streamlit run frontend.py fails on Windows with a trampoline/canonicalize path error, using python -m streamlit avoids that issue.
Frontend will be available at:
- Open frontend.
- Sign up with email/password.
- Log in.
- Upload an image or video and add an optional caption.
- Check feed for your post.
- Delete your own post using the trash button.
- Database URL is currently set to local SQLite in app code.
- JWT secret is hardcoded in app code for development.
- Streamlit frontend currently targets
http://localhost:8000backend URLs.
For production, move secrets and URLs to environment variables.
- Frontend can be hosted on Streamlit Community Cloud.
- Backend can be hosted on Render, Railway, Fly.io, Azure, or similar.
- Ensure CORS and backend base URL configuration are set for cross-origin frontend/backend deployments.
- Use a production database (PostgreSQL recommended) instead of local SQLite for scale/reliability.
- Like/comment system
- User profiles and avatars
- Pagination / infinite scroll feed
- Search and hashtag support
- Better media transformations and moderation
- CI pipeline and automated tests
Add your preferred license here (MIT, Apache-2.0, etc.).