Skip to content

Commit 6d20b01

Browse files
authored
Merge pull request #8 from flutter-news-app-full-source-code/final_polish
Final polish
2 parents c7a1bb3 + 790f82b commit 6d20b01

File tree

22 files changed

+346
-255
lines changed

22 files changed

+346
-255
lines changed

astro.config.mjs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ export default defineConfig({
1717
},
1818
],
1919
sidebar: [
20-
{
21-
label: 'Start Here',
22-
items: [
23-
{ label: 'Introduction', link: '/start-here/introduction' },
24-
{ label: 'Local Setup', link: '/start-here/local-setup' },
25-
// { label: 'Core Philosophy', link: '/start-here/core-philosophy' },
26-
{ label: 'Deployment Guides', link: '/start-here/deployment-guides' },
27-
],
28-
},
20+
{ label: 'Core Philosophy', link: 'core-philosophy' },
21+
{ label: 'Local Setup', link: 'local-setup' },
22+
{ label: 'Deployment', link: 'deployment' },
2923
{
3024
label: 'API Server',
3125
collapsed: true,
@@ -100,7 +94,7 @@ export default defineConfig({
10094
label: 'Architecture',
10195
collapsed: true,
10296
items: [
103-
{ label: 'Overview', link: '/web-dashboard/architecture/overview' },
97+
{ label: 'Overview', link: '/web-dashboard/architecture/index' },
10498
{ label: 'State Management (BLoC)', link: '/web-dashboard/architecture/state-management' },
10599
{ label: 'Routing (go_router)', link: '/web-dashboard/architecture/routing' },
106100
],
Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,38 @@
11
---
2-
title: Deployment Guide
3-
description: Learn how to deploy the API server to a production environment.
2+
title: 'Deployment: API Server'
3+
description: A guide to building and deploying the Dart Frog API server to a production environment.
44
---
55

66
import { Steps, Aside } from '@astrojs/starlight/components';
77

8-
This guide outlines the strategy for deploying the API server to a production environment. The recommended method is to use Docker, which creates a portable and consistent container for your application.
8+
This guide outlines the process for deploying the API server to a production environment. The server is built with Dart Frog and packaged as a Docker container, making it portable and easy to deploy to any hosting provider that supports Docker.
99

1010
<Aside>
11-
The world of cloud hosting and deployment tools evolves rapidly. Instead of providing specific commands that could become outdated, this guide focuses on the essential steps and links to the official documentation for the relevant services. This ensures you always have access to the most current and accurate instructions.
11+
To ensure you have the most reliable and up-to-date instructions, this guide focuses on the project-specific configuration you need to complete. For the deployment itself, we will refer you to the excellent official documentation from the Dart Frog team, which is the definitive resource.
1212
</Aside>
1313

14-
<Steps>
15-
1. **Configure Production Environment Variables**
14+
### Pre-Deployment Configuration
1615

17-
Your first step is to prepare the production configuration for the server. Unlike local development which uses a `.env` file, in production you will use your hosting provider's interface to set environment variables securely.
16+
Before you can deploy, you must complete two essential configuration steps.
1817

19-
For a detailed explanation of each required variable, please see the [Configure Environment Variables](/docs/api-server/guides/configure-environment-variables) guide.
20-
21-
2. **Choose a Deployment Strategy**
18+
<Steps>
19+
1. **Configure Production Environment Variables**
2220

23-
The API server repository includes a `Dockerfile`, which allows for two main deployment strategies:
21+
In your production environment, you will not use a `.env` file. Instead, you must configure the environment variables directly in your chosen hosting provider's interface. This is a critical step for security and proper configuration.
2422

25-
- **Deploying a Pre-built Image:** You build the Docker image on your local machine or in a CI/CD pipeline, push it to a container registry (like Docker Hub, Google Container Registry, or Amazon ECR), and then your hosting provider pulls the image from the registry.
26-
- **Deploying from Source:** You connect your Git repository directly to the hosting provider, and it uses the `Dockerfile` to build and deploy the image for you.
23+
For a detailed explanation of each required variable, please see the [**Configure Environment Variables Guide**](/docs/api-server/guides/configure-environment-variables).
2724

28-
3. **Deploy to a Hosting Provider**
25+
2. **Configure CORS**
2926

30-
Choose a hosting provider that supports Docker container deployments. Popular and well-documented options include:
31-
- [Google Cloud Run](https://cloud.google.com/run/docs/deploying)
32-
- [Amazon Elastic Container Service (ECS)](https://aws.amazon.com/ecs/)
33-
- [DigitalOcean App Platform](https://www.digitalocean.com/docs/app-platform/)
34-
- [Render](https://render.com/docs/docker)
27+
For the Web Dashboard to communicate with your API in production, you must correctly configure Cross-Origin Resource Sharing (CORS) by setting the `CORS_ALLOWED_ORIGIN` environment variable.
3528

36-
Follow the official documentation from your chosen provider to deploy your container. During the setup process, you will be prompted to configure the environment variables from Step 1.
29+
For instructions, see the [**Configure CORS Guide**](/docs/api-server/guides/configure-cors).
30+
</Steps>
3731

38-
4. **Configure CORS**
32+
### Deployment with Dart Frog
3933

40-
For your web-based dashboard to communicate with the API in production, you must correctly configure Cross-Origin Resource Sharing (CORS).
34+
Once your configuration is ready, you can proceed with the deployment. The Dart Frog documentation provides comprehensive guides for various hosting providers and deployment strategies (e.g., using Docker, deploying to Google Cloud Run, etc.).
4135

42-
For instructions, see the [Configure CORS](/docs/api-server/guides/configure-cors) guide.
36+
Following the official documentation is the recommended and most reliable path to a successful deployment.
4337

44-
</Steps>
38+
**[Official Dart Frog Deployment Guides](https://dartfrog.vgv.dev/docs/category/deploy)**

src/content/docs/api-server/guides/implement-alternative-email-client.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ This guide demonstrates the value of this architecture by walking you through th
1313

1414
The core of this flexibility is the `EmailClient` abstract class, defined in the `email_client` package. Any email service you wish to use must have a corresponding class that implements this interface.
1515

16-
The contract is simple:
16+
The contract, defined in the `email_client` package, is simple:
1717

1818
```dart
19-
// path: packages/email_client/lib/src/email_client.dart
19+
// lib/src/email_client.dart
2020
abstract class EmailClient {
2121
const EmailClient();
2222
@@ -34,7 +34,7 @@ abstract class EmailClient {
3434
Let's create a simple "logging" email client that doesn't actually send emails but instead prints the details to the console. This is useful for local development or testing.
3535

3636
1. **Create the Implementation File:**
37-
Create a new file, for example, `packages/email_logging/lib/src/email_logging.dart`.
37+
You can create a new implementation anywhere, but for this example, let's assume you create a new local file for testing purposes.
3838

3939
2. **Implement the `EmailClient`:**
4040

@@ -71,7 +71,7 @@ Let's create a simple "logging" email client that doesn't actually send emails b
7171

7272
Swapping the implementation is the easiest part. You only need to change a single part of the dependency injection setup.
7373

74-
Open the dependency configuration file: `apps/flutter-news-app-api-server-full-source-code/lib/src/config/app_dependencies.dart`.
74+
Open the dependency configuration file within the API server project: `lib/src/config/app_dependencies.dart`.
7575

7676
<Tabs>
7777
<TabItem label="Before (Default)">

src/content/docs/api-server/index.mdx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: API Server
3-
description: An overview of the high-performance Dart Frog backend that powers the Flutter News App ecosystem.
2+
title: 'API Server: Introduction'
3+
description: An overview of the high-performance Dart Frog backend that powers the Flutter News App toolkit.
44
---
55

66
import { Card, CardGrid } from '@astrojs/starlight/components';
@@ -10,24 +10,28 @@ The API Server is the core backend component of the Flutter News App Toolkit. Bu
1010
It is designed to work seamlessly with the [Mobile Client](/docs/mobile-client/) and the [Web Dashboard](/docs/web-dashboard/).
1111

1212
<CardGrid>
13-
<Card title="Getting Started" icon="rocket">
13+
<Card title="Local Setup" icon="rocket">
1414
Follow the local setup guide to get the server running on your machine.
15-
[Read more &rarr;](/docs/api-server/getting-started/)
15+
[Read more &rarr;](/docs/api-server/local-setup/)
1616
</Card>
1717
<Card title="Deployment" icon="cloud">
1818
Learn how to deploy the API server to a production environment.
1919
[Read more &rarr;](/docs/api-server/deployment/)
2020
</Card>
2121
<Card title="Features" icon="puzzle">
22-
Explore the key features and architecture of the API server.
23-
[Read more &rarr;](/docs/api-server/features/authentication/)
22+
Explore the key features of the API server, from authentication to data management.
23+
[Read more &rarr;](/docs/api-server/features/)
24+
</Card>
25+
<Card title="Architecture" icon="tree-structure">
26+
Dive into the architectural patterns that make the server robust and maintainable.
27+
[Read more &rarr;](/docs/api-server/architecture/)
2428
</Card>
2529
<Card title="API Reference" icon="open-book">
2630
A complete reference for all API endpoints and data models.
2731
[Read more &rarr;](/docs/api-server/reference/)
2832
</Card>
2933
<Card title="How-To Guides" icon="document">
3034
Practical guides for specific configuration and setup tasks.
31-
[Read more &rarr;](/docs/api-server/guides/configure-environment-variables/)
35+
[Read more &rarr;](/docs/api-server/guides/)
3236
</Card>
3337
</CardGrid>

src/content/docs/core-philosophy.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: 'Core Philosophy: Built for Production'
3+
description: An overview of the architectural principles that ensure the toolkit is robust, maintainable, and scalable.
4+
---
5+
6+
import { Aside } from '@astrojs/starlight/components';
7+
8+
This toolkit was not just built to work; it was architected to last. Every component, from the backend API to the mobile client, is built on a foundation of production-ready principles. Understanding this philosophy is key to appreciating the long-term value and maintainability of the source code you've acquired.
9+
10+
Our goal is to provide a codebase that is a pleasure to work with—one that you can confidently build upon, customize, and scale.
11+
12+
### The "Make it Right" Principle
13+
14+
Our guiding principle is to **default to production-ready patterns**, even when simpler alternatives exist. This prioritizes long-term code quality, testability, and maintainability over short-term implementation speed.
15+
16+
Key aspects of this principle include:
17+
18+
- **Dependency Injection:** We consistently use dependency injection (DI) throughout the toolkit. Services, repositories, and clients are injected rather than instantiated directly. This decouples our components, making them easy to test in isolation and simple to swap out. For example, the default SendGrid email client can be replaced with another provider by changing a single line in the DI container.
19+
20+
- **Immutability:** All data models and state classes are immutable. This leads to more predictable state management, eliminates a whole class of potential bugs related to side effects, and makes debugging easier.
21+
22+
- **Testability by Design:** The entire system is structured to be easily testable. With clear boundaries between layers and the use of DI, you can write targeted unit tests for business logic without needing to run the entire application. We mandate a high test coverage standard across all packages.
23+
24+
### A Clean, Layered Architecture
25+
26+
The toolkit follows a classic layered architecture, ensuring a clear separation of concerns. This structure is applied consistently across all applications.
27+
28+
1. **Data Layer (Clients):** The lowest layer, responsible for all communication with external sources (like the database or third-party APIs). It handles the raw data fetching and maps external errors to a set of standardized exceptions.
29+
30+
2. **Repository Layer:** This layer abstracts the data sources. It provides a clean, consistent API for the business logic layer to consume, without needing to know *how* or *where* the data is stored.
31+
32+
3. **Business Logic Layer (BLoC / Services):** This layer contains the core application logic. In the Flutter apps, this is implemented using the **BLoC pattern**. In the backend, it's handled by **Services**. This layer orchestrates data from repositories and enforces business rules.
33+
34+
4. **Presentation Layer (UI / Routes):** The top layer, responsible for presenting data to the user and capturing their input. In the Flutter apps, this is the widget tree. In the API server, these are the route handlers. This layer is kept as "dumb" as possible, reacting to state changes from the business logic layer.
35+
36+
<Aside>
37+
This clean separation means you can change the UI without touching business logic, or swap a database without affecting the UI. This is the key to a maintainable and scalable application.
38+
</Aside>
39+
40+
### Standardized and Predictable Code
41+
42+
- **Shared `core` Package:** A central `core` package contains all shared data models, enumerations, and a standardized set of `Exception` classes. This ensures that the mobile client, web dashboard, and API server all speak the same language.
43+
44+
- **Consistent Error Handling:** All errors are mapped to the standardized exceptions from the `core` package at the data layer. This means BLoCs and services can handle errors in a predictable way, regardless of their origin.
45+
46+
- **Strict Data Modeling:** All data models follow strict rules: they are immutable, use `camelCase` for JSON serialization, and forbid optional properties to prevent null-related errors.
47+
48+
By adhering to these principles, we've created a toolkit that is not only functional but also robust, testable, and ready for you to build your business on.

src/content/docs/start-here/deployment-guides.mdx renamed to src/content/docs/deployment.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
2-
title: 'Deployment Guides: From Local to Live'
2+
title: 'Deployment: From Local to Live'
33
description: A collection of guides to help you deploy the API server, mobile app, and web dashboard to production environments.
44
---
55

66
import { Steps } from '@astrojs/starlight/components';
77

8-
Once you have the ecosystem running locally, the next step is to deploy the components to production. These guides provide step-by-step instructions for preparing and deploying each part of the toolkit.
8+
Once you have the toolkit running on your local machine, the next step is to go live. These guides provide clear, step-by-step instructions for preparing and deploying each component of the toolkit to a production environment.
99

1010
<Steps>
1111
1. **Deploy the API Server**
1212

13-
Learn how to configure and deploy the Dart Frog backend to a production server using Docker.
13+
Learn how to configure and deploy the Dart Frog backend to a production server.
1414

1515
[Go to API Deployment Guide &rarr;](/docs/api-server/deployment/)
1616

1717
2. **Deploy the Web Dashboard**
1818

19-
Follow these steps to build and deploy the Flutter web dashboard to a static hosting provider.
19+
Follow the steps to build and deploy the Flutter web dashboard to your preferred hosting provider.
2020

2121
[Go to Dashboard Deployment Guide &rarr;](/docs/web-dashboard/deployment/)
2222

src/content/docs/index.mdx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Your Flutter News App - Ready to Launch'
2+
title: 'Your Full-Stack Flutter News App - Ready to Launch'
33
description: A complete, production-ready toolkit for building a cross-platform news application.
44
template: splash
55
hero:
@@ -8,21 +8,23 @@ hero:
88
file: ../../assets/flutter-news-app-full-source-code-logo.png
99
actions:
1010
- text: 'Get Started: Local Setup'
11-
link: /docs/getting-started/
11+
link: /docs/local-setup/
1212
icon: right-arrow
1313
- text: 'View Live Demos'
14-
link: '#ecosystem'
14+
link: '#toolkit-components'
1515
icon: 'down-arrow'
1616
variant: minimal
1717
---
1818

1919
import { Card, CardGrid, LinkButton } from '@astrojs/starlight/components';
2020

21-
<div id="ecosystem">
22-
## A Complete, Production-Ready Ecosystem
23-
</div>
21+
## A Complete, Production-Ready Toolkit
22+
23+
Welcome to the Flutter News App Full Source Code Toolkit. This is more than just an app template; it's a complete, three-part toolkit designed to work seamlessly together, giving you everything you need to launch, manage, and scale a modern news application from a solid, well-architected foundation.
2424

25-
Welcome to the Flutter News App Full Source Code Toolkit. This is more than just an app template; it's a complete, three-part ecosystem designed to work seamlessly together, giving you everything you need to launch, manage, and scale a modern news application.
25+
<div id="toolkit-components">
26+
### The Toolkit Components
27+
</div>
2628

2729
<CardGrid>
2830
<Card title="Mobile Client App" icon="phone">
@@ -46,7 +48,7 @@ Welcome to the Flutter News App Full Source Code Toolkit. This is more than just
4648
href="https://github.com/flutter-news-app-full-source-code/flutter-news-app-mobile-client-full-source-code"
4749
target="_blank"
4850
>
49-
Download
51+
Browse on GitHub
5052
</a>
5153
</div>
5254
</Card>
@@ -71,7 +73,7 @@ Welcome to the Flutter News App Full Source Code Toolkit. This is more than just
7173
href="https://github.com/flutter-news-app-full-source-code/flutter-news-app-web-dashboard-full-source-code"
7274
target="_blank"
7375
>
74-
Download
76+
Browse on GitHub
7577
</a>
7678
</div>
7779
</Card>
@@ -92,25 +94,33 @@ Welcome to the Flutter News App Full Source Code Toolkit. This is more than just
9294
href="https://github.com/flutter-news-app-full-source-code/flutter-news-app-api-server-full-source-code"
9395
target="_blank"
9496
>
95-
Download
97+
Browse on GitHub
9698
</a>
9799
</div>
98100
</Card>
99101
</div>
100102

101-
## Choose Your Path
103+
## How the Toolkit Fits Together
104+
105+
The **API Server** is the central brain. Both the **Mobile Client** and the **Web Dashboard** communicate with it to fetch data, authenticate users, and retrieve configuration. The **Web Dashboard** is used to populate the content that the **Mobile Client** displays.
106+
107+
This separation of concerns makes the toolkit robust and flexible. You can manage your entire platform from the web and deliver updates to your mobile users instantly.
108+
109+
## Get Started: Try, Evaluate, and Launch
110+
111+
This toolkit is source-available, allowing you to explore the code and ensure it meets your standards before making a commitment.
102112

103113
<CardGrid>
104-
<Card title="Start Your 32-Day Trial" icon="laptop">
114+
<Card title="Start Your Free Trial" icon="laptop">
105115
Download the complete source code and run the entire system on your local
106-
machine. The trial license allows for a full evaluation of the project's
107-
quality and features for 32 days.
116+
machine. The PolyForm Free Trial license allows for a full evaluation of the project's
117+
quality and features.
108118
<div style={{ marginTop: '1.5rem' }}>
109-
<LinkButton href="/docs/getting-started/">Begin Local Setup</LinkButton>
119+
<LinkButton href="/docs/local-setup/">Begin Local Setup</LinkButton>
110120
</div>
111121
</Card>
112122
<Card title="Purchase a Lifetime License" icon="rocket">
113-
A one-time purchase grants you a lifetime commercial license to build,
123+
Ready to go live? A one-time purchase grants you a lifetime commercial license to build,
114124
customize, and deploy unlimited applications, complete with lifetime
115125
updates.
116126
<div style={{ marginTop: '1.5rem' }}>

0 commit comments

Comments
 (0)