Skip to content

Commit 9199b62

Browse files
committed
docs: simplify README, focus on API endpoints
1 parent 3a93704 commit 9199b62

File tree

1 file changed

+6
-62
lines changed

1 file changed

+6
-62
lines changed

README.md

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,9 @@
88

99
`ht_api` is the central backend API service for the Headlines Toolkit (HT) project. Built with Dart using the Dart Frog framework, it provides essential APIs to support HT client applications (like the mobile app and web dashboard). It aims for simplicity, maintainability, and scalability, currently offering APIs for data access and user settings management.
1010

11-
## Features
12-
13-
### Core Functionality
14-
15-
* **Standardized Success Responses:** Returns consistent JSON success responses wrapped in a `SuccessApiResponse` structure, including request metadata (`requestId`, `timestamp`).
16-
* **Standardized Error Handling:** Returns consistent JSON error responses via centralized middleware (`lib/src/middlewares/error_handler.dart`) for predictable client-side handling.
17-
* **Request Traceability:** Generates a unique `requestId` (UUID v4) for each incoming request, included in success response metadata and available for server-side logging via context.
18-
* **In-Memory Demo Mode:** Utilizes pre-loaded fixture data (`lib/src/fixtures/`) for demonstration and development purposes, simulating a live backend without external dependencies for core data, settings, and email sending.
19-
* **Authentication:** Provides endpoints for user sign-in/sign-up via email code and anonymous sign-in. Includes token generation and validation. All Data and User Settings API endpoints now require authentication.
20-
21-
### Data API (`/api/v1/data`)
22-
23-
* **Authentication Required:** All operations on this endpoint require a valid authentication token.
24-
* **Generic Data Endpoint:** Provides a unified RESTful interface for performing CRUD (Create, Read, Update, Delete) operations on multiple data models.
25-
* **Model Agnostic Design:** Supports various data types through a single endpoint structure, determined by the `?model=` query parameter.
26-
* **Data Scoping:** Can serve global data (e.g., news articles, accessible to any authenticated user) or user-specific data (for future models, accessible only to the authenticated owner), based on the model's server-side configuration (`ModelConfig.ownership`).
27-
* **Currently Supported Data Models (as global):**
28-
* `headline`
29-
* `category`
30-
* `source`
31-
* `country`
32-
33-
### User Settings API (`/api/v1/users/{userId}/settings`)
34-
35-
* **User-Specific Settings Management:** Provides RESTful endpoints for an authenticated user to manage their own application settings. The `{userId}` in the path must match the ID of the authenticated user.
36-
* **Authentication Required:** All operations require a valid authentication token.
37-
* **Supported Settings:**
38-
* Display Settings (Theme, Font, etc.)
39-
* Language Preference
40-
41-
## Technical Overview
42-
43-
* **Language:** Dart (`>=3.0.0 <4.0.0`)
44-
* **Framework:** Dart Frog (`^1.1.0`)
45-
* **Architecture:** Layered architecture leveraging shared packages.
46-
* **Key Packages & Shared Core:**
47-
* `dart_frog`: The web framework foundation.
48-
* `uuid`: Used to generate unique request IDs.
49-
* `ht_shared`: Contains shared data models (`Headline`, `Category`, `User`, `AuthSuccessResponse`, etc.), API response wrappers (`SuccessApiResponse`, `ResponseMetadata`), and standard exceptions (`HtHttpException`).
50-
* `ht_data_client`: Defines the generic `HtDataClient<T>` interface.
51-
* `ht_data_inmemory`: Provides the `HtDataInMemoryClient<T>` implementation for data.
52-
* `ht_data_repository`: Defines the generic `HtDataRepository<T>` for data access.
53-
* `ht_app_settings_client`: Defines the `HtAppSettingsClient` interface for settings.
54-
* `ht_app_settings_inmemory`: Provides the `HtAppSettingsInMemory` implementation for settings.
55-
* `ht_app_settings_repository`: Defines the `HtAppSettingsRepository` for settings management.
56-
* `ht_email_client`: Defines the `HtEmailClient` interface for sending emails.
57-
* `ht_email_inmemory`: Provides the `HtEmailInMemoryClient` implementation for emails.
58-
* `ht_email_repository`: Defines the `HtEmailRepository` for email operations.
59-
* `ht_http_client`: Provides custom HTTP exceptions (`HtHttpException` subtypes) used for consistent error signaling.
60-
* **Key Patterns:**
61-
* **Repository Pattern:** `HtDataRepository<T>`, `HtAppSettingsRepository`, and `HtEmailRepository` provide clean abstractions over data/settings/email logic. Route handlers interact with repositories.
62-
* **Service Layer:** Services like `AuthService` orchestrate complex operations involving multiple repositories or logic (e.g., authentication flow).
63-
* **Generic Data Endpoint:** A single set of route handlers serves multiple data models via `/api/v1/data`.
64-
* **Model Registry:** A central map (`lib/src/registry/model_registry.dart`) links data model names to configurations (`ModelConfig`) for the generic data endpoint.
65-
* **Dependency Injection (Dart Frog Providers):** Middleware (`routes/_middleware.dart`) provides singleton instances of repositories, services (`AuthService`, `AuthTokenService`, etc.), the `ModelRegistryMap`, and a unique `RequestId`.
66-
* **Centralized Error Handling:** The `errorHandler` middleware intercepts exceptions and maps them to standardized JSON error responses.
67-
* **Authentication Middleware:** `authenticationProvider` validates tokens and provides `User?` context; `requireAuthentication` enforces access for protected routes.
68-
69-
## API Endpoints: Authentication (`/api/v1/auth`)
11+
## API Endpoints:
12+
13+
### Authentication (`/api/v1/auth`)
7014

7115
These endpoints handle user authentication flows.
7216

@@ -140,7 +84,7 @@ These endpoints handle user authentication flows.
14084
* **Error Response:** `401 Unauthorized` (if not authenticated), `404 Not Found` (if the user was already deleted), or other standard errors via the error handler middleware.
14185
* **Example:** `DELETE /api/v1/auth/delete-account` with `Authorization: Bearer <token>` header.
14286

143-
## API Endpoints: Data (`/api/v1/data`)
87+
### Data (`/api/v1/data`)
14488

14589
**Authentication required for all operations.**
14690

@@ -211,7 +155,7 @@ This endpoint serves as the single entry point for accessing different data mode
211155
* **Error Response:** `401 Unauthorized`, `404 Not Found`.
212156
* **Example:** `DELETE /api/v1/data/some-source-id?model=source` (Requires Bearer token)
213157

214-
## API Endpoints: User Settings (`/api/v1/users/{userId}/settings`)
158+
### User Settings (`/api/v1/users/{userId}/settings`)
215159

216160
These endpoints manage application settings for an authenticated user. The `{userId}` in the path must match the ID of the authenticated user.
217161

@@ -288,4 +232,4 @@ These endpoints manage application settings for an authenticated user. The `{use
288232

289233
## License
290234

291-
This package is licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use.
235+
This package is licensed under the [PolyForm Free Trial](LICENSE). Please review the terms before use.

0 commit comments

Comments
 (0)