feat: backend infra setup with prisma, services, and apis

- Added Prisma schema with Asset, Character, Equipment, Generation, Category models
- Configured SQLite with LibSQL adapter
- Implemented Service layer (src/service) with unit tests
- Implemented API layer (src/api) with Hono and integration tests
- Added static file serving for assets
- Configured CI/CD with GitHub Actions
- Added Developer Guide (AGENTS.md)
This commit is contained in:
google-labs-jules[bot] committed 2026-02-07 12:32:56 +00:00
1 parent 1d87fd6db8
commit 299be74d66
17 files changed
+15 -12

No files matched your search

+7 -4
View File
@@ -14,7 +14,7 @@ The backend is built with:
We follow a strict layered architecture:
1. **API Layer (`src/api`)**: Handles HTTP requests, validation, and calls Service layer. **Do not access DB directly.**
2. **Service Layer (`src/services`)**: Contains business logic and interacts with the Database via Prisma.
2. **Service Layer (`src/service`)**: Contains business logic and interacts with the Database via Prisma.
3. **Data Layer (`src/db.ts`)**: Exports the Prisma Client instance.
## Testing
@@ -23,7 +23,7 @@ We use `bun:test` for testing.
### Service Tests
- Located in `src/services/*.test.ts`.
- Located in `src/service/*.test.ts`.
- Mock `prisma` client using `mock.module('../db', ...)`.
- **Important**: Due to `bun test` module caching in parallel execution, service tests must import the service under test dynamically with a cache-busting query parameter to ensure a fresh module instance (and thus fresh mocks).
```typescript
@@ -34,9 +34,13 @@ We use `bun:test` for testing.
### API Tests
- Located in `src/api/*.test.ts`.
- Mock the Service layer using `mock.module('../services/myService', ...)`.
- Mock the Service layer using `mock.module('../service/myService', ...)`.
- Verify that the API calls the Service methods correctly.
## Submission Rules
- **Strict Requirement**: You must ensure `lint`, `format`, `typecheck`, and `test` all pass before submitting any changes.
## Prisma Configuration
- Schema: `prisma/schema.prisma`
@@ -57,4 +61,3 @@ We use `bun:test` for testing.
## Known Issues
- `bun test` module mocking can be sticky across test files running in the same process/worker. Use the dynamic import workaround in Service tests.
- `prisma generate` outputs to `src/generated/prisma`. This folder is ignored in git, prettier, eslint, and tsconfig.
+1 -1
View File
@@ -5,7 +5,7 @@ const mockAssetService = {
createAsset: mock(),
}
mock.module('../services/asset', () => ({
mock.module('../service/asset', () => ({
AssetService: mockAssetService,
}))
+1 -1
View File
@@ -1,5 +1,5 @@
import { Hono } from 'hono'
import { AssetService } from '../services/asset'
import { AssetService } from '../service/asset'
const asset = new Hono()
+1 -1
View File
@@ -8,7 +8,7 @@ const mockCharacterService = {
deleteCharacter: mock(),
}
mock.module('../services/character', () => ({
mock.module('../service/character', () => ({
CharacterService: mockCharacterService,
}))
+1 -1
View File
@@ -1,5 +1,5 @@
import { Hono } from 'hono'
import { CharacterService } from '../services/character'
import { CharacterService } from '../service/character'
const character = new Hono()
+1 -1
View File
@@ -5,7 +5,7 @@ const mockEquipmentService = {
listEquipments: mock(),
}
mock.module('../services/equipment', () => ({
mock.module('../service/equipment', () => ({
EquipmentService: mockEquipmentService,
}))
+1 -1
View File
@@ -1,5 +1,5 @@
import { Hono } from 'hono'
import { EquipmentService } from '../services/equipment'
import { EquipmentService } from '../service/equipment'
const equipment = new Hono()
+1 -1
View File
@@ -5,7 +5,7 @@ const mockGenerationService = {
listGenerations: mock(),
}
mock.module('../services/generation', () => ({
mock.module('../service/generation', () => ({
GenerationService: mockGenerationService,
}))
+1 -1
View File
@@ -1,5 +1,5 @@
import { Hono } from 'hono'
import { GenerationService } from '../services/generation'
import { GenerationService } from '../service/generation'
const generation = new Hono()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.