blob: 77dddc8e87da5d3f378e33e20d4ac3dc454cd2f6 [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-development/guide" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v3.1.1">
<title data-rh="true">Development Guide | Apache Answer</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://answer.apache.org/img/head-icon.png"><meta data-rh="true" name="twitter:image" content="https://answer.apache.org/img/head-icon.png"><meta data-rh="true" property="og:url" content="https://answer.apache.org/docs/development"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" property="og:locale:alternate" content="zh_CN"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="keywords" content="Free, Open-source, Q&amp;A Platform, Knowledge Sharing Platform, Community Forum, Knowledge Base, Developer Hub, Support Center"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Development Guide | Apache Answer"><meta data-rh="true" name="description" content="This guide will help you get started with the development of the project."><meta data-rh="true" property="og:description" content="This guide will help you get started with the development of the project."><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://answer.apache.org/docs/development"><link data-rh="true" rel="alternate" href="https://answer.apache.org/docs/development" hreflang="en"><link data-rh="true" rel="alternate" href="https://answer.apache.org/zh-CN/docs/development" hreflang="zh-CN"><link data-rh="true" rel="alternate" href="https://answer.apache.org/docs/development" hreflang="x-default"><script data-rh="true">var _paq=window._paq=window._paq||[];_paq.push(["setDoNotTrack",!0]),_paq.push(["disableCookies"]),_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),function(){var a="https://analytics.apache.org/";_paq.push(["setTrackerUrl",a+"matomo.php"]),_paq.push(["setSiteId","75"]);var e=document,p=e.createElement("script"),t=e.getElementsByTagName("script")[0];p.async=!0,p.src=a+"matomo.js",t.parentNode.insertBefore(p,t)}()</script><link rel="search" type="application/opensearchdescription+xml" title="Apache Answer" href="/opensearch.xml">
<link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="Apache Answer RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="Apache Answer Atom Feed">
<link rel="stylesheet" href="/fonts/fonts.css"><link rel="stylesheet" href="/assets/css/styles.dafb0c64.css">
<script src="/assets/js/runtime~main.5c009e72.js" defer="defer"></script>
<script src="/assets/js/main.7aa7d472.js" defer="defer"></script>
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_D8pK" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--primary"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="Answer Logo" class="themedImage_Pn4p themedImage--light_PnYV"><img src="/img/logo.svg" alt="Answer Logo" class="themedImage_Pn4p themedImage--dark_eYgw"></div></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs">Docs<!-- --></a><a class="navbar__item navbar__link" href="/plugins">Plugins<!-- --></a><a class="navbar__item navbar__link" href="/blog">Blog<!-- --></a><a class="navbar__item navbar__link" href="/download">Download<!-- --></a><div class="navbar__item dropdown dropdown--hoverable"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/community/support">Community<!-- --></a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/community/support">Support<!-- --></a></li><li><a href="https://meta.answer.dev" target="_blank" rel="noopener noreferrer" class="dropdown__link">Q&amp;A Community<!-- --></a></li><li><a class="dropdown__link" href="/community/team">Team<!-- --></a></li><li><a class="dropdown__link" href="/community/security">Security<!-- --></a></li><li><a class="dropdown__link" href="/community/security-model">Security Model<!-- --></a></li><li><a class="dropdown__link" href="/community/contributing">Contributing<!-- --></a></li><li><a href="https://github.com/apache/answer/projects" target="_blank" rel="noopener noreferrer" class="dropdown__link">Roadmap<!-- --></a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable"><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">ASF<!-- --></a><ul class="dropdown__menu"><li><a href="https://www.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<!-- --></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<!-- --></a></li><li><a href="https://www.apache.org/events/current-event.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<!-- --></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<!-- --></a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy<!-- --></a></li><li><a class="dropdown__link" href="/community/security">Security<!-- --></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<!-- --></a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link bi bi-translate"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_DSK9"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>English<!-- --></a><ul class="dropdown__menu"><li><a href="/docs/development" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="en">English<!-- --></a></li><li><a href="/zh-CN/docs/development" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="zh-CN">简体中文<!-- --></a></li></ul></div><a href="https://twitter.com/answerdev" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-twitter-x navbar-icon-link"></a><a href="https://discord.gg/a6PZZbfnFx" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-discord navbar-icon-link"></a><a href="https://github.com/apache/answer" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-github navbar-icon-link"></a><div class="searchBox_H2mL"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_eExm"><div class="docsWrapper_utsK"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_ntye" type="button"></button><div class="docRoot_vZM_"><aside class="theme-doc-sidebar-container docSidebarContainer_VQqE"><div class="sidebarViewport_A4gE"><div class="sidebar_mhZE"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_Y1UP"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/">Introduction<!-- --></a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="true" href="/docs/installation">Getting Started</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/installation">Installation<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/upgrade">Upgrade<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/command-line">Command Line<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/configfile">Config File<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/env">Environment Variables<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/plugins">Using Plugins<!-- --></a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/questions">User Guides</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible menu__list-item-collapsible--active"><a class="menu__link menu__link--sublist menu__link--active" aria-current="page" aria-expanded="true" href="/docs/development">Developer Guides</a><button aria-label="Collapse sidebar category &#x27;Developer Guides&#x27;" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" tabindex="0" href="/docs/development/plugins">Plugins</a><button aria-label="Expand sidebar category &#x27;Plugins&#x27;" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/database">Database<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api">API Document<!-- --></a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/notice">Notice<!-- --></a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/docs/faq">FAQ<!-- --></a></li></ul></nav></div></div></aside><main class="docMainContainer_dYoB"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_z5aJ"><div class="docItemContainer_c0TR"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Alpn" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_xK9p"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Developer Guides</span><meta itemprop="position" content="1"></li></ul></nav><div class="tocCollapsible_FsNm theme-doc-toc-mobile tocMobile_bxCs"><button type="button" class="clean-btn tocCollapsibleButton_a_s8">On this page<!-- --></button></div><div class="theme-doc-markdown markdown"><h1>Development Guide</h1>
<!-- --><p>This guide will help you get started with the development of the project.</p>
<!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="frontend">Frontend<!-- --><a href="#frontend" class="hash-link" aria-label="Direct link to Frontend" title="Direct link to Frontend"></a></h2>
<!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="installation">Installation<!-- --><a href="#installation" class="hash-link" aria-label="Direct link to Installation" title="Direct link to Installation"></a></h3>
<!-- --><ol>
<!-- --><li>
<!-- --><p>Ensure you have <!-- --><a href="https://nodejs.org/en" target="_blank" rel="noopener noreferrer">node</a> and <!-- --><a href="https://pnpm.io/installation" target="_blank" rel="noopener noreferrer">pnpm</a> installed.<!-- --></p>
<!-- --></li>
<!-- --><li>
<!-- --><p>After cloning the repository, run the following command. This will install all dependencies as well as build all local packages.</p>
<!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token builtin class-name">cd</span><span class="token plain"> ./ui</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">pnpm</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">install</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">// This </span><span class="token builtin class-name">command</span><span class="token plain"> will </span><span class="token builtin class-name">help</span><span class="token plain"> you create the tools you need </span><span class="token keyword" style="color:#00009f">for</span><span class="token plain"> good front-end code validation to ensure that the code style</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">pnpm</span><span class="token plain"> setup-lint</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<!-- --></li>
<!-- --><li>
<!-- --><p>To start a development server, run <!-- --><code>pnpm start</code>. now, your browser should already open automatically, and autoload <!-- --><code>http://localhost:3000</code>. you can also manually visit it.<!-- --></p>
<!-- --></li>
<!-- --><li>
<!-- --><p>To switch API, you can modify the <!-- --><code>ui/.env.development</code> file and then re-run pnpm start. If you&#x27;re just using it yourself, we recommend creating a <!-- --><code>.env.development.local</code> file that defines the address of the api you&#x27;re going to use.<!-- --></p>
<!-- --></li>
<!-- --></ol>
<!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="code-conventions">Code conventions<!-- --><a href="#code-conventions" class="hash-link" aria-label="Direct link to Code conventions" title="Direct link to Code conventions"></a></h3>
<!-- --><ul>
<!-- --><li><strong>Most important: Look around.</strong> Match the style you see used in the rest of the project. This includes formatting, naming files, naming things in code, naming things in documentation, etc.<!-- --></li>
<!-- --><li>We do have Prettier (a formatter) and ESLint (a syntax linter) to catch most stylistic problems. If you are working locally, you can run <!-- --><code>pnpm setup-lint</code>, which will help you initialize your <!-- --><code>husky</code> and <!-- --><code>pre-commit</code> files, which will automatically help you check your commits during the commit phase. Or just run <!-- --><code>pnpm lint</code> and <!-- --><code>pnpm prettier</code> to fix most code formatting.<!-- --></li>
<!-- --><li><strong>No runtime errors</strong> Before submitting the code, please ensure that there will be no errors when running locally. This will greatly reduce the workload of review.<!-- --></li>
<!-- --></ul>
<!-- --><details class="details_k1Sz alert alert--info details_mWBx" data-collapsed="true"><summary>frontend package structure</summary><div><div class="collapsibleContent_g7eR"><div><div class="codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-text codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">.</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── cmd</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── configs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── ...</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">└── ui (front-end project starts here)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── build (built results directory, usually without concern)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── public (html template for public)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── scripts (some scripting tools on front-end project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── src (almost all front-end resources are here)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── assets (static resources)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── common (project information/data defined here)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── components (all components of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── hooks (all hooks of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── i18n (Initialize the front-end i18n)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── pages (all pages of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── router (Project routing definition)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── services (all data api of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── stores (all data stores of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── utils (all utils of the project)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── plugins (UI Plugin Development &amp; Debugging Directory)</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div></div></div></details>
<!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="backend">Backend<!-- --><a href="#backend" class="hash-link" aria-label="Direct link to Backend" title="Direct link to Backend"></a></h2>
<!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="installation-1">Installation<!-- --><a href="#installation-1" class="hash-link" aria-label="Direct link to Installation" title="Direct link to Installation"></a></h3>
<!-- --><ol>
<!-- --><li>
<!-- --><p>Ensure you have <!-- --><a href="https://go.dev/doc/install" target="_blank" rel="noopener noreferrer">golang</a> installed.<!-- --></p>
<!-- --></li>
<!-- --><li>
<!-- --><p>After cloning the repository, run the following command for build.</p>
<!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">go mod download</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">go run cmd/answer/main.go init -C ./answer-data</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<!-- --></li>
<!-- --><li>
<!-- --><p>Visit <!-- --><code>http://localhost</code> to see the installation page and complete the installation.<!-- --></p>
<!-- --></li>
<!-- --><li>
<!-- --><p>Run the following command to start the server.</p>
<!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">go run cmd/answer/main.go run -C ./answer-data</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<!-- --></li>
<!-- --></ol>
<!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="code-conventions-1">Code conventions<!-- --><a href="#code-conventions-1" class="hash-link" aria-label="Direct link to Code conventions" title="Direct link to Code conventions"></a></h3>
<!-- --><p>We recommend that you follow <!-- --><a href="https://github.com/uber-go/guide" target="_blank" rel="noopener noreferrer">uber&#x27;s Golang Guidelines</a> code style.<!-- --></p>
<!-- --><details class="details_k1Sz alert alert--info details_mWBx" data-collapsed="true"><summary>backend package structure</summary><div><div class="collapsibleContent_g7eR"><div><div class="codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-text codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">.</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── cmd (main binary)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── configs (default configuration)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── docs (swagger documentation)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── i18n (International translation)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── internal</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── base (Basic component without service attributes)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── conf (Configuration)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── constant (constant)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── data (database/cache)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── handler (request/response handler)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── middleware (http middleware)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── pager (Pagination)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── reason (error reason key use to translator)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── server (http server)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── translator (translator for translate international)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> └── validator (validator for validate request)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── cli (binary commands)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── controller (request handler controller for user)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── controller_backyard (request handler controller for admin)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── entity (all entity about database table)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── install (installation related)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── migrations (upgrade related)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── repo (database/cache operations)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── router (http router)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> ├── schema (request/response schema)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> └── service (business logic)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── pkg (tools or third party)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">└── ui (frontend)</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div></div></div></details></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/apache/answer-website/edit/main/docs/development/guide.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_N_05" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page<!-- --></a></div><div class="col lastUpdated_VsjB"><span class="theme-last-updated">Last updated<!-- --> on <!-- --><b><time datetime="2025-03-25T09:28:02.000Z">Mar 25, 2025</time></b> by <!-- --><b>dashuai</b></span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/deploy-subdirectory"><div class="pagination-nav__sublabel">Previous<!-- --></div><div class="pagination-nav__label">Deploy subdirectory</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/development/plugins"><div class="pagination-nav__sublabel">Next<!-- --></div><div class="pagination-nav__label">Plugins Development Guide</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_fx0E thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#frontend" class="table-of-contents__link toc-highlight">Frontend</a><ul><li><a href="#installation" class="table-of-contents__link toc-highlight">Installation</a></li><li><a href="#code-conventions" class="table-of-contents__link toc-highlight">Code conventions</a></li></ul></li><li><a href="#backend" class="table-of-contents__link toc-highlight">Backend</a><ul><li><a href="#installation-1" class="table-of-contents__link toc-highlight">Installation</a></li><li><a href="#code-conventions-1" class="table-of-contents__link toc-highlight">Code conventions</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="footer"><div class="container py-3"><div class="d-flex justify-content-between flex-wrap text-center"><div><div class="mb-3"><a href="https://www.apache.org/" target="_blank"><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 525" role="img" style="width:120px"><defs><style>.cls-1{fill:#7c297d}.cls-3{fill:#dd552c}.cls-4{fill:#d22128}</style></defs><path class="cls-1" d="M458.804 181.745h49.045l87.413 220.094h-53.455l-14.777-38.044h-87.406l-15.094 38.044H371.39l87.413-220.094Zm55.65 142.746L483.33 244l-30.814 80.491h61.938ZM622.717 331.722h48.735c.317 21.066 16.037 33.332 40.246 33.332 20.75 0 33.958-8.49 33.958-23.267 0-15.41-14.151-24.526-45.275-31.447-51.57-10.69-76.096-32.066-76.096-68.226 0-39.93 31.757-64.771 82.384-64.771 52.19 0 85.521 28.296 85.521 72.628h-48.11c0-19.806-13.834-31.756-36.785-31.756-21.065 0-33.958 8.806-33.958 23.267 0 13.525 11.634 22.014 45.275 29.871 54.714 12.892 77.665 33.642 77.665 68.542 0 41.505-32.073 66.347-84.262 66.347-55.34 0-89.298-28.929-89.298-74.52ZM852.91 181.745h137.716v45.276h-87.722v55.023h79.859v44.023h-79.86v75.772H852.91V181.745Z"></path><path class="cls-3" d="M141.108 209.888c13.187-32.608 27.9-65.152 43.688-93.997-23.567-17.504-46.196-55.249-55.493-71.972-3.34 3.794-5.508 8.163-6.49 11.718-8.76 31.625 22.42 69.814-2.693 55.861C99.195 99.871 52.08 74.41 34.107 99.717c20.128 25.862 72.773 90.93 107 110.171Z"></path><path d="M184.796 115.891c15.297-27.95 31.6-52.428 48.501-70.063 0 0-16.858 24.4-40.936 73.18 14.582 4.016 56.113 12.256 113.96-2.686 1.422-10.513-5.645-22.075-40.863-25.947-22.993-2.524 27.597-54.902-9.052-79.674a46.281 46.281 0 0 0-3.486-2.14 45.29 45.29 0 0 0-3.911-1.205c-42.803-11.17-48.736 61.409-65.816 45.806-27.6-25.212-45.022-19.321-53.89-9.243 9.297 16.723 31.926 54.468 55.493 71.972Z" style="fill:#f79a23"></path><path class="cls-4" d="M106.682 303.838c9.662-28.946 21.286-61.466 34.426-93.95-34.228-19.241-86.873-84.31-107-110.171-3.594 5.056-6.05 12.108-6.868 21.752-4.39 51.802 49.052 90.153 38.398 97.158-14.092 9.267-42.141-22.26-53.196-2.229 16.023 20.584 48.662 57.777 94.24 87.44Z"></path><path class="cls-3" d="M254.756 192.118c-27.059-9.65 28.276-35.533 46.245-62.991 2.3-3.511 4.676-8.049 5.32-12.805-57.847 14.942-99.378 6.702-113.96 2.686-12.465 25.257-26.859 57.084-41.87 95.458 15.634 6.685 79.47 31.38 169.637 31.507 15.16-39.485-39.691-44.699-65.372-53.855Z"></path><path class="cls-4" d="M117.137 309.049c15.9 4.955 68.584 19.756 124.537 17.528 7.517-20.352-20.586-22.338-22.875-38.661-1.772-12.63 73.957 10.614 98.323-35.311a59.485 59.485 0 0 0 3.006-6.632c-90.167-.127-154.003-24.822-169.637-31.507-10.97 28.044-22.256 59.517-33.354 94.583Z"></path><path class="cls-1" d="M117.137 309.049c-7.145 22.57-14.193 46.682-21.035 72.164a1771.75 1771.75 0 0 0-7.19 27.643c53.106 17.531 102.008.04 103.666-21.638.014-.172-.018-.3-.008-.464 1.264-22.961-33.15-10.234-32.336-24.038.818-13.906 60.081-.081 78.409-29.895a34.139 34.139 0 0 0 3.03-6.244c-55.952 2.228-108.636-12.573-124.536-17.528ZM12.442 216.398c-.774 1.404-1.472 3.026-2.068 4.965-10.292 33.45 62.485 78.385 52.583 88.18-8.925 8.827-20.557-11.343-34.9-3.012a22.05 22.05 0 0 0-4.806 3.75c-16.221 16.619-.254 64.496 45.77 90.052-10.74 36.062-21.432 76.351-31.9 118.486 3.798-1.33 8.342-2.663 9.473-6.245 1.698-6.981 12.194-49.462 29.235-107.094 0 0 3.11-11.806 8.804-31.255a1996.422 1996.422 0 0 1 22.049-70.387c-45.578-29.663-78.217-66.856-94.24-87.44ZM404.167 144.735h9.264v-62.2h23.348v-9.062h-55.96v9.062h23.348v62.2zM464.853 112.958h36.469v31.777h9.358V73.473h-9.358v30.417h-36.47V73.473h-9.256v71.262h9.257v-31.777zM581.403 135.963h-35.17v-23.106h31.588v-8.772h-31.588V82.151h34.106v-8.678h-43.363v71.262h44.427v-8.772z"></path></svg></a></div><div class="fs-14"><div class="my-3"><span>Copyright © 2023 - <!-- -->2025<!-- --> The Apache Software Foundation, Licensed under the Apache License, Version 2.0.<!-- --></span><br><span>Apache, Apache Answer, the Apache logo and the Apache Answer logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.</span></div><span>Feature icons by <!-- --> <!-- --><a href="https://www.flaticon.com" class="link-secondary" target="_blank">Freepik</a>.<!-- --></span></div></div></div></div></footer></div>
</body>
</html>