🇺🇸 English | 🇧🇷 Português (Brasil)
Architecture overview → request flow, domain model, an interactive catalog simulator, endpoints and tests (page in Portuguese).
Practice project — streaming API simulation (accounts, profiles, plans, age/plan-gated catalog,
watch history, reviews). See streaming-api-plan.md for the full domain model, architecture,
API contract and TDD checklist.
Package-by-feature Spring Boot app. Controllers only handle HTTP, services orchestrate one use case each, and every business rule lives in a small policy class.
flowchart LR
C([Client / Swagger]) -->|Bearer JWT| F[JWT filter]
F --> CT[Controllers]
CT --> S[Services]
S --> P[Policies<br/>access · quota · PIN · migration]
S --> R[Repositories]
R --> DB[(PostgreSQL<br/>Flyway)]
J[TrashPurgeJob<br/>daily 03:00] --> R
CT -.-> E[GlobalExceptionHandler<br/>ApiError]
erDiagram
ACCOUNT ||--|{ PROFILE : has
PROFILE ||--o{ WATCH_HISTORY_ENTRY : watches
MOVIE ||--o{ WATCH_HISTORY_ENTRY : "appears in"
PROFILE ||--o{ REVIEW : writes
MOVIE ||--o{ REVIEW : receives
- JDK 21
- Maven 3.9+
- Docker (local PostgreSQL and Testcontainers-based tests)
-
Create your local settings file (DB credentials and JWT secret). It is git-ignored:
cp .env.example .env
Set
JWT_SECRETto a random string of at least 32 characters (openssl rand -base64 48). The application reads.envautomatically; real environment variables take precedence. -
Start PostgreSQL:
docker compose up -d
This starts
streaming-postgres(PostgreSQL 16) on port 5432, databasestreaming, with a persistent volume. Connect with DBeaver using the credentials from.env. -
Run the application (or run
StreamingApiApplicationfrom the IDE, with the project root as working directory so.envis found):mvn spring-boot:run
Flyway applies the schema and seeds 20 movies on first start.
mvn test- Unit and
@WebMvcTesttests need nothing else. - Repository tests for movies and watch history use H2 in PostgreSQL mode (
testprofile). ProfileRepositoryTest(partial unique index) andStreamingApiIntegrationTest(end-to-end flows) start a throwaway PostgreSQL via Testcontainers, so Docker must be running.
http://localhost:8080/swagger-ui.html. Call POST /api/v1/auth/register or /login, then use
the returned token in the Authorize button.