Yi Fan Xia niRi Ben Yu Ban moarimasu
Chat-Core
Live Demo: https://chatcore-ai.com/
UI Preview
Demo Videos
Click a thumbnail to open the video on YouTube.
Overview
Chat-Core is a FastAPI-based AI chat application with email-based authentication, persistent + ephemeral conversations, and prompt sharing. It integrates with Groq and Google Gemini APIs, uses PostgreSQL for storage, and ships with a Next.js frontend.
Key Features
- Email-based authentication with 6-digit verification codes
- Persistent + ephemeral chat modes
- Prompt sharing with search and public visibility controls
- Groq / Gemini integrations for LLM responses
Tech Stack
- Backend: FastAPI (Python)
- Frontend: Next.js
- Database: PostgreSQL
- Optional: Redis (for auth/session enhancements)
Quick Start (Docker Compose)
This project standardizes local execution on Docker Compose.
git clone https://github.com/kota-kawa/Chat-Core.git
cd Chat-Core
# 2) Create a .env file with required environment variables
# Example:
# GROQ_API_KEY=xxxxx
# Gemini_API_KEY=xxxxx
# FASTAPI_SECRET_KEY=xxxxx
# SEND_ADDRESS=example@gmail.com
# SEND_PASSWORD=app_password
# ADMIN_PASSWORD_HASH=pbkdf2_sha256$...
# POSTGRES_HOST=db
# POSTGRES_USER=postgres
# POSTGRES_PASSWORD=postgres
# POSTGRES_DB=strike_chat
# FRONTEND_URL=http://localhost:3000
# 3) Build and run
docker-compose up --build
- Frontend:
http://localhost:3000 - API:
http://localhost:5004
Database Migrations (Alembic)
For existing environments, apply incremental DB changes with Alembic:
pip install -r requirements.txt
# Apply all migrations
alembic upgrade head
db/init.sqlremains the bootstrap schema for brand-new databases.- Default task definitions are centralized in
frontend/data/default_tasks.jsonand seeded on startup. alembic/versions/contains incremental migration history.db/performance_indexes.sqlis kept as a direct SQL fallback for index-only updates.
Required Environment Variables
Set these in .env or in docker-compose.yml:
GROQ_API_KEY: Groq API keyGemini_API_KEY: Google Generative AI API keyGOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET: Google OAuth client credentialsGOOGLE_PROJECT_ID: Google OAuth project ID (project_idin client config)GOOGLE_JS_ORIGIN: allowed JavaScript origin for Google OAuth (default:https://chatcore-ai.com)GROQ_MODEL: Groq model name used by OpenAI SDK (default:openai/gpt-oss-20b)GEMINI_DEFAULT_MODEL: default Gemini model whenmodelis omitted (default:gemini-2.5-flash)LLM_DAILY_API_LIMIT: daily cap for total/api/chatLLM calls across all users (default:300)AUTH_EMAIL_DAILY_SEND_LIMIT: daily cap for login/verification email sends across all users (default:50)FASTAPI_SECRET_KEY: session secret (FLASK_SECRET_KEYis supported as a legacy fallback)ADMIN_PASSWORD_HASH: hashed admin password in formatpbkdf2_sha256$iterations$salt$hash(no in-code default)SEND_ADDRESS/SEND_PASSWORD: Gmail account for verification emails (EMAIL_SEND_PASSWORDis accepted as a legacy fallback)POSTGRES_HOST/POSTGRES_USER/POSTGRES_PASSWORD/POSTGRES_DB: PostgreSQL settingsDB_POOL_MIN_CONN/DB_POOL_MAX_CONN: DB connection pool min/max size (defaults:1/10)REDIS_HOST/REDIS_PORT/REDIS_DB/REDIS_PASSWORD(optional): Redis settingsFASTAPI_ENV: set toproductionto enable stricter SameSite/Secure settings (FLASK_ENVis supported as a legacy fallback)LOG_LEVEL(optional): app log level (default:INFO)LOG_DIR(optional): log output directory (default:logs)APP_LOG_FILE/ERROR_LOG_FILE(optional): app/error log file names (defaults:app.log/error.log)LOG_MAX_BYTES/LOG_BACKUP_COUNT(optional): rotating log size and retention count (defaults:10485760/10)
Generate ADMIN_PASSWORD_HASH with:
Project Structure
app.py: FastAPI entry pointblueprints/: feature modules (auth, chat, memo, prompt_share, admin)services/: shared integrations (DB, LLM, email, user helpers)templates/andstatic/: global HTML/CSS/JS assetsdb/init.sql: initial PostgreSQL schemafrontend/: Next.js frontend
Architecture Diagram
U[User Browser]
FE[Next.js Frontend]
API[FastAPI Backend]
BP[Blueprints
auth/chat/memo/prompt_share/admin]
SV[Services
db/llm/email/user]
DB[(PostgreSQL)]
RD[(Redis Optional)]
LLM[Groq / Gemini APIs]
EM[Email Provider]
U --> FE --> API
API --> BP --> SV
SV --> DB
SV --> RD
SV --> LLM
SV --> EM
Design Decisions
- Why FastAPI (instead of Flask): FastAPI gives async-first request handling, type-driven validation, and automatic OpenAPI docs. This reduces API integration friction and keeps backend contracts explicit.
Trade-off: stricter typing and async patterns add some implementation complexity. - Why Redis for session/state (optional): When Redis is available, sessions are stored server-side and shared across instances, which improves horizontal scalability and supports operational controls (e.g., centralized invalidation, quota/ephemeral state handling).
Trade-off: extra infrastructure and operational overhead. - Why PostgreSQL as the primary datastore: Core entities (users, chats, prompts, admin data) are relational and consistency-sensitive. PostgreSQL provides strong integrity guarantees plus mature indexing/migration workflows.
- Why Next.js for frontend: Next.js supports route-based UI composition and production-ready optimization while allowing incremental migration from legacy static/script assets.
Engineering Highlights (for reviewers)
- Modular design: feature-specific blueprints keep routing and templates scoped and maintainable.
- Clear separation of concerns: integrations live in
services/, keeping HTTP handlers thin and testable. - Security-aware defaults: environment-based session configuration and secret management via
.env. - Composable UI assets: shared global assets with page-specific entrypoints for predictable styling.
CSS Guidelines
static/css/base/: reset, variables, common layout primitivesstatic/css/components/: reusable UI components (e.g., sidebar, modal)static/css/pages/: page entrypoints (import base + components)/index.css
Use BEM-style kebab-case class names and document purpose/dependencies at the top of each file.
Production Notes
- Set
FASTAPI_ENV=productionto enable secure cookie settings. - Keep secrets out of version control; use
.envor a secrets manager. - Pin dependencies and update regularly.
License
Copyright (c) 2026 Kota Kawagoe
Licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Ri Ben Yu Ban (kuritsukushiteZhan Kai )
raibudemo: https://chatcore-ai.com/
UI Preview
Demo Videos
Click a thumbnail to open the video on YouTube.
Gai Yao
Chat-Core ha FastAPI deGou Zhu shita AI chiyatsutoapuridesu. me-ruRen Zheng *Yong Sok /ehuemeraruchiyatsuto*puronputoGong You woBei e, Groq to Google Gemini API niDui Ying shiteimasu. PostgreSQL woCai Yong shi, Next.js hurontoendotoLian Xi shimasu.
Zhu naJi Neng
- me-ruRen Zheng (6 Hang ko-do)
- Yong Sok /ehuemerarunochiyatsuto
- puronputoGong You (Gong Kai *Jian Suo )
- Groq / Gemini Lian Xi
Ji Shu sutatsuku
- Backend: FastAPI (Python)
- Frontend: Next.js
- Database: PostgreSQL
- Optional: Redis
Shi Xing Fang Fa (Docker Compose)
Shi Xing Fang Fa ha Docker Compose niTong Yi shiteimasu.
git clone https://github.com/kota-kawa/Chat-Core.git
cd Chat-Core
# 2) .env niBi Yao naHuan Jing Bian Shu woShe Ding
# GROQ_API_KEY=xxxxx nado
# 3) birudo&Qi Dong
docker-compose up --build
- hurontoendo:
http://localhost:3000 - API:
http://localhost:5004
de-tabe-sumaigure-shiyon(Alembic)
Ji Cun Huan Jing henoDuan Jie De naDBBian Geng ha Alembic deShi Yong shimasu.
pip install -r requirements.txt
# Quan maigure-shiyonwoShi Yong
alembic upgrade head
db/init.sql: Xin Gui DBnoChu Qi suki-ma- Ji Ding tasukuDing Yi ha
frontend/data/default_tasks.jsonwoDan Yi so-sutoshiteQi Dong Shi niTou Ru alembic/versions/: Duan Jie De naBian Geng Lu Lidb/performance_indexes.sql: indetsukusunomiwoZhi Jie Shi Yong suruhuo-rubatsukuSQL
Bi Yao naHuan Jing Bian Shu
GROQ_API_KEY: Groq API ki-Gemini_API_KEY: Google Generative AI API ki-GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET: Google OAuth kuraiantoZi Ge Qing BaoGOOGLE_PROJECT_ID: Google OAuth no project_idGOOGLE_JS_ORIGIN: Google OAuth no JavaScript origin(dehuoruto:https://chatcore-ai.com)GROQ_MODEL: OpenAI SDKJing You deShi uGroqmoderuMing (dehuoruto:openai/gpt-oss-20b)GEMINI_DEFAULT_MODEL:modelWei Zhi Ding Shi niShi uGeminimoderu(dehuoruto:gemini-2.5-flash)LLM_DAILY_API_LIMIT: Quan yu-za-He Ji no/api/chatJing You LLMHu biChu shiRi Ci Shang Xian (dehuoruto:300)AUTH_EMAIL_DAILY_SEND_LIMIT: Quan yu-za-He Ji noroguin/Ren Zheng me-ruSong Xin Ri Ci Shang Xian (dehuoruto:50)FASTAPI_SECRET_KEY: setsushiyonYong shi-kuretsuto(FLASK_SECRET_KEYhaJiu Huan Jing Xiang kehuo-rubatsukutoshiteLi Yong Ke )ADMIN_PASSWORD_HASH: Guan Li Zhe pasuwa-donohatsushiyu(Xing Shi :pbkdf2_sha256$iterations$salt$hash, ko-doNei dehuorutonashi)SEND_ADDRESS/SEND_PASSWORD: Ren Zheng me-ruSong Xin Yong Gmail(EMAIL_SEND_PASSWORDhaJiu Huan Jing Xiang kehuo-rubatsukutoshiteLi Yong Ke )POSTGRES_HOST/POSTGRES_USER/POSTGRES_PASSWORD/POSTGRES_DB: PostgreSQL She DingDB_POOL_MIN_CONN/DB_POOL_MAX_CONN: DB konekushiyonpu-ruZui Xiao /Zui Da Shu (dehuoruto:1/10)REDIS_HOST/REDIS_PORT/REDIS_DB/REDIS_PASSWORD(Ren Yi ): Redis She DingFASTAPI_ENV:productionde SameSite/Secure She Ding woQiang Hua (FLASK_ENVhaJiu Huan Jing Xiang kehuo-rubatsukutoshiteLi Yong Ke )LOG_LEVEL(Ren Yi ): apurirogureberu(dehuoruto:INFO)LOG_DIR(Ren Yi ): roguChu Li deirekutori(dehuoruto:logs)APP_LOG_FILE/ERROR_LOG_FILE(Ren Yi ): Tong Chang /era-rogunohuairuMing (dehuoruto:app.log/error.log)LOG_MAX_BYTES/LOG_BACKUP_COUNT(Ren Yi ): ro-te-shiyonnosaizuShang Xian toBao Chi Shu (dehuoruto:10485760/10)
ADMIN_PASSWORD_HASH noSheng Cheng Li :
deirekutoriGou Cheng
app.py: FastAPI entori-pointoblueprints/: Ji Neng Bie moziyu-ru(auth, chat, memo, prompt_share, admin)services/: DB/LLM/me-runadoGong Tong Chu Litemplates/*static/: Gong You HTML/CSS/JSdb/init.sql: Chu Qi suki-mafrontend/: Next.js hurontoendo
a-kitekuchiyaTu
U[yu-za-burauza]
FE[Next.js hurontoendo]
API[FastAPI batsukuendo]
BP[Blueprints
auth/chat/memo/prompt_share/admin]
SV[Services
db/llm/email/user]
DB[(PostgreSQL)]
RD[(Redis Ren Yi )]
LLM[Groq / Gemini API]
EM[me-rupurobaida]
U --> FE --> API
API --> BP --> SV
SV --> DB
SV --> RD
SV --> LLM
SV --> EM
Ji Shu De naYi Si Jue Ding (Design Decisions)
- naze FastAPI(Flask dehanaku)woXuan ndaka: Fei Tong Qi Chu Li , Xing hintobe-sunobaride-shiyon, Zi Dong Sheng Cheng sareru OpenAPI dokiyumentowoHuo Yong shi, API Lian Xi toShi Yang noMing Que Hua woYou Xian shitatamedesu.
tore-doohu: Xing Ding Yi to async noShi Zhuang Fu He haZeng emasu. - naze Redis wosetsushiyon/Zhuang Tai Guan Li niShi uka(Ren Yi ): Redis Li Yong Shi hasetsushiyonwosa-ba-Ce deYi Yuan Guan Li deki, Fu Shu insutansuGou Cheng demoGong You shiyasuku, Shi Xiao Zhi Yu yakuo-ta/ehuemeraruZhuang Tai noYun Yong gashiyasukunarimasu.
tore-doohu: Zhui Jia inhuranoYun Yong kosutogaFa Sheng shimasu. - naze PostgreSQL woZhu de-tasutoanishitaka: yu-za-*chiyatsuto*puronputo*Guan Li de-tahaGuan Xi Xing toZheng He Xing gaZhong Yao natame, Zheng He Xing Bao Zheng *indetsukusu*maigure-shiyongaCheng Shou shita PostgreSQL woCai Yong shiteimasu.
- naze Next.js woCai Yong shitaka: ru-toDan Wei deUIwoGou Cheng shitsutsuBen Fan Zui Shi Hua woXing e, Ji Cun noJing De asetsuto/sukuriputoGou Cheng karaDuan Jie De niYi Xing shiyasuitamedesu.
rebiyu-Guan Dian noQiang mi
- Ji Neng Dan Wei noFen Ge She Ji deBao Shou Xing woGao metaGou Cheng
- Ze Wu Fen Li niyorutesutoRong Yi Xing noXiang Shang
- sekiyuriteiQian Ti noShe Ding (Huan Jing Bian Shu niyoruMi Mi Guan Li )
- CSS noZai Li Yong Xing woYi Shi shitaGou Zao Hua
CSS gaidorain
static/css/base/: risetsuto/Bian Shu /Gong Tong reiautostatic/css/components/: Zai Li Yong Ke Neng na UIstatic/css/pages/: pe-ziDan Wei noentori-pointo/index.css
BEM Feng no kebab-case woTui Jiang shi, huairuMou Tou niMu De *Yi Cun Guan Xi woJi Zai shimasu.
Ben Fan Yun Yong nopointo
FASTAPI_ENV=productionde Secure She Ding woYou Xiao Hua- Mi Mi Qing Bao ha
.envor shi-kuretsutoGuan Li he - Yi Cun Guan Xi noDing Qi Geng Xin woTui Jiang
raisensu
Copyright (c) 2026 Kota Kawagoe
Apache License, Version 2.0 noXia deraisensusareteimasu. Xiang Xi ha LICENSE woCan Zhao shitekudasai.