How jan-dyndor/ai-chatbot works
This is a local AI chatbot with a Streamlit interface, FastAPI backend, PostgreSQL persistence, and Ollama-backed model generation. Users register or log in, then create chats, load history, choose a model, and submit messages; the backend streams model output and persists the exchange. Conversation titles and available models are also supported. The map includes authentication, per-conversation locking, and request middleware. Some route and page implementations were not sampled, so their connections reflect the documented layered design; planned capabilities are omitted.
Main entry points: v1.py API Routes · main.py App Setup · chat_service.py Chat Service · client.py Model Client
Components 22
Streamlit UI
- UI Entry
src/frontend/main.py - Chat Page
src/frontend/pages/chatbot_page.py - Login Page
src/frontend/pages/login_page.py - Register Page
src/frontend/pages/register_page.py
FastAPI Backend
- App Setup
src/backend/main.py - API Routes
src/backend/api/router/v1.py - Dependencies
src/backend/dependencies/depends.py - Request Middleware
src/backend/middleware/request_id_middleware.py - Logging Middleware
src/backend/middleware/logging_middleware.py
Identity
- Auth Service
src/backend/authentication/auth.py - Password Hashing
src/backend/authentication/passwords.py - User Service
src/backend/service/user_service.py
Chat Services
- Chat Service
src/backend/service/chat_service.py - Model Client
src/backend/chat_bot/client.py - Conversation Locks
src/backend/core/concurency/conversation_thread_lock.py
Persistence
- User Repository
src/backend/database/user_repository.py - Chat Repository
src/backend/database/chat_repository.py - Database Setup
src/backend/database/db.py - Data Models
src/backend/database/models.py
Other components
- User
- PostgreSQL
- Ollama
Connections 30
- User → UI Entry: uses
- UI Entry → Login Page: routes unauthenticated
- UI Entry → Chat Page: routes authenticated
- Login Page → API Routes: sends login
- Register Page → API Routes: sends registration
- Chat Page → API Routes: requests chats
- API Routes → Dependencies: resolves services
- API Routes → Auth Service: authenticates
- API Routes → Chat Service: dispatches chat
- API Routes → User Service: dispatches registration
- App Setup → API Routes: registers router
- App Setup → Request Middleware: installs
- App Setup → Logging Middleware: installs
- App Setup → Database Setup: initializes
- App Setup → Conversation Locks: creates manager
- Auth Service → User Repository: looks up users
- Auth Service → Password Hashing: verifies passwords
- User Service → Password Hashing: hashes password
- User Service → User Repository: creates user
- Chat Service → Chat Repository: reads and writes
- Chat Service → Model Client: generates responses
- Chat Service → Model Client: creates titles
- Model Client → Ollama: streams generation
- Model Client → Ollama: lists models
- Chat Repository → Data Models: queries
- User Repository → Data Models: queries
- Database Setup → PostgreSQL: connects
- Chat Repository → PostgreSQL: persists chat data
- User Repository → PostgreSQL: persists accounts
- API Routes → Chat Page: streams response