This project is a real-time chatbot with a frontend in HTML/JS/CSS and a backend in FastAPI, integrated with the OpenAI API.
It supports message streaming, database persistence (SQLite) and file uploads (TXT and PDF) for preview.
- FastAPI (backend)
- SQLite + SQLAlchemy (database)
- OpenAI API (AI assistant)
- HTML + CSS + JS (frontend)
- Jinja2 (templates)
- Uvicorn (ASGI server)
PROJETOCHAT/ │── app.py # FastAPI backend (routes and main logic) │── database.py # Database models (SQLAlchemy) │── requirements.txt # Project dependencies │── .gitignore # Files ignored by Git │── .env # Environment variables (NOT uploaded to GitHub) │ ├── templates/ │ └── index.html # Main frontend │ ├── static/ │ ├── style.css # Styles │ └── script.js # Frontend logic
git clone https://github.com/joaopedrodev23/talkingtomachine.git
cd talkingtomachine
2. Create a virtual environment
python -m venv .venv
# Linux/Mac:
source .venv/bin/activate
# Windows:
.venv\Scripts\activate
3. Install dependencies
pip install -r requirements.txt
4. Configure environment variables
Create a file named .env in the root folder with:
OPENAI_API_KEY=your_api_key_here
5. Run the server
uvicorn app:app --reload
Access at 👉 http://127.0.0.1:8000
📌 Features
💬 Real-time chat with streaming responses
🗂️ Conversation history saved in SQLite
🌙 Dark/light mode
📎 File upload (TXT/PDF) with preview
💾 Export chat as .md
🔄 Conversation persistence by chatId