Local Setup
This guide will walk you through setting up the API server in a local development environment.
-
Prerequisites
Ensure you have the following software installed on your system:
- Dart SDK: Version
3.0.0
or higher. - MongoDB: Version
5.0
or higher is recommended. - Dart Frog CLI: Install it globally by running:
Terminal window dart pub global activate dart_frog_cli
- Dart SDK: Version
-
Clone the Repository
If you haven’t already, clone the repository to your local machine.
Terminal window git clone https://github.com/flutter-news-app-full-source-code/flutter-news-app-api-server-full-source-code.gitcd flutter-news-app-api-server-full-source-code -
Set Up Local Database
The API server requires a MongoDB database. For local development, the recommended approach is to use Docker.
-
Configure Environment Variables
The server uses a
.env
file to manage secrets and configuration. You will need to create this file and populate it with the correct values for your local environment. -
Install Dependencies
Navigate to the server’s root directory and fetch the required Dart packages:
Terminal window dart pub get -
Run the Development Server
Start the Dart Frog development server:
Terminal window dart_frog dev -
Automatic Database Seeding
On its first startup, the server automatically connects to your MongoDB database and seeds it with initial data (countries, topics, users, etc.). This process is idempotent, meaning you can safely restart the server multiple times without creating duplicate data.