# alexhippo/full-stack-app-with-react-rest-api architecture

> Architecture diagram of the GitHub repository alexhippo/full-stack-app-with-react-rest-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexhippo/full-stack-app-with-react-rest-api
- Repository: https://github.com/alexhippo/full-stack-app-with-react-rest-api

## Overview

##### Main System Components

a) Client-Side (Frontend):
- React Application Layer
- Component Structure
- Context API for state management
- Authentication handling
- Route management

b) Server-Side (Backend):
- Express REST API
- Authentication middleware
- Database layer (SQLite with Sequelize ORM)
- Route handlers

**[Client Tier] <-> [API Tier] <-> [Data Tier]**

##### Detailed Component Breakdown

Frontend (Client Tier):
- User Components (SignIn, SignUp, SignOut)
- Course Components (Courses, CourseDetail, CreateCourse, UpdateCourse)
- Error Components (Forbidden, NotFound, UnhandledError)
- Context Provider for global state
- Private Routes for authentication

API Tier:
- Authentication Middleware
- Route Handlers (users.js, courses.js)
- Async Handler Middleware
- Error Handling

Data Tier:
- Sequelize Models (User, Course)
- Database Relations
- SQLite Database

##### Interaction Flows

- HTTP requests between Client and API (GET, POST, PUT, DELETE)
- Database queries between API and Data tier
- Authentication flow
- Protected route handling

##### Technical Details

Annotations for:
- Port numbers (3000 for client, 5000 for API)
- Authentication tokens
- Database connection
- Key dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client[Client Tier]
        direction TB
        App["React App"]:::frontend
        click App "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/App.js"
        
        subgraph Components[React Components]
            direction TB
            UserComps[User Components]:::frontend
            CourseComps[Course Components]:::frontend
            ErrorComps[Error Components]:::frontend
            
            subgraph UserComponents[User Management]
                direction TB
                SignIn["Sign In"]:::frontend
                SignUp["Sign Up"]:::frontend
                SignOut["Sign Out"]:::frontend
            end
            click SignIn "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/User/UserSignIn.js"
            click SignUp "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/User/UserSignUp.js"
            click SignOut "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/User/UserSignOut.js"
            
            subgraph CourseComponents[Course Management]
                direction TB
                Courses["Course List"]:::frontend
                CourseDetail["Course Detail"]:::frontend
                CreateCourse["Create Course"]:::frontend
                UpdateCourse["Update Course"]:::frontend
            end
            click Courses "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Courses/Courses.js"
            click CourseDetail "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Courses/CourseDetail.js"
            click CreateCourse "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Courses/CreateCourse.js"
            click UpdateCourse "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Courses/UpdateCourse.js"
            
            subgraph ErrorComponents[Error Handling]
                direction TB
                Forbidden["Forbidden"]:::frontend
                NotFound["Not Found"]:::frontend
                UnhandledError["Unhandled Error"]:::frontend
            end
            click Forbidden "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Errors/Forbidden.js"
            click NotFound "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Errors/NotFound.js"
            click UnhandledError "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Components/Errors/UnhandledError.js"
        end
        
        Context["Context API"]:::state
        PrivateRoute["Private Route"]:::security
        click Context "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/Context.js"
        click PrivateRoute "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/client/src/PrivateRoute.js"
    end
    
    subgraph API[API Tier]
        direction TB
        ExpressServer["Express Server"]:::api
        click ExpressServer "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/app.js"
        
        AuthMiddleware["Authentication Middleware"]:::security
        AsyncHandler["Async Handler"]:::middleware
        click AuthMiddleware "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/middleware/auth-user.js"
        click AsyncHandler "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/middleware/async-handler.js"
        
        subgraph Routes[Route Handlers]
            direction TB
            UserRoutes["User Routes"]:::api
            CourseRoutes["Course Routes"]:::api
        end
        click UserRoutes "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/routes/users.js"
        click CourseRoutes "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/routes/courses.js"
    end
    
    subgraph Data[Data Tier]
        direction TB
        Database["SQLite Database"]:::database
        click Database "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/fsjstd-restapi.db"
        
        subgraph Models[Database Models]
            direction TB
            UserModel["User Model"]:::database
            CourseModel["Course Model"]:::database
        end
        click UserModel "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/models/user.js"
        click CourseModel "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/models/course.js"
        
        DBConfig["Database Config"]:::database
        click DBConfig "https://github.com/alexhippo/full-stack-app-with-react-rest-api/blob/master/api/config/config.json"
    end
    
    %% Connections
    Client --> |HTTP Requests| API
    API --> |Queries| Data
    Context --> Components
    PrivateRoute --> Components
    
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef state fill:#9b59b6,stroke:#8e44ad,color:white
    classDef middleware fill:#95a5a6,stroke:#7f8c8d,color:white
    
    %% Legend
    subgraph Legend
        direction TB
        Frontend["Frontend Component"]:::frontend
        APIComp["API Component"]:::api
        DBComp["Database Component"]:::database
        SecurityComp["Security Component"]:::security
        StateComp["State Management"]:::state
        MiddlewareComp["Middleware"]:::middleware
    end
```
