A modern social networking platform built with FastAPI and Python
YegnaConnect is a feature-rich social networking platform that brings people together through posts, categories, and meaningful interactions. Built with modern web technologies, it provides a seamless experience for users to connect, share, and engage with content.
- User Registration & Login - Secure JWT-based authentication
- Profile Management - Customizable user profiles with bio and avatar
- Follow System - Follow/unfollow users and view followers/following lists
- User Search - Find and connect with other users
- Post Creation - Share text posts with rich formatting
- Interactive Feed - Like, comment, and engage with posts
- Comment System - Threaded comments with replies
- Like System - Like posts and comments with real-time updates
- Category Creation - Create and manage interest-based categories
- Category Membership - Join/leave categories and view members
- Category Posts - Post content to specific categories
- Category Discovery - Browse and discover new categories
- Responsive Design - Works perfectly on desktop and mobile
- Real-time Updates - Dynamic content updates without page refresh
- Clean Interface - Modern, intuitive user interface
- AJAX Integration - Smooth, fast user interactions
- FastAPI - Modern, fast web framework for building APIs
- SQLAlchemy - SQL toolkit and ORM
- PostgreSQL - Robust, open-source database
- Alembic - Database migration tool
- JWT - JSON Web Tokens for authentication
- Pydantic - Data validation using Python type annotations
- Jinja2 Templates - Server-side templating
- Tailwind CSS - Utility-first CSS framework
- JavaScript - Interactive client-side functionality
- AJAX - Asynchronous data loading
- OpenAI API - AI-powered features
- Hugging Face - Machine learning capabilities
- Redis - Caching and session management
- Python 3.8+
- PostgreSQL 13+
- Redis (optional)
-
Clone the repository
git clone https://github.com/yourusername/yegnaconnect.git cd yegnaconnect -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables Create a
.envfile in the project root:DATABASE_URL=postgresql+psycopg2://username:password@localhost:5432/yegnaconnect JWT_SECRET_KEY=your_super_secret_key_here JWT_ALGORITHM=HS256 JWT_ACCESS_TOKEN_EXPIRE_MINUTES=60 AI_HF_API_KEY=your_huggingface_api_key_here AI_OPENAI_API_KEY=your_openai_api_key_here REDIS_URL=redis://localhost:6379
-
Set up database
# Create database createdb yegnaconnect # Run migrations alembic upgrade head
-
Run the application
uvicorn main:app --reload
-
Visit the application Open your browser and go to
http://localhost:8000
YegnaConnect/
βββ alembic/ # Database migrations
βββ models/ # SQLAlchemy models
β βββ user.py # User model
β βββ post.py # Post model
β βββ category.py # Category model
β βββ __init__.py
βββ routes/ # API routes
β βββ auth.py # Authentication routes
β βββ feed.py # Feed and posts
β βββ profile.py # User profiles
β βββ search.py # User search
β βββ category.py # Category management
βββ services/ # Business logic
β βββ auth_service.py # Authentication logic
β βββ post_service.py # Post management
β βββ category_service.py # Category logic
βββ templates/ # HTML templates
β βββ base.html # Base template
β βββ feed.html # Main feed
β βββ profile.html # User profiles
β βββ ...
βββ static/ # Static files (CSS, JS, images)
βββ config.py # Configuration settings
βββ main.py # FastAPI application
βββ requirements.txt # Python dependencies
| Variable | Description | Required | Default |
|---|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes | - |
JWT_SECRET_KEY |
Secret key for JWT tokens | Yes | - |
JWT_ALGORITHM |
JWT algorithm | No | HS256 |
JWT_ACCESS_TOKEN_EXPIRE_MINUTES |
Token expiration time | No | 60 |
AI_HF_API_KEY |
Hugging Face API key | No | None |
AI_OPENAI_API_KEY |
OpenAI API key | No | None |
REDIS_URL |
Redis connection string | No | None |
-
Install PostgreSQL
# Ubuntu/Debian sudo apt-get install postgresql postgresql-contrib # macOS brew install postgresql # Windows # Download from https://postgresql.org/download/windows/
-
Create database
createdb yegnaconnect
-
Run migrations
alembic upgrade head
POST /register- User registrationPOST /login- User loginGET /logout- User logout
GET /feed- View main feedPOST /posts- Create new postPOST /posts/{post_id}/like- Like/unlike postDELETE /posts/{post_id}- Delete post
POST /posts/{post_id}/comments- Add commentPOST /comments/{comment_id}/like- Like/unlike commentDELETE /comments/{comment_id}- Delete commentPOST /comments/{comment_id}/replies- Reply to comment
GET /profile/{username}- View user profilePOST /profile/edit- Edit profilePOST /profile/{username}/follow- Follow/unfollow userGET /profile/{username}/followers- View followersGET /profile/{username}/following- View following
GET /categories- List all categoriesPOST /categories- Create new categoryGET /categories/{category_id}- View categoryPOST /categories/{category_id}/join- Join/leave categoryGET /categories/{category_id}/members- View category members
GET /search- Search users
- Secure JWT-based authentication
- Password hashing with bcrypt
- Session management
- Protected routes
- Real-time post creation and display
- Like/unlike functionality with AJAX
- Comment system with threaded replies
- Dynamic content loading
- Customizable profile information
- Follow/unfollow system
- Follower and following lists
- Profile picture support
- Interest-based category creation
- Category membership management
- Category-specific posts
- Member discovery
- User search with real-time results
- Search suggestions
- User discovery
-
Build the image
docker build -t yegnaconnect . -
Run the container
docker run -p 8000:8000 yegnaconnect
-
Create docker-compose.yml
version: '3.8' services: app: build: . ports: - "8000:8000" environment: - DATABASE_URL=postgresql://postgres:password@db:5432/yegnaconnect depends_on: - db volumes: - .:/app db: image: postgres:13 environment: - POSTGRES_DB=yegnaconnect - POSTGRES_USER=postgres - POSTGRES_PASSWORD=password volumes: - postgres_data:/var/lib/postgresql/data volumes: postgres_data:
-
Run with Docker Compose
docker-compose up -d
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI for the excellent web framework
- SQLAlchemy for the powerful ORM
- Tailwind CSS for the beautiful styling
- The open-source community for inspiration
If you have any questions or need help, please:
- Open an issue on GitHub
- Check the documentation
- Join our community discussions
Made with β€οΈ by the YegnaConnect Team