Browse Source

feat: US-001 - Project Structure and Build System Setup

- Root CMakeLists.txt with C++20 project definition
- Subdirectories: database/, webserver/, webui/, proto/, common/
- CMake FetchContent for gRPC, protobuf, nlohmann_json, spdlog, libsodium
- Build targets: smartbotic-db and smartbotic-server binaries
- .clang-format and .clang-tidy configuration files
- CMakePresets.json for debug/release builds with Ninja generator
Fszontagh 6 months ago
commit
312c855303

+ 128 - 0
.clang-format

@@ -0,0 +1,128 @@
+---
+Language: Cpp
+BasedOnStyle: Google
+
+# Indentation
+IndentWidth: 4
+TabWidth: 4
+UseTab: Never
+AccessModifierOffset: -4
+IndentCaseLabels: true
+IndentPPDirectives: BeforeHash
+NamespaceIndentation: None
+
+# Line length
+ColumnLimit: 120
+
+# Braces
+BreakBeforeBraces: Attach
+BraceWrapping:
+  AfterCaseLabel: false
+  AfterClass: false
+  AfterControlStatement: Never
+  AfterEnum: false
+  AfterFunction: false
+  AfterNamespace: false
+  AfterStruct: false
+  AfterUnion: false
+  BeforeCatch: false
+  BeforeElse: false
+  BeforeLambdaBody: false
+  IndentBraces: false
+  SplitEmptyFunction: false
+  SplitEmptyRecord: false
+  SplitEmptyNamespace: false
+
+# Alignment
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: None
+AlignConsecutiveBitFields: None
+AlignConsecutiveDeclarations: None
+AlignConsecutiveMacros: None
+AlignEscapedNewlines: Left
+AlignOperands: Align
+AlignTrailingComments: true
+
+# Arguments and parameters
+AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: true
+BinPackArguments: true
+BinPackParameters: true
+
+# Short forms
+AllowShortBlocksOnASingleLine: Empty
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortEnumsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: false
+
+# Breaks
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: true
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+BreakStringLiterals: true
+
+# Constructors and initializers
+ConstructorInitializerIndentWidth: 4
+PackConstructorInitializers: NextLine
+
+# Includes
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex: '^<.*\.h>'
+    Priority: 1
+  - Regex: '^<.*>'
+    Priority: 2
+  - Regex: '^".*"'
+    Priority: 3
+SortIncludes: CaseSensitive
+
+# Pointers and references
+DerivePointerAlignment: false
+PointerAlignment: Left
+ReferenceAlignment: Left
+
+# Spaces
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceAroundPointerQualifiers: Default
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceBeforeSquareBrackets: false
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 2
+SpacesInAngles: Never
+SpacesInCStyleCastParentheses: false
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+
+# Miscellaneous
+Cpp11BracedListStyle: true
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+FixNamespaceComments: true
+InsertBraces: false
+InsertTrailingCommas: None
+MaxEmptyLinesToKeep: 1
+QualifierAlignment: Leave
+ReflowComments: true
+SeparateDefinitionBlocks: Leave
+SortUsingDeclarations: true
+Standard: c++20
+...

+ 109 - 0
.clang-tidy

