How abdus-typing/ai-chat-app works
This is a Java/Javalin AI chat application with registration and signed-token login, authenticated multi-session conversations, message history, and AI replies via an OpenAI-compatible endpoint or offline fallback. The principal flow runs from the browser through authenticated REST controllers and ChatService, which loads history, requests a reply, and atomically persists both messages. README documents a responsive UI, but the sampled React App is only a placeholder; the tree also contains a static UI. Backend wiring and service flows are sampled; unsampled details are represented only where README or paths support them.
Main entry points: Controllers.java REST controllers · ChatService.java Chat service · AuthFilter.java Bearer auth filter · UserService.java User service
Components 16
Web interface
- Web client
src/main/resources/static - Javalin bootstrap
src/main/java/com/aichat/Main.java - REST controllers
src/main/java/com/aichat/web/Controllers.java
Identity
- Bearer auth filter
src/main/java/com/aichat/web/AuthFilter.java - User service
src/main/java/com/aichat/service/UserService.java - Token and passwords
src/main/java/com/aichat/service/AuthService.java
Conversation
- Chat service
src/main/java/com/aichat/service/ChatService.java
Persistence
- User DAO
src/main/java/com/aichat/dao/UserDao.java - Session DAO
src/main/java/com/aichat/dao/ChatSessionDao.java - Message DAO
src/main/java/com/aichat/dao/MessageDao.java - JPA and pool
src/main/java/com/aichat/jpa/JpaUtil.java - Chat entities
src/main/java/com/aichat/entity - MySQL database
AI replies
- AI reply service
src/main/java/com/aichat/service/AiService.java - OpenAI-compatible API
Other components
- Chat user
Connections 24
- Chat user → Web client: uses
- Web client → Javalin bootstrap: HTTP JSON
- Javalin bootstrap → REST controllers: routes to
- Javalin bootstrap → Bearer auth filter: protects routes
- REST controllers → Bearer auth filter: guarded by
- REST controllers → User service: registers and logs in
- REST controllers → Token and passwords: issues tokens
- Bearer auth filter → Token and passwords: validates token
- Bearer auth filter → User service: loads user
- User service → Token and passwords: hashes passwords
- User service → User DAO: reads and saves
- REST controllers → Chat service: handles chat requests
- Chat service → Session DAO: manages sessions
- Chat service → Message DAO: lists messages
- Chat service → AI reply service: requests reply
- Chat service → Chat entities: loads history and persists pair
- Session DAO → Chat entities: persists sessions
- Message DAO → Chat entities: queries messages
- User DAO → Chat entities: persists users
- JPA and pool → MySQL database: connects via pool
- Session DAO → JPA and pool: uses JPA
- Message DAO → JPA and pool: uses JPA
- User DAO → JPA and pool: uses JPA
- AI reply service → OpenAI-compatible API: calls when configured