
Add email-validator package to requirements.txt to resolve ImportError when using EmailStr in Pydantic models
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
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- 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 userPOST /auth/login
- Login user and get access token
Messages
POST /messages/send
- Send a message to another userGET /messages/received
- Get received messagesGET /messages/sent
- Get sent messagesGET /messages/conversation/{user_id}
- Get conversation with specific userGET /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.
Description
Languages
Python
96.7%
Mako
3.3%