@@ -0,0 +1,109 @@
+---
+Checks: >
+  -*,
+  bugprone-*,
+  cert-*,
+  clang-analyzer-*,
+  cppcoreguidelines-*,
+  google-*,
+  hicpp-*,
+  misc-*,
+  modernize-*,
+  performance-*,
+  portability-*,
+  readability-*,
+  -bugprone-easily-swappable-parameters,
+  -cppcoreguidelines-avoid-magic-numbers,
+  -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
+  -cppcoreguidelines-pro-bounds-constant-array-index,
+  -cppcoreguidelines-pro-bounds-pointer-arithmetic,
+  -cppcoreguidelines-pro-type-reinterpret-cast,
+  -google-readability-todo,
+  -hicpp-no-array-decay,
+  -misc-non-private-member-variables-in-classes,
+  -modernize-use-trailing-return-type,
+  -readability-magic-numbers,
+  -readability-identifier-length
+
+WarningsAsErrors: ''
+
+HeaderFilterRegex: '.*'
+
+CheckOptions:
+  - key: readability-identifier-naming.ClassCase
+    value: CamelCase
+  - key: readability-identifier-naming.ClassMemberCase
+    value: lower_case
+  - key: readability-identifier-naming.ClassMemberSuffix
+    value: '_'
+  - key: readability-identifier-naming.ConstantCase
+    value: UPPER_CASE
+  - key: readability-identifier-naming.ConstexprVariableCase
+    value: CamelCase
+  - key: readability-identifier-naming.ConstexprVariablePrefix
+    value: k
+  - key: readability-identifier-naming.EnumCase
+    value: CamelCase
+  - key: readability-identifier-naming.EnumConstantCase
+    value: CamelCase
+  - key: readability-identifier-naming.EnumConstantPrefix
+    value: k
+  - key: readability-identifier-naming.FunctionCase
+    value: CamelCase
+  - key: readability-identifier-naming.GlobalConstantCase
+    value: CamelCase
+  - key: readability-identifier-naming.GlobalConstantPrefix
+    value: k
+  - key: readability-identifier-naming.LocalConstantCase
+    value: CamelCase
+  - key: readability-identifier-naming.LocalConstantPrefix
+    value: k
+  - key: readability-identifier-naming.LocalVariableCase
+    value: lower_case
+  - key: readability-identifier-naming.MacroDefinitionCase
+    value: UPPER_CASE
+  - key: readability-identifier-naming.MemberCase
+    value: lower_case
+  - key: readability-identifier-naming.MethodCase
+    value: CamelCase
+  - key: readability-identifier-naming.NamespaceCase
+    value: lower_case
+  - key: readability-identifier-naming.ParameterCase
+    value: lower_case
+  - key: readability-identifier-naming.PrivateMemberSuffix
+    value: '_'
+  - key: readability-identifier-naming.ProtectedMemberSuffix
+    value: '_'
+  - key: readability-identifier-naming.PublicMemberCase
+    value: lower_case
+  - key: readability-identifier-naming.StaticConstantCase
+    value: CamelCase
+  - key: readability-identifier-naming.StaticConstantPrefix
+    value: k
+  - key: readability-identifier-naming.StaticVariableCase
+    value: lower_case
+  - key: readability-identifier-naming.StructCase
+    value: CamelCase
+  - key: readability-identifier-naming.TemplateParameterCase
+    value: CamelCase
+  - key: readability-identifier-naming.TypedefCase
+    value: CamelCase
+  - key: readability-identifier-naming.UnionCase
+    value: CamelCase
+  - key: readability-identifier-naming.VariableCase
+    value: lower_case
+  - key: readability-function-cognitive-complexity.Threshold
+    value: 25
+  - key: modernize-loop-convert.MinConfidence
+    value: reasonable
+  - key: modernize-replace-auto-ptr.IncludeStyle
+    value: llvm
+  - key: modernize-pass-by-value.IncludeStyle
+    value: llvm
+  - key: performance-move-const-arg.CheckTriviallyCopyableMove
+    value: false
+  - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
+    value: true
+  - key: hicpp-special-member-functions.AllowSoleDefaultDtor
+    value: true
+...

+ 39 - 0
.gitignore

@@ -0,0 +1,39 @@
+# Build directories
+build/
+cmake-build-*/
+out/
+
+# IDE files
+.idea/
+.vscode/
+*.swp
+*.swo
+*~
+
+# Compiled files
+*.o
+*.a
+*.so
+*.dylib
+
+# CMake generated files
+CMakeFiles/
+CMakeCache.txt
+cmake_install.cmake
+compile_commands.json
+Makefile
+
+# Debug files
+*.dSYM/
+*.pdb
+
+# Test output
+Testing/
+CTestTestfile.cmake
+
+# External dependencies (fetched by CMake)
+_deps/
+
+# OS files
+.DS_Store
+Thumbs.db

+ 151 - 0
CMakeLists.txt

