Skip to content

azizdeniz890/fastapi-react-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 FastAPI React Chat: Full-Stack AI Assistant

FastAPI React PostgreSQL OpenAI

App Screenshot

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.


✨ Features

  • 🤖 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.

🛠️ Technology Stack

Component Technology
Backend Python, FastAPI, Uvicorn, SQLAlchemy
Frontend React, Vite, JavaScript, CSS3
Database PostgreSQL
AI Engine OpenAI API
Tools Git, Docker (Optional), ngrok

🚀 Quick Start

Prerequisites

  • Python 3.10+
  • Node.js & npm (for frontend development)
  • PostgreSQL installed and running

One-Click Launch (Recommended)

This project includes a smart startup script baslat.bat that handles everything for you:

  1. Sets up the environment.
  2. Starts the generic Uvicorn server.
  3. Launches the application in your browser (http://localhost:8000).
  4. (Optional) Starts ngrok tunneling if available.

Just double-click baslat.bat in the root directory!

Manual Setup

  1. Clone the repository:

    git clone https://github.com/azizdeniz890/fastapi-react-chat.git
    cd fastapi-react-chat
  2. Create Virtual Environment:

    python -m venv venv
    .\venv\Scripts\activate
  3. Install Base Dependencies:

    pip install -r requirements.txt
  4. Configure Environment: Create a .env file (or set variables in baslat.bat) with:

    DATABASE_URL=postgresql://user:password@localhost/dbname
    OPENAI_API_KEY=sk-...
  5. Run Application:

    uvicorn app.main:app --reload

📂 Project Structure

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

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

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.

About

A full-stack AI Chatbot built to master FastAPI & React integration. Features PostgreSQL for persistent history, OpenAI API for intelligence, and N-Layer Architecture for clean code. Demonstrates end-to-end system design skills.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors