|
1 |
| -# ht_api |
| 1 | +<div align="center"> |
| 2 | +<img src="https://avatars.githubusercontent.com/u/202675624?s=400&u=2daf23e8872a3b666bcd4f792a21fe2633097e79&v=4" alt="Flutter News App Toolkit Logo" width="220"> |
2 | 3 |
|
3 |
| - |
4 |
| -[](https://pub.dev/packages/very_good_analysis) |
5 |
| -[](https://polyformproject.org/licenses/free-trial/1.0.0) |
| 4 | +# Flutter News App - API Server Full Source Code |
6 | 5 |
|
7 |
| -🚀 Accelerate the development of your news application backend with **ht_api**, the |
8 |
| -dedicated API service for the Headlines Toolkit. Built on the high-performance |
9 |
| -Dart Frog framework, `ht_api` provides the essential server-side infrastructure |
10 |
| -specifically designed to power robust and feature-rich news applications. |
| 6 | +<p> |
| 7 | +<img src="https://img.shields.io/badge/coverage-XX-green?style=for-the-badge" alt="coverage: percentage"> |
| 8 | +<a href="https://github.com/sponsors/flutter-news-app-full-source-code"><img src="https://img.shields.io/badge/DOCS-READ-purple?style=for-the-badge" alt="DOCS READ"></a> |
| 9 | +<a href="https://github.com/sponsors/flutter-news-app-full-source-code"><img src="https://img.shields.io/badge/LICENSE-BUY-pink?style=for-the-badge" alt="License: Buy"></a> |
| 10 | +</p> |
| 11 | +</div> |
11 | 12 |
|
12 |
| -`ht_api` is a core component of the **Headlines Toolkit**, a comprehensive, |
13 |
| -source-available ecosystem designed for building feature-rich news |
14 |
| -applications, which also includes a Flutter [mobile app](https://github.com/headlines-toolkit/ht-main) and a web-based [content |
15 |
| -management dashboard](https://github.com/headlines-toolkit/ht-dashboard). |
| 13 | +This is the complete and fully-functional backend API server for the Flutter News App Toolkit. Built with the high-performance Dart Frog framework, it gives you all the server-side features you need to power your news app, right out of the box. It is a key component of the [**Flutter News App Toolkit**](https://github.com/flutter-news-app-full-source-code), an ecosystem that also includes a flutter [mobile app](https://github.com/flutter-news-app-full-source-code/flutter-news-app-mobile-client-full-source-code) and a web-based [content dashboard](https://github.com/flutter-news-app-full-source-code/flutter-news-app-web-dashboard-full-source-code). |
16 | 14 |
|
17 |
| -## ✨ Key Capabilities |
| 15 | +## ⭐ Everything You Get, Ready to Go |
18 | 16 |
|
19 |
| -* 🔒 **Flexible & Secure Authentication:** Provide seamless user access with |
20 |
| - a unified system supporting passwordless email sign-in and anonymous guest |
21 |
| - accounts. The API intelligently handles the conversion from a guest to a |
22 |
| - permanent user, preserving all settings and preferences. It also includes |
23 |
| - a secure, role-aware login flow for privileged dashboard users. |
| 17 | +This API server comes packed with all the features you need to launch a professional, scalable news application. |
24 | 18 |
|
25 |
| -* ⚡️ **Granular Role-Based Access Control (RBAC):** Implement precise |
26 |
| - permissions with a dual-role system (`appRole` for application features, |
27 |
| - `dashboardRole` for admin functions) to control access to API features |
28 |
| - and data management capabilities. |
| 19 | +#### 🔐 **Robust & Flexible Authentication** |
| 20 | +* Provides secure, modern authentication flows, including passwordless email sign-in and anonymous guest accounts. |
| 21 | +* Intelligently handles converting guest users to permanent accounts, preserving all their settings and saved content. |
| 22 | +* Includes a separate, role-aware login flow for privileged dashboard users. |
| 23 | +> **Your Advantage:** You get a complete, secure authentication system without the complexity. All the user management logic is done for you. ✅ |
29 | 24 |
|
30 |
| -* ⚙️ **Synchronized App Settings:** Ensure a consistent and personalized user |
31 |
| - experience across devices by effortlessly syncing application preferences |
32 |
| - like theme, language, font styles, and more. |
| 25 | +#### ⚡️ **Granular Role-Based Access Control (RBAC)** |
| 26 | +* Implement precise permissions with a dual-role system: `appRole` for mobile app features and `dashboardRole` for admin functions. |
| 27 | +* Securely control access to API features and data management capabilities based on user roles. |
| 28 | +> **Your Advantage:** A powerful, built-in security model that protects your data and ensures users only access what they're supposed to. 🛡️ |
33 | 29 |
|
34 |
| -* 👤 **Personalized User Preferences:** Enable richer user interactions by |
35 |
| - managing and syncing user-specific data such as saved headlines, followed |
36 |
| - sources, and followed topics tailored to individual users. |
| 30 | +#### ⚙️ **Centralized App & User Settings** |
| 31 | +* Effortlessly sync user-specific settings like theme, language, and font styles across devices. |
| 32 | +* Manage personalized content preferences, including saved headlines and followed topics/sources. |
| 33 | +> **Your Advantage:** Deliver a seamless, personalized experience that keeps users' settings in sync, boosting engagement and retention. ❤️ |
37 | 34 |
|
38 |
| -* 💾 **Robust Data Management:** Securely manage core news data (headlines, |
39 |
| - topics, sources) through a well-structured API that supports flexible |
40 |
| - querying and sorting for dynamic content presentation. |
| 35 | +#### 💾 **Robust Data Management API** |
| 36 | +* Securely manage all your core news data, including headlines, topics, sources, and countries. |
| 37 | +* The API supports flexible querying, filtering, and sorting, allowing your app to display dynamic content feeds. |
| 38 | +> **Your Advantage:** A powerful and secure data backend that's ready to scale with your content needs. 📈 |
41 | 39 |
|
42 |
| -* 🌐 **Dynamic Remote Configuration:** Centrally manage application |
43 |
| - behavior—including ad frequency, feature flags, and maintenance status—without |
44 |
| - requiring a client-side update. |
| 40 | +#### 🌐 **Dynamic Remote Configuration** |
| 41 | +* Centrally manage your app's behavior without shipping an update. |
| 42 | +* Control ad frequency, feature flags, force-update prompts, and maintenance status directly from the server. |
| 43 | +> **Your Advantage:** Adapt your app on the fly, run experiments, and respond to issues instantly, giving you maximum operational control. 🕹️ |
45 | 44 |
|
46 |
| -* 📊 **Dynamic Dashboard Summary:** Access real-time, aggregated metrics on |
47 |
| - key data points like total headlines, topics, and sources, providing |
48 |
| - an at-a-glance overview for administrative dashboards. |
| 45 | +#### 📊 **Real-Time Dashboard Analytics** |
| 46 | +* Access real-time, aggregated metrics on key data points like total headlines, topics, and sources. |
| 47 | +* Provides an at-a-glance overview perfect for administrative dashboards. |
| 48 | +> **Your Advantage:** Instantly feed your content dashboard with the data it needs to provide valuable insights. 🎯 |
49 | 49 |
|
50 |
| -* 🔧 **Solid Technical Foundation:** Built with Dart and the high-performance |
51 |
| - Dart Frog framework, offering a maintainable codebase, standardized API |
52 |
| - responses, and built-in access control for developers. |
| 50 | +#### 🏗️ **Clean & Modern Architecture** |
| 51 | +* Built with Dart and the high-performance Dart Frog framework. |
| 52 | +* Features a clean, layered architecture with standardized API responses and built-in dependency injection. |
| 53 | +> **Your Advantage:** A solid, maintainable codebase that's easy to understand, extend, and build upon. 🔧 |
53 | 54 |
|
54 |
| -## 🔌 API Endpoints |
| 55 | +--- |
55 | 56 |
|
56 |
| -`ht_api` provides a clear and organized API surface under the `/api/v1/` path. |
57 |
| -Key endpoint groups cover authentication, data access, and user settings. |
| 57 | +## 🔑 License: Source-Available with a Free Trial |
58 | 58 |
|
59 |
| -For complete API specifications, detailed endpoint documentation, |
60 |
| -request/response schemas, and error codes, please refer to the dedicated |
61 |
| -documentation website [todo:Link to the docs website]. |
| 59 | +Get started for free and purchase when you're ready to launch! |
62 | 60 |
|
63 |
| -## 🔑 Access and Licensing |
| 61 | +* **TRY IT:** Download and explore the full source code under the PolyForm Free Trial [license](LICENSE). Perfect for evaluation. |
| 62 | +* **BUY IT:** Get an unlimited commercial lifetime license with a **one-time payment**. No subscriptions! |
| 63 | +* **GET YOURS:** [**Purchase via GitHub Sponsors**](https://github.com/sponsors/flutter-news-app-full-source-code). |
64 | 64 |
|
65 |
| -`ht_api` is source-available as part of the Headlines Toolkit ecosystem. |
| 65 | +> *<p style="color:grey">Note: The single purchase provides a comprehensive commercial license covering every repository within the [Flutter News App Toolkit](https://github.com/flutter-news-app-full-source-code) organization. No separate purchases are needed for the mobile app or dashboard.</p>* |
66 | 66 |
|
67 |
| -To acquire a commercial license for building unlimited news applications, please visit |
68 |
| -the [Headlines Toolkit GitHub organization page](https://github.com/headlines-toolkit) |
69 |
| -for more details. |
| 67 | +--- |
70 | 68 |
|
71 |
| -## 💻 Setup & Running |
| 69 | +## 🚀 Getting Started & Running Locally |
72 | 70 |
|
73 | 71 | 1. **Prerequisites:**
|
74 | 72 | * Dart SDK (`>=3.0.0`)
|
75 | 73 | * MongoDB (`>=5.0` recommended)
|
76 | 74 | * Dart Frog CLI (`dart pub global activate dart_frog_cli`)
|
77 | 75 |
|
78 |
| -2. **Configuration:** |
79 |
| - Before running the server, you must configure the necessary environment |
80 |
| - variables. |
| 76 | +2. **Clone the repository:** |
| 77 | + ```bash |
| 78 | + git clone https://github.com/flutter-news-app-full-source-code/flutter-news-app-api-server-full-source-code.git |
| 79 | + cd flutter-news-app-api-server-full-source-code |
| 80 | + ``` |
81 | 81 |
|
| 82 | +3. **Configure your environment:** |
82 | 83 | Copy the `.env.example` file to a new file named `.env`:
|
83 | 84 | ```bash
|
84 | 85 | cp .env.example .env
|
85 | 86 | ```
|
86 |
| - Then, open the new `.env` file and update the variables with your actual |
87 |
| - configuration values, such as the `DATABASE_URL`. |
| 87 | + Then, open the new `.env` file and update the variables with your actual configuration values (e.g., `DATABASE_URL`). |
88 | 88 |
|
89 |
| -3. **Clone the repository:** |
90 |
| - ```bash |
91 |
| - git clone https://github.com/headlines-toolkit/ht-api.git |
92 |
| - cd ht-api |
93 |
| - ``` |
94 | 89 | 4. **Get dependencies:**
|
95 | 90 | ```bash
|
96 | 91 | dart pub get
|
97 | 92 | ```
|
| 93 | + |
98 | 94 | 5. **Run the development server:**
|
99 | 95 | ```bash
|
100 | 96 | dart_frog dev
|
101 | 97 | ```
|
102 |
| - The API will typically be available at `http://localhost:8080`. On startup, |
103 |
| - the server will connect to your MongoDB database and seed it with initial |
104 |
| - fixture data. This seeding process is idempotent (using `upsert` |
105 |
| - operations), so it can be run multiple times without creating duplicates. |
| 98 | + The API will be available at `http://localhost:8080`. On startup, the server will connect to your MongoDB database and seed it with initial data. This process is idempotent, so it can be run multiple times without creating duplicates. |
106 | 99 |
|
107 |
| - |
108 |
| - **Note on Web Client Integration (CORS):** To allow web applications (like |
109 |
| - the HT Dashboard) to connect to this API in production, the |
110 |
| - `CORS_ALLOWED_ORIGIN` environment variable must be set to the specific |
111 |
| - origin of your web application (e.g., `https://your-dashboard.com`). |
112 |
| - |
113 |
| - For local development, the API automatically allows any request |
114 |
| - originating from `localhost` on any port, so you do not need to set this |
115 |
| - variable. |
| 100 | +--- |
116 | 101 |
|
117 | 102 | ## ✅ Testing
|
118 | 103 |
|
119 |
| -Ensure the API is robust and meets quality standards by running the test suite: |
| 104 | +This project aims for high test coverage to ensure quality and reliability. |
120 | 105 |
|
121 |
| -```bash |
122 |
| -# Ensure very_good_cli is activated: dart pub global activate very_good_cli |
123 |
| -very_good test --min-coverage 90 |
124 |
| -``` |
125 |
| - |
126 |
| -Aim for a minimum of 90% line coverage. |
| 106 | +* Run tests with: |
| 107 | + ```bash |
| 108 | + very_good test --min-coverage 90 |
0 commit comments