-
Notifications
You must be signed in to change notification settings - Fork 8
Setting Up Development Environment
This guide will walk you through setting up the development environment for the Flet-Chat project. We'll be using Docker to containerize our services, making it easy to manage and deploy.
Before you begin, ensure you have the following installed on your system:
- Docker
- Docker Compose
- Python 3.11 or higher
- Git (for version control)
First, clone the project repository to your local machine:
git clone https://github.com/HardMax71/Flet-Chat.git
cd Flet-ChatCreate a .env file in the root directory of the project and add the following environment variables:
# Example
## Database Configuration
DB_NAME=chatdb
DB_USER=chatuser
DB_PORT=5432
POSTGRES_VERSION=14
POSTGRES_PASSWORD=password
## Application Configuration
APP_PORT=8000
SECRET_KEY=secretkey
REFRESH_SECRET_KEY=refreshsecretkey
PYTHON_VERSION=3.11
## Redis Configuration
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_VERSION=6.2-alpine
Make sure to replace secretkey and refreshsecretkey with secure, randomly generated strings.
Our docker-compose.yml file defines three main services: the database (PostgreSQL), the chat service (our FastAPI backend), and Redis for real-time messaging.
To start all services, run:
docker-compose up -dThis command will:
- Start a PostgreSQL database
- Launch a Redis instance
- Build and start the chat service
You can check if all services are running correctly with:
docker-compose ps
The database will be automatically initialized with the schema defined in chat_service/init.sql. This happens when the container starts for the first time.
To run the Flet frontend application:
- Create a virtual environment:
python -m venv venv- Activate the virtual environment:
- On Windows:
venv\Scripts\activate- On macOS and Linux:
source venv/bin/activate- Install the required packages:
pip install -r requirements.txt- Run the Flet application:
python main.py --web
- The Flet frontend will be running as a desktop application.
- The FastAPI backend will be accessible at
http://localhost:8000. - You can access the API documentation at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
- Swagger UI:
- If you encounter any issues with database connections, ensure that the PostgreSQL container is running and healthy:
docker-compose logs db
- For issues with the chat service, check its logs:
docker-compose logs flet-chat-chat_service- If Redis is not connecting, verify its status:
docker-compose logs redis