Skip to content
This repository was archived by the owner on Sep 8, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
backend/target
backend/.env
backend/start.bat

frontend/elm-stuff

.idea
.idea
Binary file added Database_Relationship_Diagram.pdf
Binary file not shown.
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 Mockups/PNG/Chemical Database New Chemical 2.png
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 Mockups/PNG/Chemical Database New Chemical 3.png
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 Mockups/PNG/Chemical Database New Chemical.png
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 Mockups/PNG/Chemical Database Search.png
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 Mockups/PNG/Chemical Database Website.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
400 changes: 400 additions & 0 deletions Mockups/SVG/Chemical Database Advanced Search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
630 changes: 630 additions & 0 deletions Mockups/SVG/Chemical Database New Chemical 2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
411 changes: 411 additions & 0 deletions Mockups/SVG/Chemical Database New Chemical 3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions Mockups/SVG/Chemical Database New Chemical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
772 changes: 772 additions & 0 deletions Mockups/SVG/Chemical Database Search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
276 changes: 276 additions & 0 deletions Mockups/SVG/Chemical Database Website.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,4 @@ Coded in Rust, manages database manipulation using AJAX requests from frontend.
* [simplelog](https://github.com/drakulix/simplelog.rs)

## frontend
Coded in Elm, makes requests to the backend to access database and returns to the user.

### Dependencies:
* Core Elm Packages
* [browser](https://github.com/elm/browser)
* [core](https://github.com/elm/core)
* [html](https://github.com/elm/html)
* [http](https://github.com/elm/http)
* [json](https://github.com/elm/json)
* [url](https://github.com/elm/url)
* [bytes](https://github.com/elm/bytes)
* [file](https://github.com/elm/file)
* [time](https://github.com/elm/time)
* [virtual-dom](https://github.com/elm/virtual-dom)
* [elm-json-decode-pipeline 1.0.0](https://github.com/NoRedInk/elm-json-decode-pipeline)
* [elm-format-number 6.0.2](https://github.com/cuducos/elm-format-number)
* [elm-round 1.0.4](https://github.com/myrho/elm-round)
Coded in HTML/CSS/JS, makes requests to the backend to access database and returns to the user.
63 changes: 63 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
rouille = "3.0.0"
diesel = { version = "1.3.3", features = ["mysql"] }
diesel_migrations = "1.4.0"
dotenv = "0.13.0"
serde = { version = "1.0", features = ["derive"]}
serde_json = "1.0"
Expand Down
17 changes: 17 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use rust image
FROM rust:1.33

# Set working directory of rust app
WORKDIR /usr/src/webdev

# Copy current directory, into docker
COPY . /usr/src/webdev

# Build the app
RUN cargo build --release

# Make port 8080 available
EXPOSE 8000:8000

# Run the app
CMD ["target/release/web_dev"]
3 changes: 3 additions & 0 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#[macro_use]
extern crate diesel;

#[macro_use]
extern crate diesel_migrations;


pub mod errors;
pub mod users;
Expand Down
28 changes: 20 additions & 8 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#[macro_use]
extern crate diesel_migrations;

use std::env;
use std::sync::Mutex;
use std::thread;
use std::time;

use log::debug;
use log::error;
use log::info;
use log::trace;
use log::warn;

use diesel::prelude::*;
Expand All @@ -18,34 +22,42 @@ use web_dev::errors::WebdevErrorKind;
use web_dev::users::models::UserRequest;
use web_dev::users::requests::handle_user;

embed_migrations!();

fn main() {
dotenv().ok();

simplelog::TermLogger::init(simplelog::LevelFilter::Trace, simplelog::Config::default())
simplelog::SimpleLogger::init(simplelog::LevelFilter::Trace, simplelog::Config::default())
.unwrap();

info!("Connecting to database");

let database_url = match env::var("DATABASE_URL") {
Ok(url) => url,
Err(e) => {
Err(_e) => {
error!("Could not read DATABASE_URL environment variable");
return;
}
};

debug!("Connecting to {}", database_url);

let connection = match MysqlConnection::establish(&database_url) {
Ok(c) => c,
Err(e) => {
error!("Could not connect to database: {}", e);
return;
let connection = loop {
match MysqlConnection::establish(&database_url) {
Ok(c) => break c,
Err(e) => {
warn!("Could not connect to database: {}", e);
info!("Retrying in a second");
thread::sleep(time::Duration::from_secs(1));
}
}
};

debug!("Connected to database");

info!("Running migrations");
embedded_migrations::run(&connection);

let connection_mutex = Mutex::new(connection);

info!("Starting server on 0.0.0.0:8000");
Expand Down
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: "3.1"
services:
api:
image: webdev_api
deploy:
replicas: 1
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "8000:8000"
environment:
DATABASE_URL: mysql://root:apple1@db/web_dev

db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: apple1
MYSQL_DATABASE: web_dev

frontend:
image: webdev_frontend
ports:
- "80:80"

3 changes: 3 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker build -t webdev_frontend frontend
docker build -t webdev_api backend
docker-compose up -d
5 changes: 5 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM httpd:2.4
COPY ./www /usr/local/apache2/htdocs
COPY ./apache2/httpd.conf /usr/local/apache2/conf/httpd.conf
EXPOSE 80

Loading