Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

kota-kawa/Chat-Core

Repository files navigation

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.


> Watch Demo Video

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.

# 1) Clone the repository
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:

# Install dependencies first
pip install -r requirements.txt

# Apply all migrations
alembic upgrade head
  • db/init.sql remains the bootstrap schema for brand-new databases.
  • Default task definitions are centralized in frontend/data/default_tasks.json and seeded on startup.
  • alembic/versions/ contains incremental migration history.
  • db/performance_indexes.sql is 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 key
  • Gemini_API_KEY: Google Generative AI API key
  • GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET: Google OAuth client credentials
  • GOOGLE_PROJECT_ID: Google OAuth project ID (project_id in 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 when model is omitted (default: gemini-2.5-flash)
  • LLM_DAILY_API_LIMIT: daily cap for total /api/chat LLM 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_KEY is supported as a legacy fallback)
  • ADMIN_PASSWORD_HASH: hashed admin password in format pbkdf2_sha256$iterations$salt$hash (no in-code default)
  • SEND_ADDRESS / SEND_PASSWORD: Gmail account for verification emails (EMAIL_SEND_PASSWORD is accepted as a legacy fallback)
  • POSTGRES_HOST / POSTGRES_USER / POSTGRES_PASSWORD / POSTGRES_DB: PostgreSQL settings
  • DB_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 settings
  • FASTAPI_ENV: set to production to enable stricter SameSite/Secure settings (FLASK_ENV is 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:

python3 -c "from services.security import hash_password; print(hash_password('your_admin_password_here'))"

Project Structure

  • app.py: FastAPI entry point
  • blueprints/: feature modules (auth, chat, memo, prompt_share, admin)
  • services/: shared integrations (DB, LLM, email, user helpers)
  • templates/ and static/: global HTML/CSS/JS assets
  • db/init.sql: initial PostgreSQL schema
  • frontend/: Next.js frontend

Architecture Diagram

flowchart LR
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
Loading

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 primitives
  • static/css/components/: reusable UI components (e.g., sidebar, modal)
  • static/css/pages//index.css: page entrypoints (import base + components)

Use BEM-style kebab-case class names and document purpose/dependencies at the top of each file.

Production Notes

  • Set FASTAPI_ENV=production to enable secure cookie settings.
  • Keep secrets out of version control; use .env or 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.


> demoDong Hua woJian ru

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.

# 1) ripozitoriwoQu De
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.

# Xian niYi Cun Guan Xi woinsuto-ru
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.json woDan Yi so-sutoshiteQi Dong Shi niTou Ru
  • alembic/versions/: Duan Jie De naBian Geng Lu Li
  • db/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 Bao
  • GOOGLE_PROJECT_ID: Google OAuth no project_id
  • GOOGLE_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_KEY haJiu 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_PASSWORD haJiu Huan Jing Xiang kehuo-rubatsukutoshiteLi Yong Ke )
  • POSTGRES_HOST / POSTGRES_USER / POSTGRES_PASSWORD / POSTGRES_DB: PostgreSQL She Ding
  • DB_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 Ding
  • FASTAPI_ENV: production de SameSite/Secure She Ding woQiang Hua (FLASK_ENV haJiu 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 :

python3 -c "from services.security import hash_password; print(hash_password('your_admin_password_here'))"

deirekutoriGou Cheng

  • app.py: FastAPI entori-pointo
  • blueprints/: Ji Neng Bie moziyu-ru(auth, chat, memo, prompt_share, admin)
  • services/: DB/LLM/me-runadoGong Tong Chu Li
  • templates/*static/: Gong You HTML/CSS/JS
  • db/init.sql: Chu Qi suki-ma
  • frontend/: Next.js hurontoendo

a-kitekuchiyaTu

flowchart LR
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
Loading

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 reiauto
  • static/css/components/: Zai Li Yong Ke Neng na UI
  • static/css/pages//index.css: pe-ziDan Wei noentori-pointo

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=production de Secure She Ding woYou Xiao Hua
  • Mi Mi Qing Bao ha .env or 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.

About

FastAPI + Next.js AI chat platform with email/Google auth, persistent & ephemeral chats, prompt sharing/search, memo saving, and Groq/Gemini integration.

Topics

Resources

Readme

License

Apache-2.0 license

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors