Skip to content

laban254/social-connect-api

Repository files navigation

Social Connect API

A modern, scalable social networking API built with Flask, featuring real-time interactions, secure authentication, and comprehensive social features.

Features

  • 🔐 Authentication & Authorization

    • JWT-based authentication
    • Role-based access control
    • Secure password handling
    • Token refresh mechanism
  • 👥 User Management

    • User registration and profiles
    • Follow/unfollow functionality
    • User search and discovery
    • Profile customization
  • 📝 Content Management

    • Posts and comments
    • Media uploads
    • Content moderation
    • Rich text formatting
  • 💬 Real-time Interactions

    • WebSocket support
    • Instant notifications
    • Live updates
    • Chat functionality
  • 🔍 Search & Discovery

    • Advanced search capabilities
    • Content recommendations
    • User discovery
    • Trending topics
  • 📊 Analytics & Monitoring

    • User engagement metrics
    • Content performance
    • System health monitoring
    • Error tracking

Tech Stack

  • Backend: Flask, Python 3.8+
  • Database: PostgreSQL
  • Cache: Redis
  • Authentication: JWT
  • Real-time: Socket.IO
  • Monitoring: Prometheus, Grafana
  • Testing: pytest
  • Documentation: Swagger/OpenAPI

Prerequisites

  • Python 3.8 or higher
  • PostgreSQL
  • Redis
  • Node.js (for Socket.IO)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/social-connect-api.git
cd social-connect-api
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
  1. Initialize the database:
flask db upgrade
  1. Run the application:
flask run

API Documentation

The API documentation is available at /api/v1/docs when running the application.

Authentication

All API endpoints (except registration and login) require authentication using JWT tokens.

  1. Register a new user:
curl -X POST http://localhost:5000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{"username": "user", "email": "user@example.com", "password": "password123"}'
  1. Login to get tokens:
curl -X POST http://localhost:5000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com", "password": "password123"}'
  1. Use the access token for authenticated requests:
curl -X GET http://localhost:5000/api/v1/users/me \
  -H "Authorization: Bearer <access_token>"

Development

Running Tests

pytest

Code Style

flake8
black .

Database Migrations

flask db migrate -m "description of changes"
flask db upgrade

Deployment

The application can be deployed using Docker:

docker-compose up -d

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, email labanrotich6544@gmail.com or join our Slack channel.

About

A Flask-based social media API utilizing OAuth and PostgreSQL.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages