Welcome to the News App Backend project! This repository serves as the backend component for the News App, a Flutter application designed to deliver the latest news to users. The backend is built to provide data and functionality to support the app's features.
Backend is built using NestJS, a NodeJS framework. It is a REST API that provides endpoints for the app to consume. For data storage, the backend uses MySQL and interacts with it using TypeORM.
This project is made as a sample project and implements some of the common features found in a typical backend application. List of features:
- REST Api (CRUD operations)
- GraphQL basics (query, mutation)
- Authentication and Authorization (JWT, basic auth, username/password login)
- Testing (Jest)
- Firebase Cloud Messaging (FCM) push notifications (via firebase-admin)
- Sending emails
- Exporting data to Excel file
- File uploads and downloads
- Dockerization
- Cron jobs
- Sentry error logging
- Serving static files
- Migration scripts
- Exception filters
- Logging to file and managing log files
A demo of the backend can be found at https://news.belligerator.cz/api/. The demo is running on a Docker container.
For that purpose I have created a docker image for the backend. The image can be found at https://hub.docker.com/r/belligerator/news-backend. The image is built using the Dockerfile in the root directory of this repository.
On the server, there is docker-compose file that is used to run the backend and MySQL database. The file can be found at https://github.com/Belligerator/news-docker.
Mobile application is built using Flutter (v3.7.1) and source codes can be found at https://github.com/Belligerator/news-app. It is connected to the demo backend and can be downloaded at https://belligerator.cz/downloads/ (news-<version>.apk
). It is available for Android only.
For running the backend locally, you will need the following:
- NodeJS (v18)
- NestJS (v10)
- MySQL (v5.7)
- Docker (v20) - not required, it was used for creating the image and running the demo from the server.
-
Clone the repo news-backend
git clone git@github.com:Belligerator/news-backend.git
-
Install NPM packages
npm install
-
Create a
.env
file in the root directory and fill in the required environment variables. You can refer to the.env.example
file for the required variables. -
Create database schema
news
in database. Migration scripts will create the tables in the next step. -
Run the app
npm run start
The app should be running on
http://localhost:3000/
. -
In the root directory, there is a
news.postman_collection.json
file that contains a Postman collection with sample requests. You can import it into Postman and use it to test the endpoints.
Documentation for the endpoints can be found at https://news.belligerator.cz/api/swagger.
Documentation for the backend can be found at https://news.belligerator.cz/api/documentation.