Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment to production #11

Merged
merged 68 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
542375a
Merge pull request #2 from fmanimashaun/main
fmanimashaun Jan 15, 2024
354b83e
Complete the home page layout and styling to reflect the given design
fmanimashaun Jan 17, 2024
8318898
Add unit tests view and controller for the home page
fmanimashaun Jan 17, 2024
54c076a
Update the user model
fmanimashaun Jan 17, 2024
718f470
Add system test for the home page
fmanimashaun Jan 17, 2024
dafe2ef
Fix linter errors
fmanimashaun Jan 17, 2024
9cd291d
Update the readme
fmanimashaun Jan 17, 2024
4750933
Update the readme
fmanimashaun Jan 17, 2024
c4aead5
Merge pull request #3 from fmanimashaun/features/home
fmanimashaun Jan 17, 2024
9d5d683
Update user model
fmanimashaun Jan 17, 2024
e959817
Update the login page
fmanimashaun Jan 17, 2024
b38f97d
Update the view paddings
fmanimashaun Jan 17, 2024
99f4733
Add name attibute to the user table
fmanimashaun Jan 17, 2024
a283b70
Update the sign in and sign up view to align with the design
fmanimashaun Jan 17, 2024
a224767
Update the application controller
fmanimashaun Jan 17, 2024
e737aca
Add categories, expenses and categories_expenses models with associat…
fmanimashaun Jan 17, 2024
5c7d664
Update the categories controller and route
fmanimashaun Jan 18, 2024
84c6a65
Update the account edit page
fmanimashaun Jan 18, 2024
b8ca9ae
Update the registration view
fmanimashaun Jan 18, 2024
3b5027a
Update project
fmanimashaun Jan 18, 2024
86b38d7
Update the category home
fmanimashaun Jan 18, 2024
9bbc426
Update the category index veiw
fmanimashaun Jan 18, 2024
ff42dba
Update the expenses controller and views
fmanimashaun Jan 18, 2024
3cc4bf5
Update the transaction page
fmanimashaun Jan 19, 2024
28cf45b
update the navigation functionality
fmanimashaun Jan 19, 2024
8bdc6c9
update views
fmanimashaun Jan 19, 2024
c0e680d
Update notification message
fmanimashaun Jan 19, 2024
202a14b
Update the views
fmanimashaun Jan 19, 2024
c9e0879
Update teh views
fmanimashaun Jan 19, 2024
c79ac92
Update the controller
fmanimashaun Jan 19, 2024
efc108f
Fix linter errors
fmanimashaun Jan 19, 2024
bedc402
Merge pull request #6 from fmanimashaun/features/login-signup
fmanimashaun Jan 19, 2024
679c449
Update views
fmanimashaun Jan 19, 2024
39c426a
Add render yaml
fmanimashaun Jan 19, 2024
e1dae12
Update render yaml
fmanimashaun Jan 19, 2024
450ec78
Merge pull request #7 from fmanimashaun/features/login-signup
fmanimashaun Jan 19, 2024
c244111
Update render yaml
fmanimashaun Jan 19, 2024
6190db3
Merge pull request #8 from fmanimashaun/features/login-signup
fmanimashaun Jan 19, 2024
2642a76
Update
fmanimashaun Jan 19, 2024
28a1508
Update render yaml
fmanimashaun Jan 19, 2024
305ef84
Update render yaml
fmanimashaun Jan 19, 2024
90d12c4
Update render yaml
fmanimashaun Jan 19, 2024
7f3d532
Update render yaml
fmanimashaun Jan 19, 2024
190c7aa
Update render yaml
fmanimashaun Jan 19, 2024
5e4c22a
Update render yaml
fmanimashaun Jan 19, 2024
968f205
Update render yaml
fmanimashaun Jan 19, 2024
b0e4515
Update render yaml
fmanimashaun Jan 19, 2024
f345dd8
Update config
fmanimashaun Jan 19, 2024
f454860
Update readme
fmanimashaun Jan 20, 2024
0b5985b
Update readme
fmanimashaun Jan 20, 2024
5eb341c
Update factoryBot
fmanimashaun Jan 20, 2024
cafd8ff
Add the categories controller unit test
fmanimashaun Jan 20, 2024
3cae654
Add expenses controller unit test
fmanimashaun Jan 20, 2024
5c4e512
review the view tests in spec
fmanimashaun Jan 20, 2024
374c77b
Fix linter errors
fmanimashaun Jan 20, 2024
723077f
Add unit tests for the models
fmanimashaun Jan 20, 2024
6ffd06d
Add category system tests
fmanimashaun Jan 20, 2024
dd178e5
Update project dependencies
fmanimashaun Jan 20, 2024
07379c1
Update the linter error and add expense system test
fmanimashaun Jan 20, 2024
3641f83
Fix the error in category system test
fmanimashaun Jan 20, 2024
5af0829
Update the setup
fmanimashaun Jan 20, 2024
cd139d9
Update expense system test
fmanimashaun Jan 20, 2024
5b282cb
Update expense system test
fmanimashaun Jan 20, 2024
24bd59b
Fix linter errors
fmanimashaun Jan 20, 2024
cb39a3a
Update expense system test
fmanimashaun Jan 20, 2024
5b25e53
Update expense system test
fmanimashaun Jan 20, 2024
6acbe76
Fix linter error
fmanimashaun Jan 20, 2024
7cffd93
Merge pull request #10 from fmanimashaun/combined-soln
fmanimashaun Jan 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ gem 'tzinfo-data', platforms: %i[windows jruby]
gem 'bootsnap', require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# authorization
gem 'cancancan'
# gem 'image_processing', '~> 1.2'

