A powerful, full-stack AI Chat application built to master modern web development technologies. This project seamlessly integrates a high-performance FastAPI backend with a dynamic React frontend, utilizing PostgreSQL for robust data persistence and OpenAI for intelligent responses.
Designed with N-Layer Architecture, this project serves as a comprehensive example of building scalable, maintainable, and production-ready software systems.
- 🤖 Intelligent Chat: Powered by OpenAI's GPT models for natural, context-aware conversations.
- 🧠 Conversation Memory: Remembers past messages within a session for coherent dialogue.
- 💾 Persistent History: All chats are saved in a PostgreSQL database using SQLAlchemy ORM.
- 🎨 Modern UI: A responsive, dark-mode enabled interface built with React, Vite, and custom CSS (Glassmorphism).
- 📱 Mobile Responsive: Fully optimized for mobile devices with a collapsible sidebar and touch-friendly controls.
- ⚡ High Performance: Async capabilities of FastAPI ensure lightning-fast responses.
- 🔒 Secure: JWT-based structure (ready for expansion) and environment variable management.
- 🏗️ N-Layer Architecture:
- API Layer: Handles HTTP requests and routing.
- Service Layer: Contains business logic.
- Data Layer: Manages database interactions (DAO pattern).
- Domain Layer: Defines core entities and models.
| Component | Technology |
|---|---|
| Backend | Python, FastAPI, Uvicorn, SQLAlchemy |
| Frontend | React, Vite, JavaScript, CSS3 |
| Database | PostgreSQL |
| AI Engine | OpenAI API |
| Tools | Git, Docker (Optional), ngrok |
- Python 3.10+
- Node.js & npm (for frontend development)
- PostgreSQL installed and running
This project includes a smart startup script baslat.bat that handles everything for you:
- Sets up the environment.
- Starts the generic Uvicorn server.
- Launches the application in your browser (
http://localhost:8000). - (Optional) Starts ngrok tunneling if available.
Just double-click baslat.bat in the root directory!
-
Clone the repository:
git clone https://github.com/azizdeniz890/fastapi-react-chat.git cd fastapi-react-chat -
Create Virtual Environment:
python -m venv venv .\venv\Scripts\activate
-
Install Base Dependencies:
pip install -r requirements.txt
-
Configure Environment: Create a
.envfile (or set variables inbaslat.bat) with:DATABASE_URL=postgresql://user:password@localhost/dbname OPENAI_API_KEY=sk-...
-
Run Application:
uvicorn app.main:app --reload
fastapi-react-chat/
├── app/ # Backend Application (N-Layer Architecture)
│ ├── api/ # API Layer (Endpoints & Schemas)
│ ├── auth/ # Authentication (JWT & Rate Limiting)
│ ├── config/ # Configuration Settings
│ ├── data/ # Data Access Layer (DAO & Database Connection)
│ ├── domain/ # Domain Entities & Models
│ ├── infra/ # Infrastructure (OpenAI Client)
│ ├── service/ # Business Logic Layer
│ └── main.py # Application Entry Point
├── frontend/ # React Frontend
│ ├── src/ # Components, Hooks, & Styles
│ └── index.html # Entry HTML
├── static/ # Compiled Frontend Assets
├── docs/ # Documentation Images
├── requirements.txt # Python Dependencies
├── baslat.bat # One-Click Startup Script
└── README.md # Project Documentation
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open-source and available under the MIT License.
Note: This project was built for educational purposes to demonstrate full-stack development skills.
