This project is an API built using **Java, Java Spring Boot, Postgres. **
Database and application service uses Railway cloud platform.
- Java 17
- Spring Boot 3
- H2 (local)
- PostgreSQL (production)
- Railway
- OpenAPI (Swagger)
- CI/CD direct from GitHub
The API manages user records, accounts, cards, and provides news and resources, and demonstrates how to set up an application to run the application and database on the Railway cloud platform. Build and deployment updates are automated with the platform's integration with GitHub. For example, when the repository receives updates, the cloud service automatically generates a new build, according to the configuration, and can perform the deployment automatically.
- Installation
- Configuration
- Local Usage
- Cloud Usage
- Class Diagram
- API Endpoints
- Contributing
- Screenshots
- Clone the repository:
git clone https://github.com/jonasfschuh/JavaRESTfulAPI.git
notes:
Spring initializr of this project
- Install dependencies with Maven
- Start the application with Maven
- The API will be accessible at http://localhost:8080/swagger-ui/index.html
- The H2 Database will be accessible at http://localhost:8080/h2-console with H2 Database credentials: user: admin password:
- Create a railway account https://railway.app/, and
- Create a Postgres database.
- Set the environment variables of API on IntelliJ as generated by the Postgres container on railway.
- Logged into railway, configure the integration with github to generate continuous integration and delivery.
- Create a service in railway. When deploying, the application will build and start the application automatically.
Notes: This service allows you to configure a domain to expose this service and make it accessible outside the container.
- Below is an example generated in my configuration to access swagger-ui.
Interface for testing with swagger-ui - on railway cloud https://jfs-2024-api-prd.up.railway.app/swagger-ui/index.html
Class generated in the mermaid pattern https://mermaid.js.org/intro/
classDiagram
class User {
-String name
-Account account
-Feature[] features
-Card card
-News[] news
}
class Account {
-String number
-String agency
-Number balance
-Number limit
}
class Feature {
-String icon
-String description
}
class Card {
-String number
-Number limit
}
class News {
-String icon
-String description
}
User "1" *-- "1" Account
User "1" *-- "N" Feature
User "1" *-- "1" Card
User "1" *-- "N" News
Example POST data
{
"name": "jonas fernando schuh",
"account": {
"number": "1392-7",
"agency": "1243-2",
"balance": 300,
"limit": 6000
},
"card": {
"number": "xxxx xxxx xxxx 0000",
"limit": 20000
},
"features": [
{
"icon": "URL",
"description": "Feature description"
}
],
"news": [
{
"icon": "URL",
"description": "News description"
}
]
}
The API provides the following endpoints:
GET /users/{id} - Retrieve a specific user base on its ID
GET /users - Retrieve a list of all registered users
PUT /users/{id} - Update the data of an existing user based on its ID
DELETE /users/{id} - Delete an existing user based on its ID
POST /users - Create a new user and return the create user´s data
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request to the repository.
When contributing to this project, please follow the existing code style, commit conventions, and submit your changes in a separate branch.
Railway dashboard with CI/CD from github.
Every time a push is made to the main branch of the repository, the application is compiled and deployed automatically.