# add devise for authentication
gem 'devise'
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ GEM
bootsnap (1.17.1)
msgpack (~> 1.2)
builder (3.2.4)
cancancan (3.5.0)
capybara (3.39.2)
addressable
matrix
Expand Down Expand Up @@ -305,7 +304,6 @@ PLATFORMS

DEPENDENCIES
bootsnap
cancancan
capybara
debug
devise
Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Budget App
# Budget App - Budgetti

<a name="readme-top"></a>

Expand All @@ -24,9 +24,9 @@

<!-- PROJECT DESCRIPTION -->

## 📖 Budget App <a name="about-project"></a>
## 📖 Budget App - Budgetti <a name="about-project"></a>

The **Budget App** is a comprehensive solution for managing personal finances, designed using Ruby on Rails with a PostgreSQL database. This fully functional application allows users to create categories, track transactions, and get an overview of their spending. An important feature of the app is its ability to associate transactions with categories, enabling users to understand their spending habits better. This promotes responsible financial management, which is a vital part of personal finance. The Budget App is not just an application, but a financial companion that enhances the budgeting experience by organizing and simplifying the process
The **Budget App - Budgetti** is a comprehensive solution for managing personal finances, designed using Ruby on Rails with a PostgreSQL database. This fully functional application allows users to create categories, track transactions, and get an overview of their spending. An important feature of the app is its ability to associate transactions with categories, enabling users to understand their spending habits better. This promotes responsible financial management, which is a vital part of personal finance. The Budget App is not just an application, but a financial companion that enhances the budgeting experience by organizing and simplifying the process

## 🛠 Built With <a name="built-with"></a>

Expand Down Expand Up @@ -77,7 +77,12 @@ The **Budget App** is a comprehensive solution for managing personal finances, d

### Screenshots <a name="key-features"></a>

<img src="#" alt="public index without login" width="500"/>
<img src="screenshots/splash-screen.png" alt="public index without login" width="500"/>

### LIVE DEMO <a name="live-demo">

