English | Chinese (Simplified)
- AchoBeta Themis is a Java 21 and Spring Boot 3 multi-module backend project. It applies layered domain architecture and provides engineering support including Docker and GitHub Actions.
- This document is the standard, comprehensive README covering tech stack, module layout, environment setup, quick start, configuration & deployment, development guidelines and security compliance.
- Labor law compliance assistant powered by AI, focusing on consultation and document review for individual and enterprise users.
- Core capabilities:
- AI consultation chat with conversation history management.
- Contract/content review: extract text via Apache Tika and generate structured compliance output.
- Knowledge base query for topics and scenarios.
- MeiliSearch integration for fast legal text retrieval and debugging utilities.
- Secure endpoints with JWT and
@LoginRequiredaspect-based enforcement.
- Overview & Tech Stack
- Modules
- Prerequisites
- Quick Start
- Configuration
- Databases & External Services
- Docker Deployment
- Common Commands
- Development Guidelines
- CI/CD
- License
- Language & Runtime:
Java 21 - Framework:
Spring Boot 3.5.7 - Build:
Mavenwith wrapper (mvnw/mvnw.cmd) - Data Access:
MyBatis,MyBatis-Plus - Cache & Queue:
Redisson(Redis client),Caffeine - Search:
MeiliSearch - Security & Utilities:
JWT,Hutool,Fastjson - Document Parsing:
Apache Tika
themis-app: Application entry and runtime, Spring Boot startup and Web integration, main classcom.achobeta.themis.Application.themis-trigger: Trigger/adapter layer (Web), includes validation and document parsing, depends ondomain,api,common,infrastructure.themis-domain: Domain layer defining core business logic, depends only oncommon.themis-infrastructure: Infrastructure layer for DB access and external integrations, depends ondomainandcommon.themis-api: API contracts (request/response models), depends oncommon.themis-common: Shared module for exceptions, utilities, Redis scripts, common response models.
Reference structure:
achobeta-themis/
.githooks/
.github/workflows/
docs/dev-ops/
themis-app/
themis-trigger/
themis-domain/
themis-infrastructure/
themis-api/
themis-common/
pom.xml
README.md
LICENSE
- Install
JDK 21andGit. - Install
Docker Desktop(optional, for one-click dependencies). - Recommended IDE: IntelliJ IDEA (enable auto-optimize imports).
Initialize Git hooks (to validate commit messages):
git config core.hooksPath .githooks
chmod -R -x .githooks- Clone:
git clone <repo-url>
cd achobeta-themis- Build (skip tests):
# Windows
mvnw.cmd -T 1C -DskipTests clean package
# macOS/Linux
./mvnw -T 1C -DskipTests clean package- Run locally (dev):
# Start application module only
mvnw.cmd -pl themis-app -am spring-boot:run- Run the packaged jar:
java -jar themis-app/target/themis-app.jar- Centralized configs:
themis-app/src/main/resources/application.yml: common configapplication-dev.yml: developmentapplication-prod.yml: production
- Logging:
logback-spring.xml - Important: do not commit real secrets or sensitive configs (see Security & Compliance).
Profiles and port:
- Active profile defaults to
dev(seeapplication.yml). - Dev server port:
611(seeapplication-dev.yml).
Environment overrides (recommended in Docker/CI):
SPRING_DATASOURCE_URL,SPRING_DATASOURCE_USERNAME,SPRING_DATASOURCE_PASSWORDSERVER_PORTJWT_SECRET- Aliyun SMS:
aliyun-access-key-id,aliyun-access-key-secret,aliyun-template-code,aliyun-sign-name
- Database:
MySQL(init SQL indocs/dev-ops/mysql/init.sql) - Cache:
Redis - Search:
MeiliSearch - Object storage & SMS:
AliOSSandAliSms(utilities inthemis-common)
Start dependencies with Docker:
docker compose -f docs/dev-ops/docker-compose-environment.yml up -dPorts (compose defaults):
- MySQL:
13306 -> 3306 - Redis:
16379 -> 6379
- Start application container (example):
docker compose -f docs/dev-ops/docker-compose-app.yml up -d- For custom images and layered jars, refer to
themis-app/Dockerfileand the Spring Boot Maven Plugin setup.
Container environment variables example:
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/themis?...SPRING_DATASOURCE_USERNAME,SPRING_DATASOURCE_PASSWORDSERVER_PORT=611JWT_SECRETand Aliyun SMS keys (provide via secrets manager)
- Clean & build:
mvnw.cmd clean package -DskipTests - Run single module:
mvnw.cmd -pl themis-app -am spring-boot:run - Run tests:
mvnw.cmd test
- Interceptors:
LogInterceptorapplied globally (WebConfig). - Authentication:
LoginCheckAspectvalidatesAuthorization: Bearer <accessToken>usingJwtUtil; saves user info into SecurityContext. - Spring Security:
SecurityConfigallows/api/user/loginanonymous; adjust for stricter access as needed. - Threading:
ThreadPoolTaskExecutorfor async tasks (e.g., adjudication and history touch in chat). - Responses & errors: unified
ApiResponseplusGlobalExceptionHandlerfor business and validation errors.
- Branch naming must include owner and clearly describe work:
<type>-<name>-<description>Examples:
- New feature:
feature-<name>-<feature description>
e.g.: feature-jett-dev_log_system- Bug fix:
bugfix-<name>-<bug name>
e.g.: bugfix-jett-login_errorOther types: hotfix, release.
- Commit messages must be clear and granular (one thing per commit):
<type>(<scope>): <subject>
e.g.: feat: add new api
feat(common): add new api- Types:
feat new feature
fix bug fix
docs docs only
style code style (no logic change)
build build/deps changes
refactor refactoring
revert revert commit
# Not used currently: test, perf, ci, chore
- Subjects should not end with punctuation, e.g.:
feat: add new feature
fix: fix a bug- Content: remove unused imports, IDEA shortcut
Ctrl + Alt + O.
-
Authentication & User (
/api/user):POST /api/user/loginlogin, returns tokens.POST /api/user/logoutlogout withrefreshToken(requires login).POST /api/user/logout-alllogout all sessions (requires login).POST /api/user/refresh-tokenrefresh tokens.POST /api/user/send-verify-codesend SMS code.POST /api/user/forgetreset password.POST /api/user/change-passwordchange password (requires login).POST /api/user/change-usernamechange username (requires login).GET /api/user/info?userId=...get user info (requires login).
-
Chat (
/api/chat, requires login unless specified):POST /api/chat/consultAI Q&A.POST /api/chat/newOrcreate a new conversation ID.POST /api/chat/newarchive current and start new conversation.GET /api/chat/history?conversationId=...get chat history.GET /api/chat/historieslist user conversation metas.DELETE /api/chat/history?conversationId=...reset conversation history.GET /api/chat/secondary_question_titles/{userType}list common questions.
-
File Review (
/api/file, requires login):POST /api/file/upAndwriteupload file and extract text (Apache Tika).POST /api/file/reviewreview content and return structured result.POST /api/file/review/getIdcreate a review conversation ID.POST /api/file/review/record?flag=...save review record.GET /api/file/review/recordslist review records.GET /api/file/review/record?recordId=...get record detail.DELETE /api/file/review/record?recordId=...delete record.POST /api/file/downloaddownload generated file.
-
Knowledge Base (
/api/knowledgebs, requires login):GET /api/knowledgebs/query?question=...query by question string.GET /api/knowledgebs/topiclist topics.GET /api/knowledgebs/caselist common scenarios.
-
MeiliSearch Debug (
/api/law/debug):GET /api/law/debug/check-indexchecklaw_documentsindex stats.GET /api/law/debug/list-indexeslist indexes.POST /api/law/debug/test-add-oneadd a test document and wait for task.GET /api/law/debug/check-db-datasample DB data counts.
Authentication header:
- Use
Authorization: Bearer <accessToken>on endpoints annotated with@LoginRequired.
- Login:
curl -X POST http://localhost:611/api/user/login \
-H "Content-Type: application/json" \
-d '{"username":"demo","password":"******"}'- Chat consult:
curl -X POST http://localhost:611/api/chat/consult \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"conversationId":"<id>","message":"...","userType":1}'- File extract text:
curl -X POST http://localhost:611/api/file/upAndwrite \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-F file=@/path/to/contract.pdf- Never commit secrets (e.g.,
api_key, addresses, passwords) to the repo. - Keep real sensitive configs of
application-dev.ymlandapplication-prod.ymlwithin the team only; do not push to Git. - Avoid
git push --forceunless you fully understand the impact and have team agreement.
- GitHub Actions is configured under
.github/workflows/for build and deploy. - Extend checks, tests and artifact publishing as needed.
- Apache License 2.0 (see
LICENSE).