@@ -0,0 +1,151 @@
+cmake_minimum_required(VERSION 3.22)
+
+project(smartbotic-crm
+    VERSION 0.1.0
+    DESCRIPTION "SmartBotic CRM System"
+    LANGUAGES CXX
+)
+
+# C++20 standard
+set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+# Export compile commands for tooling
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+# Build options
+option(BUILD_TESTING "Build tests" ON)
+option(ENABLE_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)
+
+# Compiler warnings
+add_compile_options(
+    -Wall
+    -Wextra
+    -Wpedantic
+    -Werror
+    -Wno-unused-parameter
+)
+
+# Sanitizers for debug builds
+if(ENABLE_SANITIZERS)
+    add_compile_options(-fsanitize=address,undefined)
+    add_link_options(-fsanitize=address,undefined)
+endif()
+
+# Include FetchContent module
+include(FetchContent)
+
+# ============================================================================
+# External Dependencies via FetchContent
+# ============================================================================
+
+# spdlog - Fast C++ logging library
+FetchContent_Declare(
+    spdlog
+    GIT_REPOSITORY https://github.com/gabime/spdlog.git
+    GIT_TAG v1.13.0
+)
+
+# nlohmann_json - JSON for Modern C++
+FetchContent_Declare(
+    nlohmann_json
+    GIT_REPOSITORY https://github.com/nlohmann/json.git
+    GIT_TAG v3.11.3
+)
+
+# gRPC and Protobuf
+FetchContent_Declare(
+    grpc
+    GIT_REPOSITORY https://github.com/grpc/grpc.git
+    GIT_TAG v1.60.0
+    GIT_SHALLOW TRUE
+)
+
+# libsodium - Cryptography library
+FetchContent_Declare(
+    libsodium
+    GIT_REPOSITORY https://github.com/jedisct1/libsodium.git
+    GIT_TAG 1.0.19
+)
+
+# Make dependencies available
+message(STATUS "Fetching spdlog...")
+FetchContent_MakeAvailable(spdlog)
+
+message(STATUS "Fetching nlohmann_json...")
+FetchContent_MakeAvailable(nlohmann_json)
+
+message(STATUS "Fetching gRPC (this may take a while)...")
+set(gRPC_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+set(gRPC_INSTALL OFF CACHE BOOL "" FORCE)
+set(ABSL_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
+set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
+FetchContent_MakeAvailable(grpc)
+
+# libsodium requires special handling as it uses autotools
+FetchContent_GetProperties(libsodium)
+if(NOT libsodium_POPULATED)
+    FetchContent_Populate(libsodium)
+
+    # Build libsodium using autotools
+    execute_process(
+        COMMAND ${libsodium_SOURCE_DIR}/configure
+                --prefix=${libsodium_BINARY_DIR}/install
+                --disable-shared
+                --enable-static
+        WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
+        RESULT_VARIABLE SODIUM_CONFIGURE_RESULT
+    )
+
+    if(NOT SODIUM_CONFIGURE_RESULT EQUAL 0)
+        message(WARNING "libsodium configure failed, will try system libsodium")
+        find_package(PkgConfig REQUIRED)
+        pkg_check_modules(SODIUM REQUIRED libsodium)
+    else()
+        execute_process(
+            COMMAND make -j${CMAKE_BUILD_PARALLEL_LEVEL}
+            WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
+        )
+        execute_process(
+            COMMAND make install
+            WORKING_DIRECTORY ${libsodium_SOURCE_DIR}
+        )
+
+        set(SODIUM_INCLUDE_DIRS ${libsodium_BINARY_DIR}/install/include)
+        set(SODIUM_LIBRARY_DIRS ${libsodium_BINARY_DIR}/install/lib)
+        set(SODIUM_LIBRARIES sodium)
+    endif()
+endif()
+
+# Create imported target for libsodium
+add_library(sodium STATIC IMPORTED GLOBAL)
+set_target_properties(sodium PROPERTIES
+    IMPORTED_LOCATION ${SODIUM_LIBRARY_DIRS}/libsodium.a
+    INTERFACE_INCLUDE_DIRECTORIES ${SODIUM_INCLUDE_DIRS}
+)
+
+# ============================================================================
+# Project Subdirectories
+# ============================================================================
+
+add_subdirectory(common)
+add_subdirectory(proto)
+add_subdirectory(database)
+add_subdirectory(webserver)
+add_subdirectory(webui)
+
+# ============================================================================
+# Summary
+# ============================================================================
+
+message(STATUS "")
+message(STATUS "SmartBotic CRM Configuration Summary")
+message(STATUS "=====================================")
+message(STATUS "Version:           ${PROJECT_VERSION}")
+message(STATUS "C++ Standard:      ${CMAKE_CXX_STANDARD}")
+message(STATUS "Build Type:        ${CMAKE_BUILD_TYPE}")
+message(STATUS "Compiler:          ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
+message(STATUS "Build Testing:     ${BUILD_TESTING}")
+message(STATUS "Sanitizers:        ${ENABLE_SANITIZERS}")
+message(STATUS "")

+ 69 - 0
CMakePresets.json

@@ -0,0 +1,69 @@
+{
+    "version": 6,
+    "cmakeMinimumRequired": {
+        "major": 3,
+        "minor": 22,
+        "patch": 0
+    },
+    "configurePresets": [
+        {
+            "name": "base",
+            "hidden": true,
+            "generator": "Ninja",
+            "binaryDir": "${sourceDir}/build/${presetName}",
+            "cacheVariables": {
+                "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
+            }
+        },
+        {
+            "name": "debug",
+            "displayName": "Debug",
+            "description": "Debug build with full debugging information",
+            "inherits": "base",
+            "cacheVariables": {
+                "CMAKE_BUILD_TYPE": "Debug",
+                "BUILD_TESTING": "ON",
+                "ENABLE_SANITIZERS": "ON"
+            }
+        },
+        {
+            "name": "release",
+            "displayName": "Release",
+            "description": "Optimized release build",
+            "inherits": "base",
+            "cacheVariables": {
+                "CMAKE_BUILD_TYPE": "Release",
+                "BUILD_TESTING": "OFF",
+                "ENABLE_SANITIZERS": "OFF"
+            }
+        },
+        {
+            "name": "relwithdebinfo",
+            "displayName": "Release with Debug Info",
+            "description": "Optimized build with debug symbols",
+            "inherits": "base",
+            "cacheVariables": {
+                "CMAKE_BUILD_TYPE": "RelWithDebInfo",
+                "BUILD_TESTING": "ON",
+                "ENABLE_SANITIZERS": "OFF"
+            }
+        }
+    ],
+    "buildPresets": [
+        {
+            "name": "debug",
+            "displayName": "Debug Build",
+            "configurePreset": "debug"
+        },
+        {
+            "name": "release",
+            "displayName": "Release Build",
+            "configurePreset": "release"
+        },
+        {
+            "name": "relwithdebinfo",
+            "displayName": "RelWithDebInfo Build",
+            "configurePreset": "relwithdebinfo"
+        }
+    ]
+}

+ 19 - 0
common/CMakeLists.txt

@@ -0,0 +1,19 @@
+# Common library - shared utilities and types
+
+add_library(smartbotic_common STATIC
+    src/common.cpp
+)
+
+target_include_directories(smartbotic_common
+    PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+        $<INSTALL_INTERFACE:include>
+)
+
+target_link_libraries(smartbotic_common
+    PUBLIC
+        spdlog::spdlog
+        nlohmann_json::nlohmann_json
+)
+
+add_library(smartbotic::common ALIAS smartbotic_common)

+ 23 - 0
common/include/smartbotic/common.hpp

@@ -0,0 +1,23 @@
+#pragma once
+
+#include <string>
+#include <string_view>
+
+namespace smartbotic::common {
+
+/// Application version information
+struct Version {
+    static constexpr int kMajor = 0;
+    static constexpr int kMinor = 1;
+    static constexpr int kPatch = 0;
+
+    [[nodiscard]] static auto GetString() -> std::string;
+};
+
+/// Initialize common logging and utilities
+void Initialize(std::string_view app_name);
+
+/// Shutdown common resources
+void Shutdown();
+
+}  // namespace smartbotic::common

+ 23 - 0
common/src/common.cpp

@@ -0,0 +1,23 @@
+#include "smartbotic/common.hpp"
+
+#include <spdlog/spdlog.h>
+
+#include <format>
+
+namespace smartbotic::common {
+
+auto Version::GetString() -> std::string {
+    return std::format("{}.{}.{}", kMajor, kMinor, kPatch);
+}
+
+void Initialize(std::string_view app_name) {
+    spdlog::set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%n] [%^%l%$] %v");
+    spdlog::info("{} v{} initializing", app_name, Version::GetString());
+}
+
+void Shutdown() {
+    spdlog::info("Shutting down");
+    spdlog::shutdown();
+}
+
+}  // namespace smartbotic::common

+ 18 - 0
database/CMakeLists.txt

@@ -0,0 +1,18 @@
+# Database service - smartbotic-db binary
+
+add_executable(smartbotic-db
+    src/main.cpp
+)
+
+target_include_directories(smartbotic-db
+    PRIVATE
+        ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+target_link_libraries(smartbotic-db
+    PRIVATE
+        smartbotic::common
+        smartbotic::proto
+        spdlog::spdlog
+        sodium
+)

+ 16 - 0
database/src/main.cpp

@@ -0,0 +1,16 @@
+#include <spdlog/spdlog.h>
+
+#include "smartbotic/common.hpp"
+
+int main(int argc, char* argv[]) {
+    smartbotic::common::Initialize("smartbotic-db");
+
+    spdlog::info("SmartBotic Database Service starting...");
+
+    // TODO: Implement database service
+
+    spdlog::info("SmartBotic Database Service shutting down");
+    smartbotic::common::Shutdown();
+
+    return 0;
+}

+ 69 - 0
proto/CMakeLists.txt

@@ -0,0 +1,69 @@
+# Protocol Buffers and gRPC service definitions
+
+# Get protobuf and gRPC plugin locations
+set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
+set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
+
+# Proto files directory
+set(PROTO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proto)
+
+# Generated files directory
+set(PROTO_GEN_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
+file(MAKE_DIRECTORY ${PROTO_GEN_DIR})
+
+# Proto source files
+set(PROTO_FILES
+    ${PROTO_DIR}/crm.proto
+)
+
+# Generate C++ sources from proto files
+set(PROTO_SRCS)
+set(PROTO_HDRS)
+set(GRPC_SRCS)
+set(GRPC_HDRS)
+
+foreach(PROTO_FILE ${PROTO_FILES})
+    get_filename_component(PROTO_NAME ${PROTO_FILE} NAME_WE)
+
+    list(APPEND PROTO_SRCS "${PROTO_GEN_DIR}/${PROTO_NAME}.pb.cc")
+    list(APPEND PROTO_HDRS "${PROTO_GEN_DIR}/${PROTO_NAME}.pb.h")
+    list(APPEND GRPC_SRCS "${PROTO_GEN_DIR}/${PROTO_NAME}.grpc.pb.cc")
+    list(APPEND GRPC_HDRS "${PROTO_GEN_DIR}/${PROTO_NAME}.grpc.pb.h")
+
+    add_custom_command(
+        OUTPUT
+            "${PROTO_GEN_DIR}/${PROTO_NAME}.pb.cc"
+            "${PROTO_GEN_DIR}/${PROTO_NAME}.pb.h"
+            "${PROTO_GEN_DIR}/${PROTO_NAME}.grpc.pb.cc"
+            "${PROTO_GEN_DIR}/${PROTO_NAME}.grpc.pb.h"
+        COMMAND ${_PROTOBUF_PROTOC}
+            --cpp_out=${PROTO_GEN_DIR}
+            --grpc_out=${PROTO_GEN_DIR}
+            --plugin=protoc-gen-grpc=${_GRPC_CPP_PLUGIN_EXECUTABLE}
+            -I${PROTO_DIR}
+            ${PROTO_FILE}
+        DEPENDS ${PROTO_FILE}
+        COMMENT "Generating protobuf/gRPC sources for ${PROTO_NAME}"
+    )
+endforeach()
+
+# Proto library
+add_library(smartbotic_proto STATIC
+    ${PROTO_SRCS}
+    ${GRPC_SRCS}
+)
+
+target_include_directories(smartbotic_proto
+    PUBLIC
+        ${PROTO_GEN_DIR}
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+)
+
+target_link_libraries(smartbotic_proto
+    PUBLIC
+        grpc++
+        grpc++_reflection
+        libprotobuf
+)
+
+add_library(smartbotic::proto ALIAS smartbotic_proto)

+ 50 - 0
proto/proto/crm.proto

@@ -0,0 +1,50 @@
+syntax = "proto3";
+
+package smartbotic.crm;
+
+option cc_enable_arenas = true;
+
+// Common types
+message Empty {}
+
+message Timestamp {
+    int64 seconds = 1;
+    int32 nanos = 2;
+}
+
+// User management
+message User {
+    string id = 1;
+    string email = 2;
+    string name = 3;
+    Timestamp created_at = 4;
+    Timestamp updated_at = 5;
+}
+
+message CreateUserRequest {
+    string email = 1;
+    string name = 2;
+    string password = 3;
+}
+
+message GetUserRequest {
+    string id = 1;
+}
+
+message ListUsersRequest {
+    int32 page_size = 1;
+    string page_token = 2;
+}
+
+message ListUsersResponse {
+    repeated User users = 1;
+    string next_page_token = 2;
+}
+
+// CRM Service definition
+service CrmService {
+    // User management
+    rpc CreateUser(CreateUserRequest) returns (User);
+    rpc GetUser(GetUserRequest) returns (User);
+    rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
+}

+ 19 - 0
webserver/CMakeLists.txt

@@ -0,0 +1,19 @@
+# Web server - smartbotic-server binary
+
+add_executable(smartbotic-server
+    src/main.cpp
+)
+
+target_include_directories(smartbotic-server
+    PRIVATE
+        ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+target_link_libraries(smartbotic-server
+    PRIVATE
+        smartbotic::common
+        smartbotic::proto
+        spdlog::spdlog
+        nlohmann_json::nlohmann_json
+        sodium
+)

+ 16 - 0
webserver/src/main.cpp

@@ -0,0 +1,16 @@
+#include <spdlog/spdlog.h>
+
+#include "smartbotic/common.hpp"
+
+int main(int argc, char* argv[]) {
+    smartbotic::common::Initialize("smartbotic-server");
+
+    spdlog::info("SmartBotic Web Server starting...");
+
+    // TODO: Implement web server
+
+    spdlog::info("SmartBotic Web Server shutting down");
+    smartbotic::common::Shutdown();
+
+    return 0;
+}

+ 22 - 0
webui/CMakeLists.txt

@@ -0,0 +1,22 @@
+# Web UI - Static assets and frontend build integration
+
+# This directory contains the web UI frontend assets.
+# For now, we create a library for any C++ utilities that might be needed
+# for serving static content or WebSocket handling.
+
+add_library(smartbotic_webui STATIC
+    src/webui.cpp
+)
+
+target_include_directories(smartbotic_webui
+    PUBLIC
+        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+        $<INSTALL_INTERFACE:include>
+)
+
+target_link_libraries(smartbotic_webui
+    PUBLIC
+        smartbotic::common
+)
+
+add_library(smartbotic::webui ALIAS smartbotic_webui)

+ 14 - 0
webui/include/smartbotic/webui.hpp

@@ -0,0 +1,14 @@
+#pragma once
+
+#include <string>
+#include <string_view>
+
+namespace smartbotic::webui {
+
+/// Get the path to the web UI static assets
+[[nodiscard]] auto GetAssetsPath() -> std::string;
+
+/// Configure the assets path
+void SetAssetsPath(std::string_view path);
+
+}  // namespace smartbotic::webui

+ 19 - 0
webui/src/webui.cpp

@@ -0,0 +1,19 @@
+#include "smartbotic/webui.hpp"
+
+#include <string>
+
+namespace smartbotic::webui {
+
+namespace {
+std::string g_assets_path = "./webui/assets";
+}  // namespace
+
+auto GetAssetsPath() -> std::string {
+    return g_assets_path;
+}
+
+void SetAssetsPath(std::string_view path) {
+    g_assets_path = std::string(path);
+}
+
+}  // namespace smartbotic::webui