This is a full stack chat application built with FastAPI and PostgreSQL. The application provides a single /chat
endpoint for users to communicate with each other in real-time.
- Clone the repository
- Install the required dependencies with
pip install -r requirements.txt
- Start the application with
uvicorn app.main:app --reload
Once the application is running, navigate to http://localhost:8000/docs
to access the Swagger UI and interact with the /chat
endpoint.
The project follows the following structure:
app/
: Contains the main application codemain.py
: Entry point for the applicationdatabase.py
: Database configuration and connectionmodels.py
: Database modelsschemas.py
: Pydantic schemas for request and response objectsrouters/
: Contains the router for the/chat
endpoint__init__.py
: Initializes the routerchat.py
: Contains the/chat
endpoint logic
tests/
: Contains the unit tests for the applicationtest_main.py
: Tests for the main application codetest_database.py
: Tests for the database configuration and connectiontest_models.py
: Tests for the database modelstest_schemas.py
: Tests for the Pydantic schemastest_routers/
: Contains the tests for the/chat
endpoint__init__.py
: Initializes the teststest_chat.py
: Tests for the/chat
endpoint logic
alembic/
: Contains the database migration scriptsalembic.ini
: Alembic configuration fileversions/
: Contains the migration scripts__init__.py
: Initializes the migration scriptsinitial.py
: Initial migration script
docker-compose.yml
: Docker Compose configuration file for running the application and database in containersDockerfile
: Dockerfile for building the application image.github/
: Contains the GitHub Actions workflow for continuous integration.github/workflows/python-app.yml
: Workflow for running the unit tests on push and pull request events
.pre-commit-config.yaml
: Configuration file for pre-commit hooks.