Automated Action ca5dbb9088 Add complete simple messaging app with FastAPI
- Implement user authentication with JWT tokens
- Add messaging system for sending/receiving messages
- Create SQLite database with SQLAlchemy models
- Set up Alembic for database migrations
- Add health check endpoint
- Include comprehensive API documentation
- Support user registration, login, and message management
- Enable conversation history and user listing
2025-06-26 16:07:21 +00:00

1.8 KiB

Simple Messaging App

A simple messaging application built with FastAPI, SQLAlchemy, and SQLite.

Features

  • User registration and authentication with JWT tokens
  • Send and receive messages between users
  • View conversation history
  • Health check endpoint
  • API documentation with Swagger UI

Tech Stack

  • FastAPI: Modern, fast web framework for building APIs
  • SQLAlchemy: SQL toolkit and ORM
  • SQLite: Lightweight database
  • Alembic: Database migration tool
  • JWT: JSON Web Tokens for authentication
  • Bcrypt: Password hashing
  • Ruff: Fast Python linter

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the application:
uvicorn main:app --reload

The application will be available at http://localhost:8000

API Documentation

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc
  • OpenAPI JSON: http://localhost:8000/openapi.json

Endpoints

Authentication

  • POST /auth/register - Register a new user
  • POST /auth/login - Login user and get access token

Messages

  • POST /messages/send - Send a message to another user
  • GET /messages/received - Get received messages
  • GET /messages/sent - Get sent messages
  • GET /messages/conversation/{user_id} - Get conversation with specific user
  • GET /messages/users - Get list of all users

Health

  • GET /health - Health check endpoint

Environment Variables

Set the following environment variables:

  • SECRET_KEY: JWT secret key for token signing (default: "your-secret-key-here")

Database

The application uses SQLite database stored at /app/storage/db/db.sqlite. The database schema is managed with Alembic migrations.