> [LIVE Link](https://budget-app-gsnk.onrender.com/)
> [Video demo](https://www.loom.com/share/d45038fec4da479a850a62cc4929b4e7?sid=442ca8e7-66da-458b-9421-e4dcabeede23)


<p align="right"><a href="#readme-top">👆</a></p>
Expand Down Expand Up @@ -106,6 +111,8 @@ git clone https://github.com/fmanimashaun/budget-app.git
cd budget-app

bundle install

npm install
```

## Database Setup
Expand Down Expand Up @@ -187,7 +194,9 @@ If you like this project leave a start for it.

## 🙏 Acknowledgments <a name="acknowledgements"></a>

I'd like to thank Microverse for helping us in the journey to become a Fullstack developer.
- I'd like to thank Microverse for helping us in the journey to become a Fullstack developer.

- Special appreciation [Gregoire Vella on Behance](https://www.behance.net/gregoirevella) for the Original design idea

<p align="right"><a href="#readme-top">👆</a></p>

Expand Down
1 change: 1 addition & 0 deletions app/assets/images/back-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions app/assets/images/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/login.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/promo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/setting.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 34 additions & 2 deletions app/assets/stylesheets/application.tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,42 @@

@font-face {
font-family: 'Proxima Nova Light';
src: url('../fonts/ProximaLight.otf') format('opentype');
src: url('ProximaLight.otf') format('opentype');
}

@font-face {
font-family: 'Proxima Nova Bold';
src: url('../fonts/ProximaBold.otf') format('opentype');
src: url('ProximaBold.otf') format('opentype');
}

.session input::placeholder {
@apply bg-white;
@apply text-accent-100;
}

#content {
transition: transform 0.3s ease-out, margin-block 0.3s ease-out;
}

.off-canvas {
position: relative;
transform: translateX(300px);
margin-block: 50px;
}

.close {
left: -300px;
}

.toast {
background-color: #333;
color: white;
padding: 16px;
position: fixed;
z-index: 1;
left: 50%;
bottom: 120px;
font-size: 17px;
transform: translate(-50%, 0);
border-radius: 10px;
}
15 changes: 15 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :redirect_if_signed_in

protected

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end

private

def redirect_if_signed_in
redirect_to categories_path if user_signed_in? && request.path == root_path
end
end
30 changes: 30 additions & 0 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class CategoriesController < ApplicationController
before_action :authenticate_user!

def index
@categories = Category.where(user: current_user)
@total_spent = @categories.sum { |category| category.expenses.sum(:amount) }
end

def new
@category = Category.new
end

def create
@category = Category.new(category_params)
@category.user = current_user
if @category.save
flash[:notice] = 'Category was successfully created.'
redirect_to categories_path
else
render :new
end
end

private

# Only allow a list of trusted parameters through.
def category_params
params.require(:category).permit(:name, :icon)
end
end
32 changes: 32 additions & 0 deletions app/controllers/expenses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class ExpensesController < ApplicationController
before_action :authenticate_user!

def index
@category = Category.find(params[:category_id])
@expenses = @category.expenses.order(created_at: :desc)
end

def new
@expense = Expense.new
@categories = current_user.categories.all
end

def create
@expense = Expense.new(expense_params)
@expense.user = current_user
if @expense.save
flash[:notice] = 'Expense was successfully created.'
redirect_to categories_path
else
@categories = current_user.categories.all
render :new
end
end

private

# Only allow a list of trusted parameters through.
def expense_params
params.require(:expense).permit(:name, :amount, category_ids: [])
end
end
2 changes: 2 additions & 0 deletions app/helpers/categories_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CategoriesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/expenses_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ExpensesHelper
end
5 changes: 3 additions & 2 deletions app/javascript/application.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
import "@hotwired/turbo-rails"
import "controllers"
import "@hotwired/turbo-rails";
import "controllers";
import "./myScript.js";
7 changes: 0 additions & 7 deletions app/javascript/controllers/hello_controller.js

This file was deleted.

34 changes: 34 additions & 0 deletions app/javascript/myScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
document.addEventListener("turbo:load", () => {
console.log("Page loaded with Turbo Drive");

const menuBtn = document.querySelector("#menu-btn");
const content = document.querySelector("#content");
const menuBar = document.querySelector("#menubar");
const avatar = document.querySelector("#avatar");
const toast = document.querySelector("#toast");

var img = new Image();

img.src = "https://avatar.iran.liara.run/public";

img.onload = function () {
avatar.src = img.src;
};
img.onerror = function () {
avatar.src = avatar.dataset.avatarPath;
};

// add event listener
menuBtn.addEventListener("click", () => {
content.classList.toggle("off-canvas");
menuBar.classList.toggle("close");
});

// show toast if it has a message
if (toast.innerText.trim() !== "") {
toast.classList.remove("hidden");
setTimeout(() => {
toast.classList.add("hidden");
}, 5000); // The toast will be hidden after 5 seconds
}
});
3 changes: 0 additions & 3 deletions app/models/ability.rb

This file was deleted.

9 changes: 9 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Category < ApplicationRecord
belongs_to :user
has_one_attached :icon
has_many :category_expenses, dependent: :destroy
has_many :expenses, through: :category_expenses

validates :name, presence: true
validates :icon, presence: true
end
7 changes: 7 additions & 0 deletions app/models/category_expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CategoryExpense < ApplicationRecord
belongs_to :category
belongs_to :expense

validates :category, presence: true
validates :expense, presence: true
end
15 changes: 15 additions & 0 deletions app/models/expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Expense < ApplicationRecord
belongs_to :user
has_many :category_expenses, dependent: :destroy
has_many :categories, through: :category_expenses

validates :name, presence: true
validates :amount, presence: true, numericality: { greater_than: 0 }
validate :categories_not_select

def categories_not_select
return unless categories.any? { |category| category.name == 'Select at least one category' }

errors.add(:categories, 'cannot contain "Select at least one category"')
end
end
7 changes: 6 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
:recoverable, :validatable

has_many :categories, dependent: :destroy
has_many :expenses, dependent: :destroy

validates :name, presence: true
end
56 changes: 56 additions & 0 deletions app/views/categories/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<div class="relative w-full flex bg-gradient-to-tr from-primary to-dark-blue">
<%= render 'layouts/nav' %>

<div class="w-full flex flex-col bg-off-white relative" id="content">
<header class="bg-primary flex justify-between p-2">
<button id="menu-btn">
<%= image_tag 'menu.svg', alt: 'back arrow' %>
</button>
<h2 class="text-white">CATEGORIES</h2>
<%= link_to '#', class: "text-white" do %>
<%= image_tag 'search.svg', alt: 'search icon' %>
<% end %>
</header>

<div class="flex flex-col px-5 py-5 gap-2 flex-grow overflow-y-auto">
<% if @categories.empty? %>
<p>There are no categories yet.</p>
<% else %>
<% @categories.each do |category| %>
<div class="w-full">
<%= link_to category_expenses_path(category) do %>
<div
class="flex gap-2 items-center bg-white rounded-lg shadow-lg p-2"
>
<%=
image_tag category.icon,
alt: 'category image',
class: 'w-16 h-16'
%>
<div class="flex-grow">
<p
class="flex justify-between font-bold text-sm text-accent-100"
>
<span><%= category.name %></span>
<span><%=
number_to_currency(category.expenses.sum(:amount))
%></span>
</p>
</div>
</div>
<% end %>
</div>
<% end %>
<% end %>
</div>

<div class="w-full mt-auto bg-secondary p-2">
<%=
link_to 'ADD CATEGORY',
new_category_path,
class:
'block w-full text-center no-underline font-bold bg-transparent text-white border border-white p-2 rounded cursor-pointer'
%>
</div>
</div>
</div>
Loading
Loading